From 736b2709cbfed4a9c5bda26e07445fd64be338c8 Mon Sep 17 00:00:00 2001 From: Kristof Marien Date: Tue, 13 Feb 2024 08:03:01 +0100 Subject: [PATCH 1/3] Add HVAC action --- custom_components/mypyllant/climate.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/custom_components/mypyllant/climate.py b/custom_components/mypyllant/climate.py index 98d1f15..5151de9 100644 --- a/custom_components/mypyllant/climate.py +++ b/custom_components/mypyllant/climate.py @@ -100,6 +100,11 @@ for v in VentilationFanStageType ] +HVAC_ACTION_MAP = { + str(CircuitState.STANDBY): HVACAction.IDLE, + str(CircuitState.HEATING): HVACAction.HEATING, + str(CircuitState.COOLING): HVACAction.COOLING, +} async def async_setup_entry( hass: HomeAssistant, config: ConfigEntry, async_add_entities: AddEntitiesCallback @@ -437,6 +442,14 @@ async def async_set_hvac_mode(self, hvac_mode): ) await self.coordinator.async_request_refresh_delayed() + @property + def hvac_action(self) -> HVACAction | None: + states = list(set(map(lambda x: x["circuit_state"], self.system.state["circuits"]))) + + if len(states) == 1 and states[0] in HVAC_ACTION_MAP: + return HVAC_ACTION_MAP[states[0]] + return None + async def async_set_temperature(self, **kwargs: Any) -> None: """ Set new target temperature. Depending on heating mode this sets the manual mode setpoint, From 999dfe2a02675dfd4eb79e3b91650ef8beb0d973 Mon Sep 17 00:00:00 2001 From: Philipp Date: Wed, 14 Feb 2024 19:27:31 +0100 Subject: [PATCH 2/3] Added HVAC action & test case --- custom_components/mypyllant/climate.py | 20 ++++++++++---------- tests/test_climate.py | 2 ++ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/custom_components/mypyllant/climate.py b/custom_components/mypyllant/climate.py index b454062..2b96da2 100644 --- a/custom_components/mypyllant/climate.py +++ b/custom_components/mypyllant/climate.py @@ -10,6 +10,7 @@ ClimateEntity, ClimateEntityFeature, HVACMode, + HVACAction, ) from homeassistant.components.climate.const import ( FAN_AUTO, @@ -47,6 +48,7 @@ ZoneCurrentSpecialFunction, VentilationOperationMode, VentilationFanStageType, + CircuitState, ) from custom_components.mypyllant.utils import shorten_zone_name, EntityList @@ -95,6 +97,12 @@ PRESET_SLEEP: ZoneCurrentSpecialFunction.SYSTEM_OFF, } +ZONE_HVAC_ACTION_MAP = { + CircuitState.STANDBY: HVACAction.IDLE, + CircuitState.HEATING: HVACAction.HEATING, + CircuitState.COOLING: HVACAction.COOLING, +} + VENTILATION_HVAC_MODE_MAP = { HVACMode.FAN_ONLY: VentilationOperationMode.NORMAL, HVACMode.AUTO: VentilationOperationMode.TIME_CONTROLLED, @@ -112,11 +120,6 @@ for v in VentilationFanStageType ] -HVAC_ACTION_MAP = { - str(CircuitState.STANDBY): HVACAction.IDLE, - str(CircuitState.HEATING): HVACAction.HEATING, - str(CircuitState.COOLING): HVACAction.COOLING, -} async def async_setup_entry( hass: HomeAssistant, config: ConfigEntry, async_add_entities: AddEntitiesCallback @@ -504,11 +507,8 @@ async def set_zone_operating_mode( @property def hvac_action(self) -> HVACAction | None: - states = list(set(map(lambda x: x["circuit_state"], self.system.state["circuits"]))) - - if len(states) == 1 and states[0] in HVAC_ACTION_MAP: - return HVAC_ACTION_MAP[states[0]] - return None + circuit_state = self.zone.get_associated_circuit(self.system).circuit_state + return ZONE_HVAC_ACTION_MAP.get(circuit_state) async def async_set_temperature(self, **kwargs: Any) -> None: """ diff --git a/tests/test_climate.py b/tests/test_climate.py index d37d973..2db1bb0 100644 --- a/tests/test_climate.py +++ b/tests/test_climate.py @@ -15,6 +15,7 @@ VentilationClimate, ZoneClimate, async_setup_entry, + ZONE_HVAC_ACTION_MAP, ) from tests.utils import get_config_entry from tests.conftest import MockConfigEntry, TEST_OPTIONS @@ -96,6 +97,7 @@ async def test_zone_climate( assert isinstance(climate.preset_modes, list) assert climate.hvac_mode in climate.hvac_modes assert climate.preset_mode in climate.preset_modes + assert climate.hvac_action in ZONE_HVAC_ACTION_MAP.values() await mocked_api.aiohttp_session.close() From eacac75e26c7fe8fa3830b5f8c2a66bfda969941 Mon Sep 17 00:00:00 2001 From: Philipp Date: Wed, 14 Feb 2024 19:29:36 +0100 Subject: [PATCH 3/3] Updated base library --- custom_components/mypyllant/manifest.json | 2 +- dev-requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/custom_components/mypyllant/manifest.json b/custom_components/mypyllant/manifest.json index 6e2027a..30fc0c2 100644 --- a/custom_components/mypyllant/manifest.json +++ b/custom_components/mypyllant/manifest.json @@ -10,7 +10,7 @@ "iot_class": "cloud_polling", "issue_tracker": "https://github.com/signalkraft/mypyllant-component/issues", "requirements": [ - "myPyllant==0.7.14" + "myPyllant==0.7.15" ], "version": "v0.7.3" } diff --git a/dev-requirements.txt b/dev-requirements.txt index cb7db43..15ba48e 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -15,5 +15,5 @@ types-PyYAML~=6.0.12.12 pytest==7.4.3 pytest-cov==4.1.0 pytest-homeassistant-custom-component==0.13.77 -myPyllant==0.7.14 +myPyllant==0.7.15 dacite~=1.7.0 \ No newline at end of file