[homekit] allow RelativeHumidity as an optional characteristic on Thermostat (#13504)

also support QuantityType as a valid state type for double characteristics
(such as RelativeHumidity).

Signed-off-by: Cody Cutrer <cody@cutrer.us>
This commit is contained in:
Cody Cutrer 2022-10-09 03:01:25 -06:00 committed by GitHub
parent 0aa28e5d40
commit 0409484c2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 7 deletions

View File

@ -656,7 +656,7 @@ Support for this is planned for the future release of openHAB HomeKit binding.
| | | CurrentVerticalTiltAngle | Number, Dimmer | Number Item = current angle of vertical slats (-90 to +90) . Dimmer Item = the percentage of openness (0%-100%) | | | | CurrentVerticalTiltAngle | Number, Dimmer | Number Item = current angle of vertical slats (-90 to +90) . Dimmer Item = the percentage of openness (0%-100%) |
| | | TargetVerticalTiltAngle | Number, Dimmer | Number Item = target angle of vertical slats. Dimmer Item = the percentage of openness (0%-100%) | | | | TargetVerticalTiltAngle | Number, Dimmer | Number Item = target angle of vertical slats. Dimmer Item = the percentage of openness (0%-100%) |
| Slat | | | | Slat which tilts on a vertical or a horizontal axis. Configuration "type:horizontal" or "type:vertical" | | Slat | | | | Slat which tilts on a vertical or a horizontal axis. Configuration "type:horizontal" or "type:vertical" |
| | CurrentSlatState | | String | Current slat state. possible values (FIXED,SWINGING,JAMMED). Custom mapping can be defined at item level, e.g. [JAMMED="JAM", FIXED="FIX"] | | | CurrentSlatState | | String | Current slat state. possible values (FIXED,SWINGING,JAMMED). Custom mapping can be defined at item level, e.g. [JAMMED="JAM", FIXED="FIX"] |
| | | Name | String | Name of the slat | | | | Name | String | Name of the slat |
| | | SwingMode | Number, Switch | Swing mode. values: 0/OFF=SWING DISABLED, 1/ON=SWING ENABLED | | | | SwingMode | Number, Switch | Swing mode. values: 0/OFF=SWING DISABLED, 1/ON=SWING ENABLED |
| | | CurrentTiltAngle | Number, Dimmer | Number Item = current angle of slats. values -90 to 90. A value of 0 indicates that the slats are rotated to a fully open position. Dimmer Item = the percentage of openness (0%-100%) | | | | CurrentTiltAngle | Number, Dimmer | Number Item = current angle of slats. values -90 to 90. A value of 0 indicates that the slats are rotated to a fully open position. Dimmer Item = the percentage of openness (0%-100%) |
@ -678,11 +678,11 @@ Support for this is planned for the future release of openHAB HomeKit binding.
| Fan | | | | Fan | | Fan | | | | Fan |
| | ActiveStatus | | Switch | Accessory current working status. A value of "ON"/"OPEN" indicates that the accessory is active and is functioning without any errors. | | | ActiveStatus | | Switch | Accessory current working status. A value of "ON"/"OPEN" indicates that the accessory is active and is functioning without any errors. |
| | | CurrentFanState | Number | Current fan state. values: 0=INACTIVE, 1=IDLE, 2=BLOWING AIR | | | | CurrentFanState | Number | Current fan state. values: 0=INACTIVE, 1=IDLE, 2=BLOWING AIR |
| | | TargetFanState | Number, Switch | Target fan state. values: 0/OFF=MANUAL, 1/ON=AUTO. Flag [inverted=true] swaps the default mapping | | | | TargetFanState | Number, Switch | Target fan state. values: 0/OFF=MANUAL, 1/ON=AUTO. Flag [inverted=true] swaps the default mapping |
| | | RotationDirection | Number, Switch | Rotation direction. values: 0/OFF=CLOCKWISE, 1/ON=COUNTER CLOCKWISE. Flag [inverted=true] swaps the default mapping | | | | RotationDirection | Number, Switch | Rotation direction. values: 0/OFF=CLOCKWISE, 1/ON=COUNTER CLOCKWISE. Flag [inverted=true] swaps the default mapping |
| | | RotationSpeed | Number, Dimmer | Fan rotation speed in % (1-100) | | | | RotationSpeed | Number, Dimmer | Fan rotation speed in % (1-100) |
| | | SwingMode | Number, Switch | Swing mode. values: 0/OFF=SWING DISABLED, 1/ON=SWING ENABLED. Flag [inverted=true] swaps the default mapping | | | | SwingMode | Number, Switch | Swing mode. values: 0/OFF=SWING DISABLED, 1/ON=SWING ENABLED. Flag [inverted=true] swaps the default mapping |
| | | LockControl | Number, Switch | Status of physical control lock. values: 0/OFF=CONTROL LOCK DISABLED, 1/ON=CONTROL LOCK ENABLED.Flag [inverted=true] swaps the default mapping | | | | LockControl | Number, Switch | Status of physical control lock. values: 0/OFF=CONTROL LOCK DISABLED, 1/ON=CONTROL LOCK ENABLED.Flag [inverted=true] swaps the default mapping |
| Thermostat | | | | A thermostat requires all mandatory characteristics defined below | | Thermostat | | | | A thermostat requires all mandatory characteristics defined below |
| | CurrentTemperature | | Number | Current temperature. supported configuration: minValue, maxValue, step | | | CurrentTemperature | | Number | Current temperature. supported configuration: minValue, maxValue, step |
| | TargetTemperature | | Number | Target temperature. supported configuration: minValue, maxValue, step | | | TargetTemperature | | Number | Target temperature. supported configuration: minValue, maxValue, step |
@ -691,6 +691,7 @@ Support for this is planned for the future release of openHAB HomeKit binding.
| | | Name | String | Name of the thermostat | | | | Name | String | Name of the thermostat |
| | | CoolingThresholdTemperature | Number | Maximum temperature that must be reached before cooling is turned on. min/max/step can configured at item level, e.g. minValue=10.5, maxValue=50, step=2] | | | | CoolingThresholdTemperature | Number | Maximum temperature that must be reached before cooling is turned on. min/max/step can configured at item level, e.g. minValue=10.5, maxValue=50, step=2] |
| | | HeatingThresholdTemperature | Number | Minimum temperature that must be reached before heating is turned on. min/max/step can configured at item level, e.g. minValue=10.5, maxValue=50, step=2] | | | | HeatingThresholdTemperature | Number | Minimum temperature that must be reached before heating is turned on. min/max/step can configured at item level, e.g. minValue=10.5, maxValue=50, step=2] |
| | | RelativeHumidity | Number | Relative humidity in % between 0 and 100. |
| HeaterCooler | | | | Heater or/and cooler device | | HeaterCooler | | | | Heater or/and cooler device |
| | ActiveStatus | | Switch | Accessory current working status. A value of "ON"/"OPEN" indicates that the accessory is active and is functioning without any errors. | | | ActiveStatus | | Switch | Accessory current working status. A value of "ON"/"OPEN" indicates that the accessory is active and is functioning without any errors. |
| | CurrentTemperature | | Number | Current temperature. supported configuration: minValue, maxValue, step | | | CurrentTemperature | | Number | Current temperature. supported configuration: minValue, maxValue, step |
@ -702,7 +703,7 @@ Support for this is planned for the future release of openHAB HomeKit binding.
| | | LockControl | Number, Switch | Status of physical control lock. values: 0/OFF=CONTROL LOCK DISABLED, 1/ON=CONTROL LOCK ENABLED | | | | LockControl | Number, Switch | Status of physical control lock. values: 0/OFF=CONTROL LOCK DISABLED, 1/ON=CONTROL LOCK ENABLED |
| | | CoolingThresholdTemperature | Number | Maximum temperature that must be reached before cooling is turned on. min/max/step can configured at item level, e.g. minValue=10.5, maxValue=50, step=2] | | | | CoolingThresholdTemperature | Number | Maximum temperature that must be reached before cooling is turned on. min/max/step can configured at item level, e.g. minValue=10.5, maxValue=50, step=2] |
| | | HeatingThresholdTemperature | Number | Minimum temperature that must be reached before heating is turned on. min/max/step can configured at item level, e.g. minValue=10.5, maxValue=50, step=2] | | | | HeatingThresholdTemperature | Number | Minimum temperature that must be reached before heating is turned on. min/max/step can configured at item level, e.g. minValue=10.5, maxValue=50, step=2] |
| Lock | | | | A Lock Mechanism. with flag [inverted=true] the default mapping to switch ON/OFF can be inverted. | | Lock | | | | A Lock Mechanism. with flag [inverted=true] the default mapping to switch ON/OFF can be inverted. |
| | LockCurrentState | | Switch, Number | Current state of lock mechanism (1/ON=SECURED, 0/OFF=UNSECURED, 2=JAMMED, 3=UNKNOWN) | | | LockCurrentState | | Switch, Number | Current state of lock mechanism (1/ON=SECURED, 0/OFF=UNSECURED, 2=JAMMED, 3=UNKNOWN) |
| | LockTargetState | | Switch | Target state of lock mechanism (ON=SECURED, OFF=UNSECURED) | | | LockTargetState | | Switch | Target state of lock mechanism (ON=SECURED, OFF=UNSECURED) |
| | | Name | String | Name of the lock | | | | Name | String | Name of the lock |
@ -732,7 +733,7 @@ Support for this is planned for the future release of openHAB HomeKit binding.
| | | LockTargetState | Switch | target states of lock mechanism (OFF=SECURED, ON=UNSECURED) | | | | LockTargetState | Switch | target states of lock mechanism (OFF=SECURED, ON=UNSECURED) |
| Battery | | | | Accessory with battery. Battery can be chargeable (configuration chargeable:true) and non-chargeable (configuration chargeable:false) | | Battery | | | | Accessory with battery. Battery can be chargeable (configuration chargeable:true) and non-chargeable (configuration chargeable:false) |
| | BatteryLevel | | Number | Battery level 0% to 100% | | | BatteryLevel | | Number | Battery level 0% to 100% |
| | BatteryLowStatus | | Switch, Contact, Number | Battery low indicator. ON/OPEN = battery level is low; for number if the value is below the lowThreshold, then it is low. Default is 20. | | | BatteryLowStatus | | Switch, Contact, Number | Battery low indicator. ON/OPEN = battery level is low; for number if the value is below the lowThreshold, then it is low. Default is 20. |
| | BatteryChargingState | | Switch, Contact | Mandatory only for chargeable battery. ON/OPEN = battery is charging | | | BatteryChargingState | | Switch, Contact | Mandatory only for chargeable battery. ON/OPEN = battery is charging |
| | | Name | String | Name of the battery accessory | | | | Name | String | Name of the battery accessory |
| Filter | | | | Accessory with filter maintenance indicator | | Filter | | | | Accessory with filter maintenance indicator |

