diff --git a/homeassistant/components/homekit/type_thermostats.py b/homeassistant/components/homekit/type_thermostats.py index b8c3b3f0197..57b381fa416 100644 --- a/homeassistant/components/homekit/type_thermostats.py +++ b/homeassistant/components/homekit/type_thermostats.py @@ -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] ) diff --git a/tests/components/homekit/test_type_thermostats.py b/tests/components/homekit/test_type_thermostats.py index 756b20456fe..9533c30017f 100644 --- a/tests/components/homekit/test_type_thermostats.py +++ b/tests/components/homekit/test_type_thermostats.py @@ -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")