|
| 1 | +package com.beowulfe.hap.accessories; |
| 2 | + |
| 3 | +import java.util.Collection; |
| 4 | +import java.util.Collections; |
| 5 | +import java.util.concurrent.CompletableFuture; |
| 6 | + |
| 7 | +import com.beowulfe.hap.HomekitAccessory; |
| 8 | +import com.beowulfe.hap.HomekitCharacteristicChangeCallback; |
| 9 | +import com.beowulfe.hap.Service; |
| 10 | +import com.beowulfe.hap.accessories.properties.ValveType; |
| 11 | +import com.beowulfe.hap.impl.services.ValveService; |
| 12 | + |
| 13 | +/** |
| 14 | + * A Valve (sprinkler head, faucet, etc.) |
| 15 | + * |
| 16 | + * @author Tim Harper |
| 17 | + */ |
| 18 | +public interface Valve extends HomekitAccessory { |
| 19 | + |
| 20 | + @Override |
| 21 | + default Collection<Service> getServices() { |
| 22 | + return Collections.singleton(new ValveService(this)); |
| 23 | + } |
| 24 | + |
| 25 | + /** |
| 26 | + * Retrieves the current active state of the valve; Active could mean the valve is open (but not necessarily |
| 27 | + * running), |
| 28 | + * or that the valve is associated with an active watering program (like a watering program) but is not currently |
| 29 | + * running. |
| 30 | + * |
| 31 | + * To communicate water is flowing through a valve, inUse should be used. |
| 32 | + * |
| 33 | + * @return a future that will contain the binary state |
| 34 | + */ |
| 35 | + CompletableFuture<Boolean> getValveActive(); |
| 36 | + |
| 37 | + /** |
| 38 | + * Sets the valve active state |
| 39 | + * |
| 40 | + * @param active the binary state to set |
| 41 | + * @return a future that completes when the change is made |
| 42 | + * @throws Exception when the change cannot be made |
| 43 | + */ |
| 44 | + CompletableFuture<Void> setValveActive(boolean active) throws Exception; |
| 45 | + |
| 46 | + /** |
| 47 | + * Subscribes to changes in the active state of the valve. |
| 48 | + * |
| 49 | + * @param callback the function to call when the state changes. |
| 50 | + */ |
| 51 | + void subscribeValveActive(HomekitCharacteristicChangeCallback callback); |
| 52 | + |
| 53 | + /** |
| 54 | + * Unsubscribes from changes in the valve active state. |
| 55 | + */ |
| 56 | + void unsubscribeValveActive(); |
| 57 | + |
| 58 | + /** |
| 59 | + * Retrieves the current inUse state of the valve; InUse usually means water is flowing through the valve. |
| 60 | + * |
| 61 | + * To communicate water is flowing through a valve, inUse should be used. |
| 62 | + * |
| 63 | + * @return a future that will contain the binary state |
| 64 | + */ |
| 65 | + CompletableFuture<Boolean> getValveInUse(); |
| 66 | + |
| 67 | + /** |
| 68 | + * Subscribes to changes in the inUse state of the valve. |
| 69 | + * |
| 70 | + * @param callback the function to call when the state changes. |
| 71 | + */ |
| 72 | + void subscribeValveInUse(HomekitCharacteristicChangeCallback callback); |
| 73 | + |
| 74 | + /** |
| 75 | + * Unsubscribes from changes in the valve inUse state. |
| 76 | + */ |
| 77 | + void unsubscribeValveInUse(); |
| 78 | + |
| 79 | + /** |
| 80 | + * Retrieves the valve type. |
| 81 | + * |
| 82 | + * To communicate water is flowing through a valve, inUse should be used. |
| 83 | + * |
| 84 | + * @return a future that will contain the binary state |
| 85 | + */ |
| 86 | + CompletableFuture<ValveType> getValveType(); |
| 87 | + |
| 88 | + /** |
| 89 | + * Subscribes to changes in the valveType state of the valve. |
| 90 | + * |
| 91 | + * @param callback the function to call when the state changes. |
| 92 | + */ |
| 93 | + void subscribeValveType(HomekitCharacteristicChangeCallback callback); |
| 94 | + |
| 95 | + /** |
| 96 | + * Unsubscribes from changes in the valveType state light. |
| 97 | + */ |
| 98 | + void unsubscribeValveType(); |
| 99 | +} |
0 commit comments