mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 23:27:37 +00:00
Use climate enums in geniushub (#70653)
This commit is contained in:
parent
2676f4df7a
commit
587505c85b
@ -1,15 +1,13 @@
|
|||||||
"""Support for Genius Hub climate devices."""
|
"""Support for Genius Hub climate devices."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from homeassistant.components.climate import ClimateEntity, ClimateEntityFeature
|
from homeassistant.components.climate import ClimateEntity
|
||||||
from homeassistant.components.climate.const import (
|
from homeassistant.components.climate.const import (
|
||||||
CURRENT_HVAC_HEAT,
|
|
||||||
CURRENT_HVAC_IDLE,
|
|
||||||
CURRENT_HVAC_OFF,
|
|
||||||
HVAC_MODE_HEAT,
|
|
||||||
HVAC_MODE_OFF,
|
|
||||||
PRESET_ACTIVITY,
|
PRESET_ACTIVITY,
|
||||||
PRESET_BOOST,
|
PRESET_BOOST,
|
||||||
|
ClimateEntityFeature,
|
||||||
|
HVACAction,
|
||||||
|
HVACMode,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
@ -18,7 +16,7 @@ from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
|||||||
from . import DOMAIN, GeniusHeatingZone
|
from . import DOMAIN, GeniusHeatingZone
|
||||||
|
|
||||||
# GeniusHub Zones support: Off, Timer, Override/Boost, Footprint & Linked modes
|
# 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()}
|
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"}
|
HA_PRESET_TO_GH = {PRESET_ACTIVITY: "footprint", PRESET_BOOST: "override"}
|
||||||
@ -70,7 +68,7 @@ class GeniusClimateZone(GeniusHeatingZone, ClimateEntity):
|
|||||||
@property
|
@property
|
||||||
def hvac_mode(self) -> str:
|
def hvac_mode(self) -> str:
|
||||||
"""Return hvac operation ie. heat, cool mode."""
|
"""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
|
@property
|
||||||
def hvac_modes(self) -> list[str]:
|
def hvac_modes(self) -> list[str]:
|
||||||
@ -82,10 +80,10 @@ class GeniusClimateZone(GeniusHeatingZone, ClimateEntity):
|
|||||||
"""Return the current running hvac operation if supported."""
|
"""Return the current running hvac operation if supported."""
|
||||||
if "_state" in self._zone.data: # only for v3 API
|
if "_state" in self._zone.data: # only for v3 API
|
||||||
if not self._zone.data["_state"].get("bIsActive"):
|
if not self._zone.data["_state"].get("bIsActive"):
|
||||||
return CURRENT_HVAC_OFF
|
return HVACAction.OFF
|
||||||
if self._zone.data["_state"].get("bOutRequestHeat"):
|
if self._zone.data["_state"].get("bOutRequestHeat"):
|
||||||
return CURRENT_HVAC_HEAT
|
return HVACAction.HEATING
|
||||||
return CURRENT_HVAC_IDLE
|
return HVACAction.IDLE
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -100,7 +98,9 @@ class GeniusClimateZone(GeniusHeatingZone, ClimateEntity):
|
|||||||
return [PRESET_ACTIVITY, PRESET_BOOST]
|
return [PRESET_ACTIVITY, PRESET_BOOST]
|
||||||
return [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."""
|
"""Set a new hvac mode."""
|
||||||
await self._zone.set_mode(HA_HVAC_TO_GH.get(hvac_mode))
|
await self._zone.set_mode(HA_HVAC_TO_GH.get(hvac_mode))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user