|
| 1 | +package com.beowulfe.hap.accessories; |
| 2 | + |
| 3 | +import com.beowulfe.hap.HomekitAccessory; |
| 4 | +import com.beowulfe.hap.HomekitCharacteristicChangeCallback; |
| 5 | +import com.beowulfe.hap.Service; |
| 6 | +import com.beowulfe.hap.accessories.properties.CurrentSecuritySystemState; |
| 7 | +import com.beowulfe.hap.accessories.properties.SecuritySystemAlarmType; |
| 8 | +import com.beowulfe.hap.accessories.properties.TargetSecuritySystemState; |
| 9 | +import com.beowulfe.hap.impl.services.SecuritySystemService; |
| 10 | + |
| 11 | +import java.util.Collection; |
| 12 | +import java.util.Collections; |
| 13 | +import java.util.concurrent.CompletableFuture; |
| 14 | + |
| 15 | +/** |
| 16 | + * <p>A security system that can be armed so that when a contact sensor is opened or a motion |
| 17 | + * sensor detects movement, then a siren could be fired off. There are different modes for arming |
| 18 | + * the system. See {@link TargetSecuritySystemState} for more information.</p> |
| 19 | + * |
| 20 | + * @author Gaston Dombiak |
| 21 | + */ |
| 22 | +public interface SecuritySystem extends HomekitAccessory { |
| 23 | + |
| 24 | + /** |
| 25 | + * Retrieves the current state of the security system. The state describes if the system |
| 26 | + * is armed in any of its variations; or if the alarm has been triggered; or if the system |
| 27 | + * is disarmed. |
| 28 | + * |
| 29 | + * @return current state of the security system. |
| 30 | + */ |
| 31 | + CompletableFuture<CurrentSecuritySystemState> getCurrentSecuritySystemState(); |
| 32 | + |
| 33 | + /** |
| 34 | + * Subscribes to changes to the state of the security system. |
| 35 | + * |
| 36 | + * @param callback the function to call when the state changes. |
| 37 | + */ |
| 38 | + void subscribeCurrentSecuritySystemState(HomekitCharacteristicChangeCallback callback); |
| 39 | + |
| 40 | + /** |
| 41 | + * Unsubscribes from changes in the state of the security system. |
| 42 | + */ |
| 43 | + void unsubscribeCurrentSecuritySystemState(); |
| 44 | + |
| 45 | + /** |
| 46 | + * Sets the state of the security system. The security system could be armed in any |
| 47 | + * of its variations or disarmed. |
| 48 | + * |
| 49 | + * @param state target state of the security system. |
| 50 | + * @throws Exception when the change cannot be made. |
| 51 | + */ |
| 52 | + void setTargetSecuritySystemState(TargetSecuritySystemState state) throws Exception; |
| 53 | + |
| 54 | + /** |
| 55 | + * Retrieves the pending, but not yet completed, state of the security system. |
| 56 | + * |
| 57 | + * @return target state of the security system. |
| 58 | + */ |
| 59 | + CompletableFuture<TargetSecuritySystemState> getTargetSecuritySystemState(); |
| 60 | + |
| 61 | + /** |
| 62 | + * Subscribes to changes in the pending, but not yet completed, state of the security system. |
| 63 | + * |
| 64 | + * @param callback the function to call when the state changes. |
| 65 | + */ |
| 66 | + void subscribeTargetSecuritySystemState(HomekitCharacteristicChangeCallback callback); |
| 67 | + |
| 68 | + /** |
| 69 | + * Unsubscribes from changes in the pending, but not yet completed, state of the security system. |
| 70 | + */ |
| 71 | + void unsubscribeTargetSecuritySystemState(); |
| 72 | + |
| 73 | + /** |
| 74 | + * Retrieves the alarm type of the security system. |
| 75 | + * |
| 76 | + * @return alarm type of the security system. |
| 77 | + */ |
| 78 | + CompletableFuture<SecuritySystemAlarmType> getAlarmTypeState(); |
| 79 | + |
| 80 | + /** |
| 81 | + * Subscribes to changes to the alarm type of the security system. |
| 82 | + * |
| 83 | + * @param callback the function to call when the alarm type changes. |
| 84 | + */ |
| 85 | + void subscribeAlarmTypeState(HomekitCharacteristicChangeCallback callback); |
| 86 | + |
| 87 | + /** |
| 88 | + * Unsubscribes from changes in the alarm type of the security system. |
| 89 | + */ |
| 90 | + void unsubscribeAlarmTypeState(); |
| 91 | + |
| 92 | + @Override |
| 93 | + default Collection<Service> getServices() { |
| 94 | + return Collections.singleton(new SecuritySystemService(this)); |
| 95 | + } |
| 96 | +} |
0 commit comments