mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[homekit] Make Thermostat.CurrentHeatingCoolingMode optional (#17191)
Just default it to OFF if it's not linked. The experience in Home app is still decent - it says "Cool to X", "Heat to X", or "Set to X", instead of "Cooling to X", "Heating to X" if it was actually running. I thought about defaulting it to "HEAT" or "COOL" depending on the current target mode, but if it's set to "AUTO", that's not a valid state for the current mode. Signed-off-by: Cody Cutrer <cody@cutrer.us> Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
This commit is contained in:
parent
330bcb54be
commit
93672ce16b
@ -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) | |
|
||||
|
@ -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 });
|
||||
|
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user