From c1163283ffb57381a6d8d64cd620c4e256e09e0d Mon Sep 17 00:00:00 2001 From: SukramJ Date: Tue, 26 Nov 2019 19:02:30 +0100 Subject: [PATCH] Add hvac_action to HomematicIP Cloud Climate (#28859) * Add hvac_action to HomematicIP Cloud Climate * update test data * limit hvac action to radiator only * add checks * Fix test to match new conditions --- .../components/homematicip_cloud/climate.py | 20 +++++++++++++++++++ .../homematicip_cloud/test_climate.py | 14 +++++++++++++ 2 files changed, 34 insertions(+) diff --git a/homeassistant/components/homematicip_cloud/climate.py b/homeassistant/components/homematicip_cloud/climate.py index 6cc556d5ff2..e3c922dc577 100644 --- a/homeassistant/components/homematicip_cloud/climate.py +++ b/homeassistant/components/homematicip_cloud/climate.py @@ -10,6 +10,8 @@ from homematicip.functionalHomes import IndoorClimateHome from homeassistant.components.climate import ClimateDevice from homeassistant.components.climate.const import ( + CURRENT_HVAC_HEAT, + CURRENT_HVAC_IDLE, HVAC_MODE_AUTO, HVAC_MODE_COOL, HVAC_MODE_HEAT, @@ -140,6 +142,24 @@ class HomematicipHeatingGroup(HomematicipGenericDevice, ClimateDevice): else [HVAC_MODE_AUTO, HVAC_MODE_COOL] ) + @property + def hvac_action(self) -> Optional[str]: + """ + Return the current hvac_action. + + This is only relevant for radiator thermostats. + """ + if ( + self._device.floorHeatingMode == "RADIATOR" + and self._has_radiator_thermostat + and self._heat_mode_enabled + ): + return ( + CURRENT_HVAC_HEAT if self._device.valvePosition else CURRENT_HVAC_IDLE + ) + + return None + @property def preset_mode(self) -> Optional[str]: """Return the current preset mode.""" diff --git a/tests/components/homematicip_cloud/test_climate.py b/tests/components/homematicip_cloud/test_climate.py index d40a77751e8..db052929474 100644 --- a/tests/components/homematicip_cloud/test_climate.py +++ b/tests/components/homematicip_cloud/test_climate.py @@ -7,8 +7,11 @@ from homematicip.functionalHomes import IndoorClimateHome from homeassistant.components.climate import DOMAIN as CLIMATE_DOMAIN from homeassistant.components.climate.const import ( ATTR_CURRENT_TEMPERATURE, + ATTR_HVAC_ACTION, ATTR_PRESET_MODE, ATTR_PRESET_MODES, + CURRENT_HVAC_HEAT, + CURRENT_HVAC_IDLE, HVAC_MODE_AUTO, HVAC_MODE_COOL, HVAC_MODE_HEAT, @@ -215,6 +218,17 @@ async def test_hmip_heating_group_heat(hass, default_mock_hap): # Only fire event from last async_manipulate_test_data available. assert hmip_device.mock_calls[-1][0] == "fire_update_event" + await async_manipulate_test_data(hass, hmip_device, "floorHeatingMode", "RADIATOR") + await async_manipulate_test_data(hass, hmip_device, "valvePosition", 0.1) + ha_state = hass.states.get(entity_id) + assert ha_state.state == HVAC_MODE_AUTO + assert ha_state.attributes[ATTR_HVAC_ACTION] == CURRENT_HVAC_HEAT + await async_manipulate_test_data(hass, hmip_device, "floorHeatingMode", "RADIATOR") + await async_manipulate_test_data(hass, hmip_device, "valvePosition", 0.0) + ha_state = hass.states.get(entity_id) + assert ha_state.state == HVAC_MODE_AUTO + assert ha_state.attributes[ATTR_HVAC_ACTION] == CURRENT_HVAC_IDLE + async def test_hmip_heating_group_cool(hass, default_mock_hap): """Test HomematicipHeatingGroup."""