diff --git a/CHANGES.md b/CHANGES.md index 82f671c8c..398b3b93d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -11,7 +11,7 @@ ## New and improved * Valid values are supported for enum characteristics instead of min and max values -* Supported valid states for Thermostat, SecuritySystem and HeaterCooler [#108] +* Supported valid states for Thermostat, SecuritySystem, HeaterCooler and HumidifierDehumidifier [#108] [#120](https://github.com/hap-java/HAP-Java/pull/120) # HAP-Java 1.1.5 diff --git a/src/main/java/io/github/hapjava/accessories/HumidifierDehumidifierAccessory.java b/src/main/java/io/github/hapjava/accessories/HumidifierDehumidifierAccessory.java index bc723ce27..63a460526 100644 --- a/src/main/java/io/github/hapjava/accessories/HumidifierDehumidifierAccessory.java +++ b/src/main/java/io/github/hapjava/accessories/HumidifierDehumidifierAccessory.java @@ -57,6 +57,16 @@ public interface HumidifierDehumidifierAccessory extends HomekitAccessory { CompletableFuture setTargetHumidifierDehumidifierState( TargetHumidifierDehumidifierStateEnum state); + /** + * Valid values for target state. + * + * @return array of valid target states. + */ + default TargetHumidifierDehumidifierStateEnum[] + getTargetHumidifierDehumidifierStateValidValues() { + return TargetHumidifierDehumidifierStateEnum.values(); + } + /** * Subscribes to changes in the humidifier/dehumidifier current state. * diff --git a/src/main/java/io/github/hapjava/characteristics/impl/humidifier/TargetHumidifierDehumidifierStateCharacteristic.java b/src/main/java/io/github/hapjava/characteristics/impl/humidifier/TargetHumidifierDehumidifierStateCharacteristic.java index 278e7443c..4b4a90a54 100644 --- a/src/main/java/io/github/hapjava/characteristics/impl/humidifier/TargetHumidifierDehumidifierStateCharacteristic.java +++ b/src/main/java/io/github/hapjava/characteristics/impl/humidifier/TargetHumidifierDehumidifierStateCharacteristic.java @@ -15,6 +15,7 @@ public class TargetHumidifierDehumidifierStateCharacteristic implements EventableCharacteristic { public TargetHumidifierDehumidifierStateCharacteristic( + TargetHumidifierDehumidifierStateEnum[] validValues, Supplier> getter, ExceptionalConsumer setter, Consumer subscriber, @@ -22,7 +23,7 @@ public TargetHumidifierDehumidifierStateCharacteristic( super( "000000B4-0000-1000-8000-0026BB765291", "target humidifier state", - TargetHumidifierDehumidifierStateEnum.values(), + validValues, Optional.of(getter), Optional.of(setter), Optional.of(subscriber), diff --git a/src/main/java/io/github/hapjava/services/impl/HumidifierDehumidifierService.java b/src/main/java/io/github/hapjava/services/impl/HumidifierDehumidifierService.java index be57b7eb5..afd1dfdb2 100644 --- a/src/main/java/io/github/hapjava/services/impl/HumidifierDehumidifierService.java +++ b/src/main/java/io/github/hapjava/services/impl/HumidifierDehumidifierService.java @@ -54,6 +54,7 @@ public HumidifierDehumidifierService(HumidifierDehumidifierAccessory accessory) accessory::subscribeCurrentHumidifierDehumidifierState, accessory::unsubscribeCurrentHumidifierDehumidifierState), new TargetHumidifierDehumidifierStateCharacteristic( + accessory.getTargetHumidifierDehumidifierStateValidValues(), accessory::getTargetHumidifierDehumidifierState, accessory::setTargetHumidifierDehumidifierState, accessory::subscribeTargetHumidifierDehumidifierState,