View File

@ -96,6 +96,7 @@ import io.github.hapjava.characteristics.impl.fan.TargetFanStateCharacteristic;
import io.github.hapjava.characteristics.impl.fan.TargetFanStateEnum; import io.github.hapjava.characteristics.impl.fan.TargetFanStateEnum;
import io.github.hapjava.characteristics.impl.filtermaintenance.FilterLifeLevelCharacteristic; import io.github.hapjava.characteristics.impl.filtermaintenance.FilterLifeLevelCharacteristic;
import io.github.hapjava.characteristics.impl.filtermaintenance.ResetFilterIndicationCharacteristic; import io.github.hapjava.characteristics.impl.filtermaintenance.ResetFilterIndicationCharacteristic;
import io.github.hapjava.characteristics.impl.humiditysensor.CurrentRelativeHumidityCharacteristic;
import io.github.hapjava.characteristics.impl.lightbulb.BrightnessCharacteristic; import io.github.hapjava.characteristics.impl.lightbulb.BrightnessCharacteristic;
import io.github.hapjava.characteristics.impl.lightbulb.ColorTemperatureCharacteristic; import io.github.hapjava.characteristics.impl.lightbulb.ColorTemperatureCharacteristic;
import io.github.hapjava.characteristics.impl.lightbulb.HueCharacteristic; import io.github.hapjava.characteristics.impl.lightbulb.HueCharacteristic;
@ -159,6 +160,7 @@ public class HomekitCharacteristicFactory {
put(VOLUME, HomekitCharacteristicFactory::createVolumeCharacteristic); put(VOLUME, HomekitCharacteristicFactory::createVolumeCharacteristic);
put(COOLING_THRESHOLD_TEMPERATURE, HomekitCharacteristicFactory::createCoolingThresholdCharacteristic); put(COOLING_THRESHOLD_TEMPERATURE, HomekitCharacteristicFactory::createCoolingThresholdCharacteristic);
put(HEATING_THRESHOLD_TEMPERATURE, HomekitCharacteristicFactory::createHeatingThresholdCharacteristic); put(HEATING_THRESHOLD_TEMPERATURE, HomekitCharacteristicFactory::createHeatingThresholdCharacteristic);
put(RELATIVE_HUMIDITY, HomekitCharacteristicFactory::createRelativeHumidityCharacteristic);
put(REMAINING_DURATION, HomekitCharacteristicFactory::createRemainingDurationCharacteristic); put(REMAINING_DURATION, HomekitCharacteristicFactory::createRemainingDurationCharacteristic);
put(OZONE_DENSITY, HomekitCharacteristicFactory::createOzoneDensityCharacteristic); put(OZONE_DENSITY, HomekitCharacteristicFactory::createOzoneDensityCharacteristic);
put(NITROGEN_DIOXIDE_DENSITY, HomekitCharacteristicFactory::createNitrogenDioxideDensityCharacteristic); put(NITROGEN_DIOXIDE_DENSITY, HomekitCharacteristicFactory::createNitrogenDioxideDensityCharacteristic);
@ -355,6 +357,8 @@ public class HomekitCharacteristicFactory {
value = ((PercentType) state).doubleValue(); value = ((PercentType) state).doubleValue();
} else if (state instanceof DecimalType) { } else if (state instanceof DecimalType) {
value = ((DecimalType) state).doubleValue(); value = ((DecimalType) state).doubleValue();
} else if (state instanceof QuantityType) {
value = ((QuantityType) state).doubleValue();
} }
return CompletableFuture.completedFuture(value); return CompletableFuture.completedFuture(value);
}; };
@ -750,6 +754,13 @@ public class HomekitCharacteristicFactory {
getUnsubscriber(taggedItem, HEATING_THRESHOLD_TEMPERATURE, updater)); getUnsubscriber(taggedItem, HEATING_THRESHOLD_TEMPERATURE, updater));
} }
private static CurrentRelativeHumidityCharacteristic createRelativeHumidityCharacteristic(
HomekitTaggedItem taggedItem, HomekitAccessoryUpdater updater) {
return new CurrentRelativeHumidityCharacteristic(getDoubleSupplier(taggedItem, 0.0),
getSubscriber(taggedItem, RELATIVE_HUMIDITY, updater),
getUnsubscriber(taggedItem, RELATIVE_HUMIDITY, updater));
}
private static OzoneDensityCharacteristic createOzoneDensityCharacteristic(final HomekitTaggedItem taggedItem, private static OzoneDensityCharacteristic createOzoneDensityCharacteristic(final HomekitTaggedItem taggedItem,
HomekitAccessoryUpdater updater) { HomekitAccessoryUpdater updater) {
return new OzoneDensityCharacteristic( return new OzoneDensityCharacteristic(