mirror of
https://github.com/home-assistant/core.git
synced 2025-04-26 18:27:51 +00:00
Use climate enums in overkiz (#70731)
This commit is contained in:
parent
c4eeeb9674
commit
ae5ec1a320
@ -5,26 +5,23 @@ from typing import cast
|
|||||||
|
|
||||||
from pyoverkiz.enums import OverkizCommand, OverkizCommandParam, OverkizState
|
from pyoverkiz.enums import OverkizCommand, OverkizCommandParam, OverkizState
|
||||||
|
|
||||||
from homeassistant.components.climate import (
|
from homeassistant.components.climate import ClimateEntity
|
||||||
HVAC_MODE_OFF,
|
|
||||||
ClimateEntity,
|
|
||||||
ClimateEntityFeature,
|
|
||||||
)
|
|
||||||
from homeassistant.components.climate.const import (
|
from homeassistant.components.climate.const import (
|
||||||
HVAC_MODE_HEAT,
|
|
||||||
PRESET_COMFORT,
|
PRESET_COMFORT,
|
||||||
PRESET_ECO,
|
PRESET_ECO,
|
||||||
PRESET_NONE,
|
PRESET_NONE,
|
||||||
|
ClimateEntityFeature,
|
||||||
|
HVACMode,
|
||||||
)
|
)
|
||||||
from homeassistant.components.overkiz.entity import OverkizEntity
|
from homeassistant.components.overkiz.entity import OverkizEntity
|
||||||
from homeassistant.const import TEMP_CELSIUS
|
from homeassistant.const import TEMP_CELSIUS
|
||||||
|
|
||||||
PRESET_FROST_PROTECTION = "frost_protection"
|
PRESET_FROST_PROTECTION = "frost_protection"
|
||||||
|
|
||||||
OVERKIZ_TO_HVAC_MODES: dict[str, str] = {
|
OVERKIZ_TO_HVAC_MODES: dict[str, HVACMode] = {
|
||||||
OverkizCommandParam.ON: HVAC_MODE_HEAT,
|
OverkizCommandParam.ON: HVACMode.HEAT,
|
||||||
OverkizCommandParam.COMFORT: HVAC_MODE_HEAT,
|
OverkizCommandParam.COMFORT: HVACMode.HEAT,
|
||||||
OverkizCommandParam.OFF: HVAC_MODE_OFF,
|
OverkizCommandParam.OFF: HVACMode.OFF,
|
||||||
}
|
}
|
||||||
HVAC_MODES_TO_OVERKIZ = {v: k for k, v in OVERKIZ_TO_HVAC_MODES.items()}
|
HVAC_MODES_TO_OVERKIZ = {v: k for k, v in OVERKIZ_TO_HVAC_MODES.items()}
|
||||||
|
|
||||||
@ -47,13 +44,13 @@ class AtlanticElectricalHeater(OverkizEntity, ClimateEntity):
|
|||||||
_attr_temperature_unit = TEMP_CELSIUS
|
_attr_temperature_unit = TEMP_CELSIUS
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def hvac_mode(self) -> str:
|
def hvac_mode(self) -> HVACMode:
|
||||||
"""Return hvac operation ie. heat, cool mode."""
|
"""Return hvac operation ie. heat, cool mode."""
|
||||||
return OVERKIZ_TO_HVAC_MODES[
|
return OVERKIZ_TO_HVAC_MODES[
|
||||||
cast(str, self.executor.select_state(OverkizState.CORE_ON_OFF))
|
cast(str, self.executor.select_state(OverkizState.CORE_ON_OFF))
|
||||||
]
|
]
|
||||||
|
|
||||||
async def async_set_hvac_mode(self, hvac_mode: str) -> None:
|
async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
|
||||||
"""Set new target hvac mode."""
|
"""Set new target hvac mode."""
|
||||||
await self.executor.async_execute_command(
|
await self.executor.async_execute_command(
|
||||||
OverkizCommand.SET_HEATING_LEVEL, HVAC_MODES_TO_OVERKIZ[hvac_mode]
|
OverkizCommand.SET_HEATING_LEVEL, HVAC_MODES_TO_OVERKIZ[hvac_mode]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user