diff --git a/bundles/org.openhab.io.homekit/README.md b/bundles/org.openhab.io.homekit/README.md index 66cd5141159..9d420b9e4db 100644 --- a/bundles/org.openhab.io.homekit/README.md +++ b/bundles/org.openhab.io.homekit/README.md @@ -952,9 +952,9 @@ All accessories also support the following optional characteristic that can be l | | | FaultStatus | Contact, Number, String, Switch | Fault status | inverted (false) | NO_FAULT (0, OFF, CLOSED), GENERAL_FAULT (1, ON, OPEN) | | | | TamperedStatus | Contact, Number, String, Switch | Tampered status | inverted (false) | NOT_TAMPERED (0, OFF, CLOSED), TAMPERED (1, ON, OPEN) | | Thermostat | | | | A thermostat requires at least one of TargetTemperature, CoolingThresholdTemperature, or HeatingThresholdTemperature must be provided. | | | -| | CurrentHeatingCoolingMode | | Number, String, Switch | Current heating cooling mode | | OFF (0, OFF), HEAT (1, ON), COOL (2) | | | CurrentTemperature | | Number | Current temperature. | minValue (0), maxValue (100), step (0.1) | | | | TargetHeatingCoolingMode | | Number, String, Switch | Target heating cooling mode | | OFF (0, OFF), HEAT (1, ON), COOL (2), AUTO (3) [*](#customizable-enum) | +| | | CurrentHeatingCoolingMode | Number, String, Switch | Current heating cooling mode | | OFF (0, OFF), HEAT (1, ON), COOL (2) | | | | TargetTemperature | Number | Target temperature. If CoolingThresholdTemperature and HeatingThresholdTemperature are also provided, this characteristic is used when the thermostat is in HEAT or COOL mode. In AUTO mode, this characteristic receives the average of the two thresholds. | minValue (10), maxValue (38), step (0.1) | | | | | CoolingThresholdTemperature | Number | Maximum temperature that must be reached before cooling is turned on. If TargetTemperature is not provided, this characteristic will also be used in COOL mode. | minValue (10), maxValue (35), step (0.1) | | | | | HeatingThresholdTemperature | Number | Minimum temperature that must be reached before heating is turned on. If TargetTemperature is not provided, this characteristic will also be used in HEAT mode. | minValue (0), maxValue (25), step (0.1) | | diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitAccessoryFactory.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitAccessoryFactory.java index f019eeb821e..74462e7adeb 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitAccessoryFactory.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitAccessoryFactory.java @@ -104,8 +104,7 @@ public class HomekitAccessoryFactory { put(TELEVISION, new HomekitCharacteristicType[] { ACTIVE }); put(TELEVISION_SPEAKER, new HomekitCharacteristicType[] { MUTE }); put(TEMPERATURE_SENSOR, new HomekitCharacteristicType[] { CURRENT_TEMPERATURE }); - put(THERMOSTAT, new HomekitCharacteristicType[] { CURRENT_HEATING_COOLING_STATE, - TARGET_HEATING_COOLING_STATE, CURRENT_TEMPERATURE }); + put(THERMOSTAT, new HomekitCharacteristicType[] { TARGET_HEATING_COOLING_STATE, CURRENT_TEMPERATURE }); put(VALVE, new HomekitCharacteristicType[] { ACTIVE_STATUS, INUSE_STATUS }); put(WINDOW, new HomekitCharacteristicType[] { CURRENT_POSITION, TARGET_POSITION, POSITION_STATE }); put(WINDOW_COVERING, new HomekitCharacteristicType[] { TARGET_POSITION, CURRENT_POSITION, POSITION_STATE }); diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitThermostatImpl.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitThermostatImpl.java index fbbe9401c42..94f6bfae8b0 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitThermostatImpl.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitThermostatImpl.java @@ -34,6 +34,7 @@ import io.github.hapjava.characteristics.Characteristic; import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; import io.github.hapjava.characteristics.impl.thermostat.CoolingThresholdTemperatureCharacteristic; import io.github.hapjava.characteristics.impl.thermostat.CurrentHeatingCoolingStateCharacteristic; +import io.github.hapjava.characteristics.impl.thermostat.CurrentHeatingCoolingStateEnum; import io.github.hapjava.characteristics.impl.thermostat.CurrentTemperatureCharacteristic; import io.github.hapjava.characteristics.impl.thermostat.HeatingThresholdTemperatureCharacteristic; import io.github.hapjava.characteristics.impl.thermostat.TargetHeatingCoolingStateCharacteristic; @@ -186,14 +187,22 @@ class HomekitThermostatImpl extends AbstractHomekitAccessoryImpl { })); } - // This characteristic is technically mandatory, but we provide a default if it's not provided + // These characteristics are technically mandatory, but we provide defaults if they're not provided + var currentHeatingCoolingStateCharacteristic = getCharacteristic(CurrentHeatingCoolingStateCharacteristic.class) + .orElseGet(() -> new CurrentHeatingCoolingStateCharacteristic( + new CurrentHeatingCoolingStateEnum[] { CurrentHeatingCoolingStateEnum.OFF }, + () -> CompletableFuture.completedFuture(CurrentHeatingCoolingStateEnum.OFF), (cb) -> { + }, () -> { + }) + + ); var displayUnitCharacteristic = getCharacteristic(TemperatureDisplayUnitCharacteristic.class) .orElseGet(() -> HomekitCharacteristicFactory.createSystemTemperatureDisplayUnitCharacteristic()); - addService(new ThermostatService(getCharacteristic(CurrentHeatingCoolingStateCharacteristic.class).get(), - targetHeatingCoolingStateCharacteristic, - getCharacteristic(CurrentTemperatureCharacteristic.class).get(), targetTemperatureCharacteristic.get(), - displayUnitCharacteristic)); + addService( + new ThermostatService(currentHeatingCoolingStateCharacteristic, targetHeatingCoolingStateCharacteristic, + getCharacteristic(CurrentTemperatureCharacteristic.class).get(), + targetTemperatureCharacteristic.get(), displayUnitCharacteristic)); } private void thresholdTemperatureChanged() {