|
| 1 | +package io.github.hapjava.accessories; |
| 2 | + |
| 3 | +import io.github.hapjava.HomekitAccessory; |
| 4 | +import io.github.hapjava.HomekitCharacteristicChangeCallback; |
| 5 | +import io.github.hapjava.Service; |
| 6 | +import io.github.hapjava.accessories.properties.CarbonDioxideDetectedState; |
| 7 | +import io.github.hapjava.impl.services.CarbonDioxideSensorService; |
| 8 | +import java.util.Collection; |
| 9 | +import java.util.Collections; |
| 10 | +import java.util.concurrent.CompletableFuture; |
| 11 | + |
| 12 | +/** |
| 13 | + * A carbon dioxide sensor reports whether carbon dioxide has been detected or not. |
| 14 | + * |
| 15 | + * <p>Carbon dioxide sensors that run on batteries will need to implement this interface and also |
| 16 | + * implement {@link BatteryStatusAccessory}. |
| 17 | + * |
| 18 | + * @author Eugen Freiter |
| 19 | + */ |
| 20 | +public interface CarbonDioxideSensor extends HomekitAccessory { |
| 21 | + |
| 22 | + /** |
| 23 | + * Retrieves the state of the sensor that indicates if carbon dioxide has been detected. |
| 24 | + * |
| 25 | + * @return a future that will contain the carbon dioxide sensor's state |
| 26 | + */ |
| 27 | + CompletableFuture<CarbonDioxideDetectedState> getCarbonDioxideDetectedState(); |
| 28 | + |
| 29 | + @Override |
| 30 | + default Collection<Service> getServices() { |
| 31 | + return Collections.singleton(new CarbonDioxideSensorService(this)); |
| 32 | + } |
| 33 | + |
| 34 | + /** |
| 35 | + * Subscribes to changes in the carbon dioxide's state. |
| 36 | + * |
| 37 | + * @param callback the function to call when the state changes. |
| 38 | + */ |
| 39 | + void subscribeCarbonDioxideDetectedState(HomekitCharacteristicChangeCallback callback); |
| 40 | + |
| 41 | + /** |
| 42 | + * Retrieves the carbon dioxide level |
| 43 | + * |
| 44 | + * @return a future that will contain the carbon dioxide level as a value between 0 and 100000 |
| 45 | + */ |
| 46 | + CompletableFuture<Double> getCarbonDioxideLevel(); |
| 47 | + |
| 48 | + /** Unsubscribes from changes in the carbon dioxide's state. */ |
| 49 | + void unsubscribeCarbonDioxideDetectedState(); |
| 50 | + |
| 51 | + /** |
| 52 | + * Subscribes to changes in the carbon dioxide level. |
| 53 | + * |
| 54 | + * @param callback the function to call when the state changes. |
| 55 | + */ |
| 56 | + void subscribeCarbonDioxideLevel(HomekitCharacteristicChangeCallback callback); |
| 57 | + |
| 58 | + /** Unsubscribes from changes in the carbon dioxide level. */ |
| 59 | + void unsubscribeCarbonDioxideLevel(); |
| 60 | +} |
0 commit comments