From 93fe77de8d29459fa56bd76fd222072fd088a2f1 Mon Sep 17 00:00:00 2001 From: Nyro Date: Wed, 21 Dec 2022 16:05:27 +0100 Subject: [PATCH] Add external handling in Overkiz AtlanticElectricalHeaterWithAdjustableTemperatureSetPoint (#84010) * Add external handling in AtlanticElectricalHeaterWithAdjustableTemperatureSetpoint * Improve comparing to external Co-authored-by: Thibaut * Update to pyoverkiz 1.7.3 * Fix coding style lint * Use OverkizCommand * Fix small issues Co-authored-by: Thibaut --- ...ter_with_adjustable_temperature_setpoint.py | 18 ++++++++++++++++-- homeassistant/components/overkiz/manifest.json | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/overkiz/climate_entities/atlantic_electrical_heater_with_adjustable_temperature_setpoint.py b/homeassistant/components/overkiz/climate_entities/atlantic_electrical_heater_with_adjustable_temperature_setpoint.py index a3a2be171c7..3b02523ec20 100644 --- a/homeassistant/components/overkiz/climate_entities/atlantic_electrical_heater_with_adjustable_temperature_setpoint.py +++ b/homeassistant/components/overkiz/climate_entities/atlantic_electrical_heater_with_adjustable_temperature_setpoint.py @@ -24,6 +24,7 @@ PRESET_COMFORT1 = "comfort-1" PRESET_COMFORT2 = "comfort-2" PRESET_FROST_PROTECTION = "frost_protection" PRESET_PROG = "prog" +PRESET_EXTERNAL = "external" # Map Overkiz presets to Home Assistant presets @@ -36,6 +37,7 @@ OVERKIZ_TO_PRESET_MODE: dict[str, str] = { OverkizCommandParam.COMFORT_2: PRESET_COMFORT2, OverkizCommandParam.AUTO: PRESET_AUTO, OverkizCommandParam.BOOST: PRESET_BOOST, + OverkizCommandParam.EXTERNAL: PRESET_EXTERNAL, OverkizCommandParam.INTERNAL: PRESET_PROG, } @@ -48,6 +50,7 @@ OVERKIZ_TO_HVAC_MODE: dict[str, str] = { OverkizCommandParam.AUTO: HVACMode.AUTO, OverkizCommandParam.BASIC: HVACMode.HEAT, OverkizCommandParam.STANDBY: HVACMode.OFF, + OverkizCommandParam.EXTERNAL: HVACMode.AUTO, OverkizCommandParam.INTERNAL: HVACMode.AUTO, } @@ -96,15 +99,26 @@ class AtlanticElectricalHeaterWithAdjustableTemperatureSetpoint( @property def preset_mode(self) -> str | None: """Return the current preset mode, e.g., home, away, temp.""" + + states = self.device.states + if ( - state := self.device.states[OverkizState.IO_TARGET_HEATING_LEVEL] + operating_mode := states[OverkizState.CORE_OPERATING_MODE] + ) and operating_mode.value_as_str == OverkizCommandParam.EXTERNAL: + return PRESET_EXTERNAL + + if ( + state := states[OverkizState.IO_TARGET_HEATING_LEVEL] ) and state.value_as_str: return OVERKIZ_TO_PRESET_MODE[state.value_as_str] return None async def async_set_preset_mode(self, preset_mode: str) -> None: """Set new preset mode.""" - if preset_mode in [PRESET_AUTO, PRESET_PROG]: + + if preset_mode == PRESET_EXTERNAL: + command = OverkizCommand.SET_SCHEDULING_TYPE + elif preset_mode in [PRESET_AUTO, PRESET_PROG]: command = OverkizCommand.SET_OPERATING_MODE else: command = OverkizCommand.SET_HEATING_LEVEL diff --git a/homeassistant/components/overkiz/manifest.json b/homeassistant/components/overkiz/manifest.json index eb1eee8a7b5..c5d272b0489 100644 --- a/homeassistant/components/overkiz/manifest.json +++ b/homeassistant/components/overkiz/manifest.json @@ -4,7 +4,7 @@ "config_flow": true, "integration_type": "hub", "documentation": "https://www.home-assistant.io/integrations/overkiz", - "requirements": ["pyoverkiz==1.7.2"], + "requirements": ["pyoverkiz==1.7.3"], "zeroconf": [ { "type": "_kizbox._tcp.local.", diff --git a/requirements_all.txt b/requirements_all.txt index ddef4bc8ae2..aa4a77c72bf 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1820,7 +1820,7 @@ pyotgw==2.1.3 pyotp==2.8.0 # homeassistant.components.overkiz -pyoverkiz==1.7.2 +pyoverkiz==1.7.3 # homeassistant.components.openweathermap pyowm==3.2.0 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 33df1afdc77..7d04cef4976 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -1297,7 +1297,7 @@ pyotgw==2.1.3 pyotp==2.8.0 # homeassistant.components.overkiz -pyoverkiz==1.7.2 +pyoverkiz==1.7.3 # homeassistant.components.openweathermap pyowm==3.2.0