[homekit] mapping configuration improvements (#9932)
* add support for custom mapping * add screenshot * remove unnecessary variable * make parameter nullable to avoid not required list instances Signed-off-by: Eugen Freiter <freiter@gmx.de>
This commit is contained in:
parent
ff9454596e
commit
bd949518de
|
@ -108,10 +108,10 @@ org.openhab.homekit:maximumTemperature=100
|
|||
| pin | Pin code used for pairing with iOS devices. Apparently, pin codes are provided by Apple and represent specific device types, so they cannot be chosen freely. The pin code 031-45-154 is used in sample applications and known to work. | 031-45-154 |
|
||||
| startDelay | HomeKit start delay in seconds in case the number of accessories is lower than last time. This helps to avoid resetting home app in case not all items have been initialised properly before HomeKit integration start. | 30 |
|
||||
| useFahrenheitTemperature | Set to true to use Fahrenheit degrees, or false to use Celsius degrees. | false |
|
||||
| thermostatTargetModeCool | Word used for activating the cooling mode of the device (if applicable). | CoolOn |
|
||||
| thermostatTargetModeHeat | Word used for activating the heating mode of the device (if applicable). | HeatOn |
|
||||
| thermostatTargetModeAuto | Word used for activating the automatic mode of the device (if applicable). | Auto |
|
||||
| thermostatTargetModeOff | Word used to set the thermostat mode of the device to off (if applicable). | Off |
|
||||
| thermostatTargetModeCool | Word used for activating the cooling mode of the device (if applicable). It can be overwritten at item level. | CoolOn |
|
||||
| thermostatTargetModeHeat | Word used for activating the heating mode of the device (if applicable). It can be overwritten at item level. | HeatOn |
|
||||
| thermostatTargetModeAuto | Word used for activating the automatic mode of the device (if applicable). It can be overwritten at item level. | Auto |
|
||||
| thermostatTargetModeOff | Word used to set the thermostat mode of the device to off (if applicable). It can be overwritten at item level. | Off |
|
||||
| minimumTemperature | Lower bound of possible temperatures, used in the user interface of the iOS device to display the allowed temperature range. Note that this setting applies to all devices in HomeKit. | -100 |
|
||||
| maximumTemperature | Upper bound of possible temperatures, used in the user interface of the iOS device to display the allowed temperature range. Note that this setting applies to all devices in HomeKit. | 100 |
|
||||
| name | Name under which this HomeKit bridge is announced on the network. This is also the name displayed on the iOS device when searching for available bridges. | openHAB |
|
||||
|
@ -198,6 +198,242 @@ Switch light1 "Light 1" (gLight) {homekit="Lighting.OnState"}
|
|||
Switch light2 "Light 2" (gLight) {homekit="Lighting.OnState"}
|
||||
```
|
||||
|
||||
|
||||
## Accessory Configuration Details
|
||||
|
||||
This section provides examples widely used accessory types.
|
||||
For complete list of supported accessory types and characteristics please see section [Supported accessory type](#Supported accessory type)
|
||||
|
||||
### Dimmers
|
||||
|
||||
The way HomeKit handles dimmer devices can be different to the actual dimmers' way of working.
|
||||
HomeKit home app sends following commands/update:
|
||||
|
||||
- On brightness change home app sends "ON" event along with target brightness, e.g. "Brightness = 50%" + "State = ON".
|
||||
- On "ON" event home app sends "ON" along with brightness 100%, i.e. "Brightness = 100%" + "State = ON"
|
||||
- On "OFF" event home app sends "OFF" without brightness information.
|
||||
|
||||
However, some dimmer devices for example do not expect brightness on "ON" event, some others do not expect "ON" upon brightness change.
|
||||
In order to support different devices HomeKit integration can filter some events. Which events should be filtered is defined via dimmerMode configuration.
|
||||
|
||||
```xtend
|
||||
Dimmer dimmer_light "Dimmer Light" {homekit="Lighting, Lighting.Brightness" [dimmerMode="<mode>"]}
|
||||
```
|
||||
|
||||
Following modes are supported:
|
||||
|
||||
- "normal" - no filtering. The commands will be sent to device as received from HomeKit. This is default mode.
|
||||
- "filterOn" - ON events are filtered out. only OFF events and brightness information are sent
|
||||
- "filterBrightness100" - only Brightness=100% is filtered out. everything else sent unchanged. This allows custom logic for soft launch in devices.
|
||||
- "filterOnExceptBrightness100" - ON events are filtered out in all cases except of brightness = 100%.
|
||||
|
||||
Examples:
|
||||
|
||||
```xtend
|
||||
Dimmer dimmer_light_1 "Dimmer Light 1" {homekit="Lighting, Lighting.Brightness" [dimmerMode="filterOn"]}
|
||||
Dimmer dimmer_light_2 "Dimmer Light 2" {homekit="Lighting, Lighting.Brightness" [dimmerMode="filterBrightness100"]}
|
||||
Dimmer dimmer_light_3 "Dimmer Light 3" {homekit="Lighting, Lighting.Brightness" [dimmerMode="filterOnExceptBrightness100"]}
|
||||
```
|
||||
|
||||
### Windows Covering (Blinds) / Window / Door
|
||||
|
||||
HomeKit Windows Covering, Window and Door accessory types have following mandatory characteristics:
|
||||
|
||||
- CurrentPosition (0-100% of current window covering position)
|
||||
- TargetPosition (0-100% of target position)
|
||||
- PositionState (DECREASING,INCREASING or STOPPED as state). If no state provided, HomeKit will send STOPPED
|
||||
|
||||
These characteristics can be mapped to a single openHAB rollershutter item. In such case currentPosition will always equal target position, means if you request to close a blind/window/door, HomeKit will immediately report that the blind/window/door is closed.
|
||||
As discussed above, one can use full or shorthand definition. Following two definitions are equal:
|
||||
|
||||
```xtend
|
||||
Rollershutter window "Window" {homekit = "Window"}
|
||||
Rollershutter door "Door" {homekit = "Door"}
|
||||
Rollershutter window_covering "Window Rollershutter" {homekit = "WindowCovering"}
|
||||
Rollershutter window_covering_long "Window Rollershutter long" {homekit = "WindowCovering, WindowCovering.CurrentPosition, WindowCovering.TargetPosition, WindowCovering.PositionState"}
|
||||
```
|
||||
|
||||
openHAB Rollershutter is defined by default as:
|
||||
|
||||
- OPEN if position is 0%,
|
||||
- CLOSED if position is 100%.
|
||||
|
||||
In contrast, HomeKit window covering/door/window have inverted mapping
|
||||
|
||||
- OPEN if position 100%
|
||||
- CLOSED if position is 0%
|
||||
|
||||
Therefore, HomeKit integration inverts by default the values between openHAB and HomeKit, e.g. if openHAB current position is 30% then it will send 70% to HomeKit app.
|
||||
In case you need to disable this logic you can do it with configuration parameter inverted="false", e.g.
|
||||
|
||||
```xtend
|
||||
Rollershutter window_covering "Window Rollershutter" {homekit = "WindowCovering" [inverted="false"]}
|
||||
Rollershutter window "Window" {homekit = "Window" [inverted="false"]}
|
||||
Rollershutter door "Door" {homekit = "Door" [inverted="false"]}
|
||||
|
||||
```
|
||||
|
||||
Window covering can have a number of optional characteristics like horizontal & vertical tilt, obstruction status and hold position trigger.
|
||||
If your blind supports tilt, and you want to control tilt via HomeKit you need to define blind as a group.
|
||||
e.g.
|
||||
|
||||
```xtend
|
||||
Group gBlind "Blind with tilt" {homekit = "WindowCovering"}
|
||||
Rollershutter window_covering "Blind" (gBlind) {homekit = "WindowCovering"}
|
||||
Dimmer window_covering_htilt "Blind horizontal tilt" (gBlind) {homekit = "WindowCovering.CurrentHorizontalTiltAngle, WindowCovering.TargetHorizontalTiltAngle"}
|
||||
Dimmer window_covering_vtilt "Blind vertical tilt" (gBlind) {homekit = "WindowCovering.CurrentVerticalTiltAngle, WindowCovering.TargetVerticalTiltAngle"}
|
||||
```
|
||||
### Thermostat
|
||||
A HomeKit thermostat has following mandatory characteristics:
|
||||
|
||||
- CurrentTemperature
|
||||
- TargetTemperature
|
||||
- CurrentHeatingCoolingMode
|
||||
- TargetHeatingCoolingMode
|
||||
|
||||
In order to define a thermostat you need to create a group with at least these 4 items.
|
||||
Example:
|
||||
|
||||
```xtend
|
||||
Group gThermostat "Thermostat" {homekit = "Thermostat"}
|
||||
Number thermostat_current_temp "Thermostat Current Temp [%.1f C]" (gThermostat) {homekit = "CurrentTemperature"}
|
||||
Number thermostat_target_temp "Thermostat Target Temp[%.1f C]" (gThermostat) {homekit = "TargetTemperature"}
|
||||
String thermostat_current_mode "Thermostat Current Mode" (gThermostat) {homekit = "CurrentHeatingCoolingMode"}
|
||||
String thermostat_target_mode "Thermostat Target Mode" (gThermostat) {homekit = "TargetHeatingCoolingMode"}
|
||||
```
|
||||
|
||||
In addition, thermostat can have thresholds for cooling and heating modes.
|
||||
Example with thresholds:
|
||||
|
||||
```xtend
|
||||
Group gThermostat "Thermostat" {homekit = "Thermostat"}
|
||||
Number thermostat_current_temp "Thermostat Current Temp [%.1f C]" (gThermostat) {homekit = "CurrentTemperature"}
|
||||
Number thermostat_target_temp "Thermostat Target Temp[%.1f C]" (gThermostat) {homekit = "TargetTemperature"}
|
||||
String thermostat_current_mode "Thermostat Current Mode" (gThermostat) {homekit = "CurrentHeatingCoolingMode"}
|
||||
String thermostat_target_mode "Thermostat Target Mode" (gThermostat) {homekit = "TargetHeatingCoolingMode"}
|
||||
Number thermostat_cool_thrs "Thermostat Cool Threshold Temp [%.1f C]" (gThermostat) {homekit = "CoolingThresholdTemperature"}
|
||||
Number thermostat_heat_thrs "Thermostat Heat Threshold Temp [%.1f C]" (gThermostat) {homekit = "HeatingThresholdTemperature"}
|
||||
```
|
||||
|
||||
#### Min / max temperatures
|
||||
|
||||
Current and target temperatures have default min and max values. Any values below or above max limits will be replaced with min or max limits.
|
||||
Default limits are:
|
||||
- current temperature: min value = 0 C, max value = 100 C
|
||||
- target temperature: min value = 10 C, max value = 38 C
|
||||
|
||||
You can overwrite default values using minValue and maxValue configuration at item level, e.g.
|
||||
|
||||
```xtend
|
||||
Number thermostat_current_temp "Thermostat Current Temp [%.1f C]" (gThermostat) {homekit = "CurrentTemperature" [minValue=5, maxValue=30]}
|
||||
Number thermostat_target_temp "Thermostat Target Temp[%.1f C]" (gThermostat) {homekit = "TargetTemperature" [minValue=10.5, maxValue=27]}
|
||||
```
|
||||
|
||||
#### Thermostat modes
|
||||
|
||||
HomeKit thermostat supports following modes
|
||||
|
||||
- CurrentHeatingCoolingMode: OFF, HEAT, COOL
|
||||
- TargetHeatingCoolingMode: OFF, HEAT, COOL, AUTO
|
||||
|
||||
These modes are mapped to string values of openHAB items using either global configuration (see [Global Configuration](#Global Configuration)) or configuration at item level.
|
||||
e.g. if your current mode item can have following values: "OFF", "HEATING", "COOLING" then you need following mapping at item level
|
||||
|
||||
```xtend
|
||||
String thermostat_current_mode "Thermostat Current Mode" (gThermostat) {homekit = "CurrentHeatingCoolingMode" [OFF="OFF", HEAT="HEATING", COOL="COOLING"]}
|
||||
```
|
||||
|
||||
You can provide mapping for target mode in similar way.
|
||||
|
||||
The custom mapping at item level can be also used to reduce number of modes shown in home app. The modes can be only reduced, but not added, i.e. it is not possible to add new custom mode to HomeKit thermostat.
|
||||
|
||||
Example: if your thermostat does not support cooling, then you need to limit mapping to OFF and HEAT values only:
|
||||
|
||||
```xtend
|
||||
String thermostat_current_mode "Thermostat Current Mode" (gThermostat) {homekit = "CurrentHeatingCoolingMode" [HEAT="HEATING", OFF="OFF"]}
|
||||
String thermostat_target_mode "Thermostat Target Mode" (gThermostat) {homekit = "TargetHeatingCoolingMode" [HEAT="HEATING", OFF="OFF"]}
|
||||
```
|
||||
|
||||
The mapping using main UI looks like following:
|
||||
|
||||
![mode_mapping.png](doc/mode_mapping.png)
|
||||
|
||||
### Valve
|
||||
|
||||
The HomeKit valve accessory supports following 2 optional characteristics:
|
||||
|
||||
- duration: this describes how long the valve should set "InUse" once it is activated. The duration changes will apply to the next operation. If valve is already active then duration changes have no effect.
|
||||
|
||||
- remaining duration: this describes the remaining duration on the valve. Notifications on this characteristic must only be used if the remaining duration increases/decreases from the accessoryʼs usual countdown of remaining duration.
|
||||
|
||||
Upon valve activation in home app, home app starts to count down from the "duration" to "0" without contacting the server. Home app also does not trigger any action if it remaining duration get 0.
|
||||
It is up to valve to have an own timer and stop valve once the timer is over.
|
||||
Some valves have such timer, e.g. pretty common for sprinklers.
|
||||
In case the valve has no timer capability, openHAB can take care on this - start an internal timer and send "Off" command to the valve once the timer is over.
|
||||
|
||||
configuration for these two cases looks as follow:
|
||||
|
||||
- valve with timer:
|
||||
|
||||
```xtend
|
||||
Group gValve "Valve Group" {homekit="Valve" [homekitValveType="Irrigation"]}
|
||||
Switch valve_active "Valve active" (gValve) {homekit = "Valve.ActiveStatus, Valve.InUseStatus"}
|
||||
Number valve_duration "Valve duration" (gValve) {homekit = "Valve.Duration"}
|
||||
Number valve_remaining_duration "Valve remaining duration" (gValve) {homekit = "Valve.RemainingDuration"}
|
||||
```
|
||||
|
||||
- valve without timer (no item for remaining duration required)
|
||||
|
||||
```xtend
|
||||
Group gValve "Valve Group" {homekit="Valve" [homekitValveType="Irrigation", homekitTimer="true]}
|
||||
Switch valve_active "Valve active" (gValve) {homekit = "Valve.ActiveStatus, Valve.InUseStatus"}
|
||||
Number valve_duration "Valve duration" (gValve) {homekit = "Valve.Duration" [homekitDefaultDuration = 1800]}
|
||||
```
|
||||
|
||||
### Sensors
|
||||
|
||||
Sensors have typically one mandatory characteristic, e.g. temperature or lead trigger, and several optional characteristics which are typically used for battery powered sensors and/or wireless sensors.
|
||||
Following table summarizes the optional characteristics supported by sensors.
|
||||
|
||||
| Characteristics | Supported openHAB items | Description |
|
||||
|:-----------------------------|:-------------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| Name | String | Name of the sensor. This characteristic is interesting only for very specific cases in which the name of accessory is dynamic. if you not sure then you don't need it. |
|
||||
| ActiveStatus | Switch, Contact | Accessory current working status. "ON"/"OPEN" indicates that the accessory is active and is functioning without any errors. |
|
||||
| FaultStatus | Switch, Contact | Accessory fault status. "ON"/"OPEN" value indicates that the accessory has experienced a fault that may be interfering with its intended functionality. A value of "OFF"/"CLOSED" indicates that there is no fault. |
|
||||
| TamperedStatus | Switch, Contact | Accessory tampered status. "ON"/"OPEN" indicates that the accessory has been tampered. Value should return to "OFF"/"CLOSED" when the accessory has been reset to a non-tampered state. |
|
||||
| BatteryLowStatus | Switch, Contact | Accessory battery status. "ON"/"OPEN" indicates that the battery level of the accessory is low. Value should return to "OFF"/"CLOSED" when the battery charges to a level thats above the low threshold. |
|
||||
|
||||
Examples of sensor definitions.
|
||||
Sensors without optional characteristics:
|
||||
|
||||
```xtend
|
||||
Switch leaksensor_single "Leak Sensor" {homekit="LeakSensor"}
|
||||
Number light_sensor "Light Sensor" {homekit="LightSensor"}
|
||||
Number temperature_sensor "Temperature Sensor [%.1f C]" {homekit="TemperatureSensor"}
|
||||
Contact contact_sensor "Contact Sensor" {homekit="ContactSensor"}
|
||||
Switch occupancy_sensor "Occupancy Sensor" {homekit="OccupancyDetectedState"}
|
||||
Switch motion_sensor "Motion Sensor" {homekit="MotionSensor"}
|
||||
Number humidity_sensor "Humidity Sensor" {homekit="HumiditySensor"}
|
||||
```
|
||||
|
||||
Sensors with optional characteristics:
|
||||
|
||||
```xtend
|
||||
Group gLeakSensor "Leak Sensor" {homekit="LeakSensor"}
|
||||
Switch leaksensor "Leak Sensor State" (gLeakSensor) {homekit="LeakDetectedState"}
|
||||
Switch leaksensor_bat "Leak Sensor Battery" (gLeakSensor) {homekit="BatteryLowStatus"}
|
||||
Switch leaksensor_active "Leak Sensor Active" (gLeakSensor) {homekit="ActiveStatus"}
|
||||
Switch leaksensor_fault "Leak Sensor Fault" (gLeakSensor) {homekit="FaultStatus"}
|
||||
Switch leaksensor_tampered "Leak Sensor Tampered" (gLeakSensor) {homekit="TamperedStatus"}
|
||||
|
||||
Group gMotionSensor "Motion Sensor" {homekit="MotionSensor"}
|
||||
Switch motionsensor "Motion Sensor State" (gMotionSensor) {homekit="MotionDetectedState"}
|
||||
Switch motionsensor_bat "Motion Sensor Battery" (gMotionSensor) {homekit="BatteryLowStatus"}
|
||||
Switch motionsensor_active "Motion Sensor Active" (gMotionSensor) {homekit="ActiveStatus"}
|
||||
Switch motionsensor_fault "Motion Sensor Fault" (gMotionSensor) {homekit="FaultStatus"}
|
||||
Switch motionsensor_tampered "Motion Sensor Tampered" (gMotionSensor) {homekit="TamperedStatus"}
|
||||
```
|
||||
|
||||
## Supported accessory type
|
||||
|
||||
| Accessory Tag | Mandatory Characteristics | Optional Characteristics | Supported OH items | Description |
|
||||
|
@ -461,163 +697,6 @@ Number cooler_cool_thrs "Cooler Cool Threshold Temp [%.1f C]" (gCo
|
|||
Number cooler_heat_thrs "Cooler Heat Threshold Temp [%.1f C]" (gCooler) {homekit="HeatingThresholdTemperature" [minValue=0.5, maxValue=20]}
|
||||
```
|
||||
|
||||
## Accessory Configuration Details
|
||||
|
||||
### Dimmers
|
||||
|
||||
The way HomeKit handles dimmer devices can be different to the actual dimmers' way of working.
|
||||
HomeKit home app sends following commands/update:
|
||||
|
||||
- On brightness change home app sends "ON" event along with target brightness, e.g. "Brightness = 50%" + "State = ON".
|
||||
- On "ON" event home app sends "ON" along with brightness 100%, i.e. "Brightness = 100%" + "State = ON"
|
||||
- On "OFF" event home app sends "OFF" without brightness information.
|
||||
|
||||
However, some dimmer devices for example do not expect brightness on "ON" event, some others do not expect "ON" upon brightness change.
|
||||
In order to support different devices HomeKit integration can filter some events. Which events should be filtered is defined via dimmerMode configuration.
|
||||
|
||||
```xtend
|
||||
Dimmer dimmer_light "Dimmer Light" {homekit="Lighting, Lighting.Brightness" [dimmerMode="<mode>"]}
|
||||
```
|
||||
|
||||
Following modes are supported:
|
||||
|
||||
- "normal" - no filtering. The commands will be sent to device as received from HomeKit. This is default mode.
|
||||
- "filterOn" - ON events are filtered out. only OFF events and brightness information are sent
|
||||
- "filterBrightness100" - only Brightness=100% is filtered out. everything else sent unchanged. This allows custom logic for soft launch in devices.
|
||||
- "filterOnExceptBrightness100" - ON events are filtered out in all cases except of brightness = 100%.
|
||||
|
||||
Examples:
|
||||
|
||||
```xtend
|
||||
Dimmer dimmer_light_1 "Dimmer Light 1" {homekit="Lighting, Lighting.Brightness" [dimmerMode="filterOn"]}
|
||||
Dimmer dimmer_light_2 "Dimmer Light 2" {homekit="Lighting, Lighting.Brightness" [dimmerMode="filterBrightness100"]}
|
||||
Dimmer dimmer_light_3 "Dimmer Light 3" {homekit="Lighting, Lighting.Brightness" [dimmerMode="filterOnExceptBrightness100"]}
|
||||
```
|
||||
|
||||
### Windows Covering (Blinds) / Window / Door
|
||||
|
||||
HomeKit Windows Covering, Window and Door accessory types have following mandatory characteristics:
|
||||
|
||||
- CurrentPosition (0-100% of current window covering position)
|
||||
- TargetPosition (0-100% of target position)
|
||||
- PositionState (DECREASING,INCREASING or STOPPED as state). If no state provided, HomeKit will send STOPPED
|
||||
|
||||
These characteristics can be mapped to a single openHAB rollershutter item. In such case currentPosition will always equal target position, means if you request to close a blind/window/door, HomeKit will immediately report that the blind/window/door is closed.
|
||||
As discussed above, one can use full or shorthand definition. Following two definitions are equal:
|
||||
|
||||
```xtend
|
||||
Rollershutter window "Window" {homekit = "Window"}
|
||||
Rollershutter door "Door" {homekit = "Door"}
|
||||
Rollershutter window_covering "Window Rollershutter" {homekit = "WindowCovering"}
|
||||
Rollershutter window_covering_long "Window Rollershutter long" {homekit = "WindowCovering, WindowCovering.CurrentPosition, WindowCovering.TargetPosition, WindowCovering.PositionState"}
|
||||
```
|
||||
|
||||
openHAB Rollershutter is defined by default as:
|
||||
|
||||
- OPEN if position is 0%,
|
||||
- CLOSED if position is 100%.
|
||||
|
||||
In contrast, HomeKit window covering/door/window have inverted mapping
|
||||
|
||||
- OPEN if position 100%
|
||||
- CLOSED if position is 0%
|
||||
|
||||
Therefore, HomeKit integration inverts by default the values between openHAB and HomeKit, e.g. if openHAB current position is 30% then it will send 70% to HomeKit app.
|
||||
In case you need to disable this logic you can do it with configuration parameter inverted="false", e.g.
|
||||
|
||||
```xtend
|
||||
Rollershutter window_covering "Window Rollershutter" {homekit = "WindowCovering" [inverted="false"]}
|
||||
Rollershutter window "Window" {homekit = "Window" [inverted="false"]}
|
||||
Rollershutter door "Door" {homekit = "Door" [inverted="false"]}
|
||||
|
||||
```
|
||||
|
||||
Window covering can have a number of optional characteristics like horizontal & vertical tilt, obstruction status and hold position trigger.
|
||||
If your blind supports tilt, and you want to control tilt via HomeKit you need to define blind as a group.
|
||||
e.g.
|
||||
|
||||
```xtend
|
||||
Group gBlind "Blind with tilt" {homekit = "WindowCovering"}
|
||||
Rollershutter window_covering "Blind" (gBlind) {homekit = "WindowCovering"}
|
||||
Dimmer window_covering_htilt "Blind horizontal tilt" (gBlind) {homekit = "WindowCovering.CurrentHorizontalTiltAngle, WindowCovering.TargetHorizontalTiltAngle"}
|
||||
Dimmer window_covering_vtilt "Blind vertical tilt" (gBlind) {homekit = "WindowCovering.CurrentVerticalTiltAngle, WindowCovering.TargetVerticalTiltAngle"}
|
||||
```
|
||||
|
||||
### Valve
|
||||
|
||||
The HomeKit valve accessory supports following 2 optional characteristics:
|
||||
|
||||
- duration: this describes how long the valve should set "InUse" once it is activated. The duration changes will apply to the next operation. If valve is already active then duration changes have no effect.
|
||||
|
||||
- remaining duration: this describes the remaining duration on the valve. Notifications on this characteristic must only be used if the remaining duration increases/decreases from the accessoryʼs usual countdown of remaining duration.
|
||||
|
||||
Upon valve activation in home app, home app starts to count down from the "duration" to "0" without contacting the server. Home app also does not trigger any action if it remaining duration get 0.
|
||||
It is up to valve to have an own timer and stop valve once the timer is over.
|
||||
Some valves have such timer, e.g. pretty common for sprinklers.
|
||||
In case the valve has no timer capability, openHAB can take care on this - start an internal timer and send "Off" command to the valve once the timer is over.
|
||||
|
||||
configuration for these two cases looks as follow:
|
||||
|
||||
- valve with timer:
|
||||
|
||||
```xtend
|
||||
Group gValve "Valve Group" {homekit="Valve" [homekitValveType="Irrigation"]}
|
||||
Switch valve_active "Valve active" (gValve) {homekit = "Valve.ActiveStatus, Valve.InUseStatus"}
|
||||
Number valve_duration "Valve duration" (gValve) {homekit = "Valve.Duration"}
|
||||
Number valve_remaining_duration "Valve remaining duration" (gValve) {homekit = "Valve.RemainingDuration"}
|
||||
```
|
||||
|
||||
- valve without timer (no item for remaining duration required)
|
||||
|
||||
```xtend
|
||||
Group gValve "Valve Group" {homekit="Valve" [homekitValveType="Irrigation", homekitTimer="true]}
|
||||
Switch valve_active "Valve active" (gValve) {homekit = "Valve.ActiveStatus, Valve.InUseStatus"}
|
||||
Number valve_duration "Valve duration" (gValve) {homekit = "Valve.Duration" [homekitDefaultDuration = 1800]}
|
||||
```
|
||||
|
||||
### Sensors
|
||||
|
||||
Sensors have typically one mandatory characteristic, e.g. temperature or lead trigger, and several optional characteristics which are typically used for battery powered sensors and/or wireless sensors.
|
||||
Following table summarizes the optional characteristics supported by sensors.
|
||||
|
||||
| Characteristics | Supported openHAB items | Description |
|
||||
|:-----------------------------|:-------------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| Name | String | Name of the sensor. This characteristic is interesting only for very specific cases in which the name of accessory is dynamic. if you not sure then you don't need it. |
|
||||
| ActiveStatus | Switch, Contact | Accessory current working status. "ON"/"OPEN" indicates that the accessory is active and is functioning without any errors. |
|
||||
| FaultStatus | Switch, Contact | Accessory fault status. "ON"/"OPEN" value indicates that the accessory has experienced a fault that may be interfering with its intended functionality. A value of "OFF"/"CLOSED" indicates that there is no fault. |
|
||||
| TamperedStatus | Switch, Contact | Accessory tampered status. "ON"/"OPEN" indicates that the accessory has been tampered. Value should return to "OFF"/"CLOSED" when the accessory has been reset to a non-tampered state. |
|
||||
| BatteryLowStatus | Switch, Contact | Accessory battery status. "ON"/"OPEN" indicates that the battery level of the accessory is low. Value should return to "OFF"/"CLOSED" when the battery charges to a level thats above the low threshold. |
|
||||
|
||||
Examples of sensor definitions.
|
||||
Sensors without optional characteristics:
|
||||
|
||||
```xtend
|
||||
Switch leaksensor_single "Leak Sensor" {homekit="LeakSensor"}
|
||||
Number light_sensor "Light Sensor" {homekit="LightSensor"}
|
||||
Number temperature_sensor "Temperature Sensor [%.1f C]" {homekit="TemperatureSensor"}
|
||||
Contact contact_sensor "Contact Sensor" {homekit="ContactSensor"}
|
||||
Switch occupancy_sensor "Occupancy Sensor" {homekit="OccupancyDetectedState"}
|
||||
Switch motion_sensor "Motion Sensor" {homekit="MotionSensor"}
|
||||
Number humidity_sensor "Humidity Sensor" {homekit="HumiditySensor"}
|
||||
```
|
||||
|
||||
Sensors with optional characteristics:
|
||||
|
||||
```xtend
|
||||
Group gLeakSensor "Leak Sensor" {homekit="LeakSensor"}
|
||||
Switch leaksensor "Leak Sensor State" (gLeakSensor) {homekit="LeakDetectedState"}
|
||||
Switch leaksensor_bat "Leak Sensor Battery" (gLeakSensor) {homekit="BatteryLowStatus"}
|
||||
Switch leaksensor_active "Leak Sensor Active" (gLeakSensor) {homekit="ActiveStatus"}
|
||||
Switch leaksensor_fault "Leak Sensor Fault" (gLeakSensor) {homekit="FaultStatus"}
|
||||
Switch leaksensor_tampered "Leak Sensor Tampered" (gLeakSensor) {homekit="TamperedStatus"}
|
||||
|
||||
Group gMotionSensor "Motion Sensor" {homekit="MotionSensor"}
|
||||
Switch motionsensor "Motion Sensor State" (gMotionSensor) {homekit="MotionDetectedState"}
|
||||
Switch motionsensor_bat "Motion Sensor Battery" (gMotionSensor) {homekit="BatteryLowStatus"}
|
||||
Switch motionsensor_active "Motion Sensor Active" (gMotionSensor) {homekit="ActiveStatus"}
|
||||
Switch motionsensor_fault "Motion Sensor Fault" (gMotionSensor) {homekit="FaultStatus"}
|
||||
Switch motionsensor_tampered "Motion Sensor Tampered" (gMotionSensor) {homekit="TamperedStatus"}
|
||||
```
|
||||
|
||||
## Common Problems
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 52 KiB |
|
@ -58,7 +58,10 @@ public class HomekitAuthInfoImpl implements HomekitAuthInfo {
|
|||
@Override
|
||||
public void createUser(String username, byte[] publicKey) {
|
||||
logger.trace("Create user {}", username);
|
||||
storage.put(createUserKey(username), Base64.getEncoder().encodeToString(publicKey));
|
||||
final String userKey = createUserKey(username);
|
||||
final String encodedPublicKey = Base64.getEncoder().encodeToString(publicKey);
|
||||
storage.put(userKey, encodedPublicKey);
|
||||
logger.trace("Stored user key {} with value {}", userKey, encodedPublicKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -218,20 +218,32 @@ abstract class AbstractHomekitAccessoryImpl implements HomekitAccessory {
|
|||
*
|
||||
* @param characteristicType characteristicType to identify item
|
||||
* @param map mapping to update
|
||||
* @param customEnumList list to store custom state enumeration
|
||||
*/
|
||||
@NonNullByDefault
|
||||
protected void updateMapping(HomekitCharacteristicType characteristicType, Map<?, String> map) {
|
||||
protected <T> void updateMapping(HomekitCharacteristicType characteristicType, Map<T, String> map,
|
||||
@Nullable List<T> customEnumList) {
|
||||
getCharacteristic(characteristicType).ifPresent(c -> {
|
||||
final Map<String, Object> configuration = c.getConfiguration();
|
||||
if (configuration != null) {
|
||||
map.replaceAll((k, current_value) -> {
|
||||
final Object new_value = configuration.get(current_value);
|
||||
return (new_value instanceof String) ? (String) new_value : current_value;
|
||||
map.forEach((k, current_value) -> {
|
||||
final Object new_value = configuration.get(k.toString());
|
||||
if (new_value instanceof String) {
|
||||
map.put(k, (String) new_value);
|
||||
if (customEnumList != null) {
|
||||
customEnumList.add(k);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NonNullByDefault
|
||||
protected <T> void updateMapping(HomekitCharacteristicType characteristicType, Map<T, String> map) {
|
||||
updateMapping(characteristicType, map, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* takes item state as value and retrieves the key for that value from mapping.
|
||||
* e.g. used to map StringItem value to HomeKit Enum
|
||||
|
|
|
@ -16,6 +16,7 @@ import static org.openhab.io.homekit.internal.HomekitCharacteristicType.ACTIVE_S
|
|||
import static org.openhab.io.homekit.internal.HomekitCharacteristicType.CURRENT_HEATER_COOLER_STATE;
|
||||
import static org.openhab.io.homekit.internal.HomekitCharacteristicType.TARGET_HEATER_COOLER_STATE;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -71,13 +72,16 @@ public class HomekitHeaterCoolerImpl extends AbstractHomekitAccessoryImpl implem
|
|||
}
|
||||
};
|
||||
|
||||
private final List<CurrentHeaterCoolerStateEnum> customCurrentStateList = new ArrayList<>();
|
||||
private final List<TargetHeaterCoolerStateEnum> customTargetStateList = new ArrayList<>();
|
||||
|
||||
public HomekitHeaterCoolerImpl(HomekitTaggedItem taggedItem, List<HomekitTaggedItem> mandatoryCharacteristics,
|
||||
HomekitAccessoryUpdater updater, HomekitSettings settings) throws IncompleteAccessoryException {
|
||||
super(taggedItem, mandatoryCharacteristics, updater, settings);
|
||||
activeReader = new BooleanItemReader(getItem(ACTIVE_STATUS, GenericItem.class)
|
||||
.orElseThrow(() -> new IncompleteAccessoryException(ACTIVE_STATUS)), OnOffType.ON, OpenClosedType.OPEN);
|
||||
updateMapping(CURRENT_HEATER_COOLER_STATE, currentStateMapping);
|
||||
updateMapping(TARGET_HEATER_COOLER_STATE, targetStateMapping);
|
||||
updateMapping(CURRENT_HEATER_COOLER_STATE, currentStateMapping, customCurrentStateList);
|
||||
updateMapping(TARGET_HEATER_COOLER_STATE, targetStateMapping, customTargetStateList);
|
||||
final HeaterCoolerService service = new HeaterCoolerService(this);
|
||||
service.addOptionalCharacteristic(new TemperatureDisplayUnitCharacteristic(this::getTemperatureDisplayUnit,
|
||||
this::setTemperatureDisplayUnit, this::subscribeTemperatureDisplayUnit,
|
||||
|
@ -85,6 +89,19 @@ public class HomekitHeaterCoolerImpl extends AbstractHomekitAccessoryImpl implem
|
|||
getServices().add(service);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CurrentHeaterCoolerStateEnum[] getCurrentHeaterCoolerStateValidValues() {
|
||||
return customCurrentStateList.isEmpty()
|
||||
? currentStateMapping.keySet().toArray(new CurrentHeaterCoolerStateEnum[0])
|
||||
: customCurrentStateList.toArray(new CurrentHeaterCoolerStateEnum[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetHeaterCoolerStateEnum[] getTargetHeaterCoolerStateValidValues() {
|
||||
return customTargetStateList.isEmpty() ? targetStateMapping.keySet().toArray(new TargetHeaterCoolerStateEnum[0])
|
||||
: customTargetStateList.toArray(new TargetHeaterCoolerStateEnum[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Double> getCurrentTemperature() {
|
||||
final @Nullable DecimalType state = getStateAs(HomekitCharacteristicType.CURRENT_TEMPERATURE,
|
||||
|
|
|
@ -15,6 +15,7 @@ package org.openhab.io.homekit.internal.accessories;
|
|||
import static org.openhab.io.homekit.internal.HomekitCharacteristicType.SECURITY_SYSTEM_CURRENT_STATE;
|
||||
import static org.openhab.io.homekit.internal.HomekitCharacteristicType.SECURITY_SYSTEM_TARGET_STATE;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -62,15 +63,33 @@ public class HomekitSecuritySystemImpl extends AbstractHomekitAccessoryImpl impl
|
|||
put(TargetSecuritySystemStateEnum.NIGHT_ARM, "NIGHT_ARM");
|
||||
}
|
||||
};
|
||||
private final List<CurrentSecuritySystemStateEnum> customCurrentStateList;
|
||||
private final List<TargetSecuritySystemStateEnum> customTargetStateList;
|
||||
|
||||
public HomekitSecuritySystemImpl(HomekitTaggedItem taggedItem, List<HomekitTaggedItem> mandatoryCharacteristics,
|
||||
HomekitAccessoryUpdater updater, HomekitSettings settings) {
|
||||
super(taggedItem, mandatoryCharacteristics, updater, settings);
|
||||
updateMapping(SECURITY_SYSTEM_CURRENT_STATE, currentStateMapping);
|
||||
updateMapping(SECURITY_SYSTEM_TARGET_STATE, targetStateMapping);
|
||||
customCurrentStateList = new ArrayList<>();
|
||||
customTargetStateList = new ArrayList<>();
|
||||
updateMapping(SECURITY_SYSTEM_CURRENT_STATE, currentStateMapping, customCurrentStateList);
|
||||
updateMapping(SECURITY_SYSTEM_TARGET_STATE, targetStateMapping, customTargetStateList);
|
||||
getServices().add(new SecuritySystemService(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CurrentSecuritySystemStateEnum[] getCurrentSecuritySystemStateValidValues() {
|
||||
return customCurrentStateList.isEmpty()
|
||||
? currentStateMapping.keySet().toArray(new CurrentSecuritySystemStateEnum[0])
|
||||
: customCurrentStateList.toArray(new CurrentSecuritySystemStateEnum[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetSecuritySystemStateEnum[] getTargetSecuritySystemStateValidValues() {
|
||||
return customTargetStateList.isEmpty()
|
||||
? targetStateMapping.keySet().toArray(new TargetSecuritySystemStateEnum[0])
|
||||
: customTargetStateList.toArray(new TargetSecuritySystemStateEnum[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<CurrentSecuritySystemStateEnum> getCurrentSecuritySystemState() {
|
||||
return CompletableFuture.completedFuture(getKeyFromMapping(SECURITY_SYSTEM_CURRENT_STATE, currentStateMapping,
|
||||
|
|
|
@ -12,8 +12,14 @@
|
|||
*/
|
||||
package org.openhab.io.homekit.internal.accessories;
|
||||
|
||||
import static org.openhab.io.homekit.internal.HomekitCharacteristicType.CURRENT_HEATING_COOLING_STATE;
|
||||
import static org.openhab.io.homekit.internal.HomekitCharacteristicType.TARGET_HEATING_COOLING_STATE;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
|
@ -49,43 +55,52 @@ import io.github.hapjava.services.impl.ThermostatService;
|
|||
*/
|
||||
class HomekitThermostatImpl extends AbstractHomekitAccessoryImpl implements ThermostatAccessory {
|
||||
private final Logger logger = LoggerFactory.getLogger(HomekitThermostatImpl.class);
|
||||
private final Map<CurrentHeatingCoolingStateEnum, String> currentHeatingCoolingStateMapping;
|
||||
private final Map<TargetHeatingCoolingStateEnum, String> targetHeatingCoolingStateMapping;
|
||||
private final List<CurrentHeatingCoolingStateEnum> customCurrentHeatingCoolingStateList;
|
||||
private final List<TargetHeatingCoolingStateEnum> customTargetHeatingCoolingStateList;
|
||||
|
||||
public HomekitThermostatImpl(HomekitTaggedItem taggedItem, List<HomekitTaggedItem> mandatoryCharacteristics,
|
||||
HomekitAccessoryUpdater updater, HomekitSettings settings) {
|
||||
super(taggedItem, mandatoryCharacteristics, updater, settings);
|
||||
currentHeatingCoolingStateMapping = new EnumMap<>(CurrentHeatingCoolingStateEnum.class);
|
||||
currentHeatingCoolingStateMapping.put(CurrentHeatingCoolingStateEnum.OFF, settings.thermostatCurrentModeOff);
|
||||
currentHeatingCoolingStateMapping.put(CurrentHeatingCoolingStateEnum.COOL,
|
||||
settings.thermostatCurrentModeCooling);
|
||||
currentHeatingCoolingStateMapping.put(CurrentHeatingCoolingStateEnum.HEAT,
|
||||
settings.thermostatCurrentModeHeating);
|
||||
targetHeatingCoolingStateMapping = new EnumMap<>(TargetHeatingCoolingStateEnum.class);
|
||||
targetHeatingCoolingStateMapping.put(TargetHeatingCoolingStateEnum.OFF, settings.thermostatTargetModeOff);
|
||||
targetHeatingCoolingStateMapping.put(TargetHeatingCoolingStateEnum.COOL, settings.thermostatTargetModeCool);
|
||||
targetHeatingCoolingStateMapping.put(TargetHeatingCoolingStateEnum.HEAT, settings.thermostatTargetModeHeat);
|
||||
targetHeatingCoolingStateMapping.put(TargetHeatingCoolingStateEnum.AUTO, settings.thermostatTargetModeAuto);
|
||||
customCurrentHeatingCoolingStateList = new ArrayList<>();
|
||||
customTargetHeatingCoolingStateList = new ArrayList<>();
|
||||
updateMapping(CURRENT_HEATING_COOLING_STATE, currentHeatingCoolingStateMapping,
|
||||
customCurrentHeatingCoolingStateList);
|
||||
updateMapping(TARGET_HEATING_COOLING_STATE, targetHeatingCoolingStateMapping,
|
||||
customTargetHeatingCoolingStateList);
|
||||
this.getServices().add(new ThermostatService(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CurrentHeatingCoolingStateEnum[] getCurrentHeatingCoolingStateValidValues() {
|
||||
return customCurrentHeatingCoolingStateList.isEmpty()
|
||||
? currentHeatingCoolingStateMapping.keySet().toArray(new CurrentHeatingCoolingStateEnum[0])
|
||||
: customCurrentHeatingCoolingStateList.toArray(new CurrentHeatingCoolingStateEnum[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetHeatingCoolingStateEnum[] getTargetHeatingCoolingStateValidValues() {
|
||||
return customTargetHeatingCoolingStateList.isEmpty()
|
||||
? targetHeatingCoolingStateMapping.keySet().toArray(new TargetHeatingCoolingStateEnum[0])
|
||||
: customTargetHeatingCoolingStateList.toArray(new TargetHeatingCoolingStateEnum[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<CurrentHeatingCoolingStateEnum> getCurrentState() {
|
||||
final HomekitSettings settings = getSettings();
|
||||
String stringValue = settings.thermostatCurrentModeOff;
|
||||
final Optional<HomekitTaggedItem> characteristic = getCharacteristic(
|
||||
HomekitCharacteristicType.CURRENT_HEATING_COOLING_STATE);
|
||||
if (characteristic.isPresent()) {
|
||||
stringValue = characteristic.get().getItem().getState().toString();
|
||||
} else {
|
||||
logger.warn("Missing mandatory characteristic {}", HomekitCharacteristicType.CURRENT_HEATING_COOLING_STATE);
|
||||
}
|
||||
|
||||
CurrentHeatingCoolingStateEnum mode;
|
||||
|
||||
if (stringValue.equalsIgnoreCase(settings.thermostatCurrentModeCooling)) {
|
||||
mode = CurrentHeatingCoolingStateEnum.COOL;
|
||||
} else if (stringValue.equalsIgnoreCase(settings.thermostatCurrentModeHeating)) {
|
||||
mode = CurrentHeatingCoolingStateEnum.HEAT;
|
||||
} else if (stringValue.equalsIgnoreCase(settings.thermostatCurrentModeOff)) {
|
||||
mode = CurrentHeatingCoolingStateEnum.OFF;
|
||||
} else if (stringValue.equals("UNDEF") || stringValue.equals("NULL")) {
|
||||
logger.warn("Heating cooling current mode not available. Relaying value of OFF to Homekit");
|
||||
mode = CurrentHeatingCoolingStateEnum.OFF;
|
||||
} else {
|
||||
logger.warn("Unrecognized heatingCoolingCurrentMode: {}. Expected {}, {}, or {} strings in value.",
|
||||
stringValue, settings.thermostatCurrentModeCooling, settings.thermostatCurrentModeHeating,
|
||||
settings.thermostatCurrentModeOff);
|
||||
mode = CurrentHeatingCoolingStateEnum.OFF;
|
||||
}
|
||||
return CompletableFuture.completedFuture(mode);
|
||||
return CompletableFuture.completedFuture(getKeyFromMapping(CURRENT_HEATING_COOLING_STATE,
|
||||
currentHeatingCoolingStateMapping, CurrentHeatingCoolingStateEnum.OFF));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -114,36 +129,8 @@ class HomekitThermostatImpl extends AbstractHomekitAccessoryImpl implements Ther
|
|||
|
||||
@Override
|
||||
public CompletableFuture<TargetHeatingCoolingStateEnum> getTargetState() {
|
||||
final HomekitSettings settings = getSettings();
|
||||
String stringValue = settings.thermostatTargetModeOff;
|
||||
|
||||
final Optional<HomekitTaggedItem> characteristic = getCharacteristic(
|
||||
HomekitCharacteristicType.TARGET_HEATING_COOLING_STATE);
|
||||
if (characteristic.isPresent()) {
|
||||
stringValue = characteristic.get().getItem().getState().toString();
|
||||
} else {
|
||||
logger.warn("Missing mandatory characteristic {}", HomekitCharacteristicType.TARGET_HEATING_COOLING_STATE);
|
||||
}
|
||||
TargetHeatingCoolingStateEnum mode;
|
||||
|
||||
if (stringValue.equalsIgnoreCase(settings.thermostatTargetModeCool)) {
|
||||
mode = TargetHeatingCoolingStateEnum.COOL;
|
||||
} else if (stringValue.equalsIgnoreCase(settings.thermostatTargetModeHeat)) {
|
||||
mode = TargetHeatingCoolingStateEnum.HEAT;
|
||||
} else if (stringValue.equalsIgnoreCase(settings.thermostatTargetModeAuto)) {
|
||||
mode = TargetHeatingCoolingStateEnum.AUTO;
|
||||
} else if (stringValue.equalsIgnoreCase(settings.thermostatTargetModeOff)) {
|
||||
mode = TargetHeatingCoolingStateEnum.OFF;
|
||||
} else if (stringValue.equals("UNDEF") || stringValue.equals("NULL")) {
|
||||
logger.warn("Heating cooling target mode not available. Relaying value of OFF to Homekit");
|
||||
mode = TargetHeatingCoolingStateEnum.OFF;
|
||||
} else {
|
||||
logger.warn("Unrecognized heating cooling target mode: {}. Expected {}, {}, {}, or {} strings in value.",
|
||||
stringValue, settings.thermostatTargetModeCool, settings.thermostatTargetModeHeat,
|
||||
settings.thermostatTargetModeAuto, settings.thermostatTargetModeOff);
|
||||
mode = TargetHeatingCoolingStateEnum.OFF;
|
||||
}
|
||||
return CompletableFuture.completedFuture(mode);
|
||||
return CompletableFuture.completedFuture(getKeyFromMapping(TARGET_HEATING_COOLING_STATE,
|
||||
targetHeatingCoolingStateMapping, TargetHeatingCoolingStateEnum.OFF));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -166,32 +153,8 @@ class HomekitThermostatImpl extends AbstractHomekitAccessoryImpl implements Ther
|
|||
|
||||
@Override
|
||||
public void setTargetState(TargetHeatingCoolingStateEnum mode) {
|
||||
final HomekitSettings settings = getSettings();
|
||||
String modeString = null;
|
||||
switch (mode) {
|
||||
case AUTO:
|
||||
modeString = settings.thermostatTargetModeAuto;
|
||||
break;
|
||||
|
||||
case COOL:
|
||||
modeString = settings.thermostatTargetModeCool;
|
||||
break;
|
||||
|
||||
case HEAT:
|
||||
modeString = settings.thermostatTargetModeHeat;
|
||||
break;
|
||||
|
||||
case OFF:
|
||||
modeString = settings.thermostatTargetModeOff;
|
||||
break;
|
||||
}
|
||||
final Optional<HomekitTaggedItem> characteristic = getCharacteristic(
|
||||
HomekitCharacteristicType.TARGET_HEATING_COOLING_STATE);
|
||||
if (characteristic.isPresent()) {
|
||||
((StringItem) characteristic.get().getItem()).send(new StringType(modeString));
|
||||
} else {
|
||||
logger.warn("Missing mandatory characteristic {}", HomekitCharacteristicType.TARGET_HEATING_COOLING_STATE);
|
||||
}
|
||||
getItem(TARGET_HEATING_COOLING_STATE, StringItem.class)
|
||||
.ifPresent(item -> item.send(new StringType(targetHeatingCoolingStateMapping.get(mode))));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -226,7 +189,7 @@ class HomekitThermostatImpl extends AbstractHomekitAccessoryImpl implements Ther
|
|||
|
||||
@Override
|
||||
public void subscribeCurrentState(HomekitCharacteristicChangeCallback callback) {
|
||||
subscribe(HomekitCharacteristicType.CURRENT_HEATING_COOLING_STATE, callback);
|
||||
subscribe(CURRENT_HEATING_COOLING_STATE, callback);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -251,7 +214,7 @@ class HomekitThermostatImpl extends AbstractHomekitAccessoryImpl implements Ther
|
|||
|
||||
@Override
|
||||
public void unsubscribeCurrentState() {
|
||||
unsubscribe(HomekitCharacteristicType.CURRENT_HEATING_COOLING_STATE);
|
||||
unsubscribe(CURRENT_HEATING_COOLING_STATE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue