[homekit] Target Fan state - add support for Switch Item (#12985)
* add support for SwitchItem for target fan state Signed-off-by: Eugen Freiter <freiter@gmx.de>
This commit is contained in:
parent
b31f06a4cd
commit
6f3cb286d9
@ -540,7 +540,7 @@ Support for this is planned for the future release of openHAB HomeKit binding.
|
|||||||
## Supported accessory type
|
## Supported accessory type
|
||||||
|
|
||||||
| Accessory Tag | Mandatory Characteristics | Optional Characteristics | Supported OH items | Description |
|
| Accessory Tag | Mandatory Characteristics | Optional Characteristics | Supported OH items | Description |
|
||||||
|:---------------------|:----------------------------|:-----------------------------|:-------------------------|:-----------------------------------------------------------------|
|
|:---------------------|:----------------------------|:-----------------------------|:------------------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
| AirQualitySensor | | | | Air Quality Sensor which can measure different parameters |
|
| AirQualitySensor | | | | Air Quality Sensor which can measure different parameters |
|
||||||
| | AirQuality | | String | Air quality state, possible values (UNKNOWN,EXCELLENT,GOOD,FAIR,INFERIOR,POOR). Custom mapping can be defined at item level, e.g. [EXCELLENT="BEST", POOR="BAD"] |
|
| | AirQuality | | String | Air quality state, possible values (UNKNOWN,EXCELLENT,GOOD,FAIR,INFERIOR,POOR). Custom mapping can be defined at item level, e.g. [EXCELLENT="BEST", POOR="BAD"] |
|
||||||
| | | OzoneDensity | Number | Ozone density in micrograms/m3, max 1000 |
|
| | | OzoneDensity | Number | Ozone density in micrograms/m3, max 1000 |
|
||||||
@ -676,11 +676,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 | Target fan state. values: 0=MANUAL, 1=AUTO |
|
| | | 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 |
|
| | | 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 |
|
| | | 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 |
|
| | | 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 |
|
||||||
|
|||||||
@ -634,23 +634,12 @@ public class HomekitCharacteristicFactory {
|
|||||||
|
|
||||||
private static TargetFanStateCharacteristic createTargetFanStateCharacteristic(HomekitTaggedItem taggedItem,
|
private static TargetFanStateCharacteristic createTargetFanStateCharacteristic(HomekitTaggedItem taggedItem,
|
||||||
HomekitAccessoryUpdater updater) {
|
HomekitAccessoryUpdater updater) {
|
||||||
return new TargetFanStateCharacteristic(() -> {
|
return new TargetFanStateCharacteristic(
|
||||||
final @Nullable DecimalType value = taggedItem.getItem().getStateAs(DecimalType.class);
|
() -> getEnumFromItem(taggedItem, TargetFanStateEnum.MANUAL, TargetFanStateEnum.AUTO,
|
||||||
@Nullable
|
TargetFanStateEnum.AUTO),
|
||||||
TargetFanStateEnum targetFanStateEnum = value != null ? TargetFanStateEnum.fromCode(value.intValue())
|
(targetState) -> setValueFromEnum(taggedItem, targetState, TargetFanStateEnum.MANUAL,
|
||||||
: null;
|
TargetFanStateEnum.AUTO),
|
||||||
if (targetFanStateEnum == null) {
|
getSubscriber(taggedItem, TARGET_FAN_STATE, updater),
|
||||||
targetFanStateEnum = TargetFanStateEnum.AUTO;
|
|
||||||
}
|
|
||||||
return CompletableFuture.completedFuture(targetFanStateEnum);
|
|
||||||
}, (targetState) -> {
|
|
||||||
if (taggedItem.getItem() instanceof NumberItem) {
|
|
||||||
((NumberItem) taggedItem.getItem()).send(new DecimalType(targetState.getCode()));
|
|
||||||
} else {
|
|
||||||
logger.warn("Item type {} is not supported for {}. Only Number type is supported.",
|
|
||||||
taggedItem.getItem().getType(), taggedItem.getName());
|
|
||||||
}
|
|
||||||
}, getSubscriber(taggedItem, TARGET_FAN_STATE, updater),
|
|
||||||
getUnsubscriber(taggedItem, TARGET_FAN_STATE, updater));
|
getUnsubscriber(taggedItem, TARGET_FAN_STATE, updater));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user