Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for valid values for (de)Humidifier target state #120

Merged
merged 4 commits into from
Dec 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ public interface HumidifierDehumidifierAccessory extends HomekitAccessory {
CompletableFuture<Void> 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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ public class TargetHumidifierDehumidifierStateCharacteristic
implements EventableCharacteristic {

public TargetHumidifierDehumidifierStateCharacteristic(
TargetHumidifierDehumidifierStateEnum[] validValues,
Supplier<CompletableFuture<TargetHumidifierDehumidifierStateEnum>> getter,
ExceptionalConsumer<TargetHumidifierDehumidifierStateEnum> setter,
Consumer<HomekitCharacteristicChangeCallback> subscriber,
Runnable unsubscriber) {
super(
"000000B4-0000-1000-8000-0026BB765291",
"target humidifier state",
TargetHumidifierDehumidifierStateEnum.values(),
validValues,
Optional.of(getter),
Optional.of(setter),
Optional.of(subscriber),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public HumidifierDehumidifierService(HumidifierDehumidifierAccessory accessory)
accessory::subscribeCurrentHumidifierDehumidifierState,
accessory::unsubscribeCurrentHumidifierDehumidifierState),
new TargetHumidifierDehumidifierStateCharacteristic(
accessory.getTargetHumidifierDehumidifierStateValidValues(),
accessory::getTargetHumidifierDehumidifierState,
accessory::setTargetHumidifierDehumidifierState,
accessory::subscribeTargetHumidifierDehumidifierState,
Expand Down