Skip to content
Snippets Groups Projects
Unverified Commit de317fb2 authored by J. Nick Koston's avatar J. Nick Koston Committed by GitHub
Browse files

Map dry and fan only states for homekit thermostats (#33682)

Homekit only has Off/Heat/Cool/Auto at this time, but
at least we can prevent the device from erroring
by mapping dry and fan to cool so it continues
to function.
parent f3801156
No related branches found
No related tags found
No related merge requests found
......@@ -16,6 +16,8 @@ from homeassistant.components.climate.const import (
ATTR_TARGET_TEMP_HIGH,
ATTR_TARGET_TEMP_LOW,
CURRENT_HVAC_COOL,
CURRENT_HVAC_DRY,
CURRENT_HVAC_FAN,
CURRENT_HVAC_HEAT,
CURRENT_HVAC_IDLE,
CURRENT_HVAC_OFF,
......@@ -91,6 +93,8 @@ HC_HASS_TO_HOMEKIT_ACTION = {
CURRENT_HVAC_IDLE: 0,
CURRENT_HVAC_HEAT: 1,
CURRENT_HVAC_COOL: 2,
CURRENT_HVAC_DRY: 2,
CURRENT_HVAC_FAN: 2,
}
......@@ -382,6 +386,7 @@ class Thermostat(HomeAccessory):
# Set current operation mode for supported thermostats
hvac_action = new_state.attributes.get(ATTR_HVAC_ACTION)
if hvac_action:
self.char_current_heat_cool.set_value(
HC_HASS_TO_HOMEKIT_ACTION[hvac_action]
)
......
......@@ -17,6 +17,8 @@ from homeassistant.components.climate.const import (
ATTR_TARGET_TEMP_LOW,
ATTR_TARGET_TEMP_STEP,
CURRENT_HVAC_COOL,
CURRENT_HVAC_DRY,
CURRENT_HVAC_FAN,
CURRENT_HVAC_HEAT,
CURRENT_HVAC_IDLE,
DEFAULT_MAX_TEMP,
......@@ -25,6 +27,7 @@ from homeassistant.components.climate.const import (
DOMAIN as DOMAIN_CLIMATE,
HVAC_MODE_AUTO,
HVAC_MODE_COOL,
HVAC_MODE_DRY,
HVAC_MODE_FAN_ONLY,
HVAC_MODE_HEAT,
HVAC_MODE_HEAT_COOL,
......@@ -233,6 +236,38 @@ async def test_thermostat(hass, hk_driver, cls, events):
assert acc.char_current_temp.value == 22.0
assert acc.char_display_units.value == 0
hass.states.async_set(
entity_id,
HVAC_MODE_FAN_ONLY,
{
ATTR_TEMPERATURE: 22.0,
ATTR_CURRENT_TEMPERATURE: 22.0,
ATTR_HVAC_ACTION: CURRENT_HVAC_FAN,
},
)
await hass.async_block_till_done()
assert acc.char_target_temp.value == 22.0
assert acc.char_current_heat_cool.value == 2
assert acc.char_target_heat_cool.value == 2
assert acc.char_current_temp.value == 22.0
assert acc.char_display_units.value == 0
hass.states.async_set(
entity_id,
HVAC_MODE_DRY,
{
ATTR_TEMPERATURE: 22.0,
ATTR_CURRENT_TEMPERATURE: 22.0,
ATTR_HVAC_ACTION: CURRENT_HVAC_DRY,
},
)
await hass.async_block_till_done()
assert acc.char_target_temp.value == 22.0
assert acc.char_current_heat_cool.value == 2
assert acc.char_target_heat_cool.value == 2
assert acc.char_current_temp.value == 22.0
assert acc.char_display_units.value == 0
# Set from HomeKit
call_set_temperature = async_mock_service(hass, DOMAIN_CLIMATE, "set_temperature")
call_set_hvac_mode = async_mock_service(hass, DOMAIN_CLIMATE, "set_hvac_mode")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment