From 587505c85bc82fb41335cb26a7e801ee03ff8104 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Mon, 25 Apr 2022 10:46:52 +0200 Subject: [PATCH] Use climate enums in geniushub (#70653) --- homeassistant/components/geniushub/climate.py | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/homeassistant/components/geniushub/climate.py b/homeassistant/components/geniushub/climate.py index e82e90788d2..e4f2ec6d535 100644 --- a/homeassistant/components/geniushub/climate.py +++ b/homeassistant/components/geniushub/climate.py @@ -1,15 +1,13 @@ """Support for Genius Hub climate devices.""" from __future__ import annotations -from homeassistant.components.climate import ClimateEntity, ClimateEntityFeature +from homeassistant.components.climate import ClimateEntity from homeassistant.components.climate.const import ( - CURRENT_HVAC_HEAT, - CURRENT_HVAC_IDLE, - CURRENT_HVAC_OFF, - HVAC_MODE_HEAT, - HVAC_MODE_OFF, PRESET_ACTIVITY, PRESET_BOOST, + ClimateEntityFeature, + HVACAction, + HVACMode, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -18,7 +16,7 @@ from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType from . import DOMAIN, GeniusHeatingZone # GeniusHub Zones support: Off, Timer, Override/Boost, Footprint & Linked modes -HA_HVAC_TO_GH = {HVAC_MODE_OFF: "off", HVAC_MODE_HEAT: "timer"} +HA_HVAC_TO_GH = {HVACMode.OFF: "off", HVACMode.HEAT: "timer"} GH_HVAC_TO_HA = {v: k for k, v in HA_HVAC_TO_GH.items()} HA_PRESET_TO_GH = {PRESET_ACTIVITY: "footprint", PRESET_BOOST: "override"} @@ -70,7 +68,7 @@ class GeniusClimateZone(GeniusHeatingZone, ClimateEntity): @property def hvac_mode(self) -> str: """Return hvac operation ie. heat, cool mode.""" - return GH_HVAC_TO_HA.get(self._zone.data["mode"], HVAC_MODE_HEAT) + return GH_HVAC_TO_HA.get(self._zone.data["mode"], HVACMode.HEAT) @property def hvac_modes(self) -> list[str]: @@ -82,10 +80,10 @@ class GeniusClimateZone(GeniusHeatingZone, ClimateEntity): """Return the current running hvac operation if supported.""" if "_state" in self._zone.data: # only for v3 API if not self._zone.data["_state"].get("bIsActive"): - return CURRENT_HVAC_OFF + return HVACAction.OFF if self._zone.data["_state"].get("bOutRequestHeat"): - return CURRENT_HVAC_HEAT - return CURRENT_HVAC_IDLE + return HVACAction.HEATING + return HVACAction.IDLE return None @property @@ -100,7 +98,9 @@ class GeniusClimateZone(GeniusHeatingZone, ClimateEntity): return [PRESET_ACTIVITY, PRESET_BOOST] return [PRESET_BOOST] - async def async_set_hvac_mode(self, hvac_mode: str) -> None: + async def async_set_hvac_mode( # type:ignore[override] + self, hvac_mode: HVACMode + ) -> None: """Set a new hvac mode.""" await self._zone.set_mode(HA_HVAC_TO_GH.get(hvac_mode))