Use climate enums in senz (#70735)

This commit is contained in:
epenet 2022-04-26 09:15:26 +02:00 committed by GitHub
parent a3938deb24
commit b69b3be4b0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -6,11 +6,7 @@ from typing import Any
from aiosenz import MODE_AUTO, Thermostat from aiosenz import MODE_AUTO, Thermostat
from homeassistant.components.climate import ClimateEntity from homeassistant.components.climate import ClimateEntity
from homeassistant.components.climate.const import ( from homeassistant.components.climate.const import ClimateEntityFeature, HVACMode
HVAC_MODE_AUTO,
HVAC_MODE_HEAT,
ClimateEntityFeature,
)
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_TEMPERATURE, PRECISION_TENTHS, TEMP_CELSIUS from homeassistant.const import ATTR_TEMPERATURE, PRECISION_TENTHS, TEMP_CELSIUS
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
@ -39,7 +35,7 @@ class SENZClimate(CoordinatorEntity, ClimateEntity):
_attr_temperature_unit = TEMP_CELSIUS _attr_temperature_unit = TEMP_CELSIUS
_attr_precision = PRECISION_TENTHS _attr_precision = PRECISION_TENTHS
_attr_hvac_modes = [HVAC_MODE_HEAT, HVAC_MODE_AUTO] _attr_hvac_modes = [HVACMode.HEAT, HVACMode.AUTO]
_attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE _attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE
_attr_max_temp = 35 _attr_max_temp = 35
_attr_min_temp = 5 _attr_min_temp = 5
@ -83,15 +79,15 @@ class SENZClimate(CoordinatorEntity, ClimateEntity):
return self._thermostat.online return self._thermostat.online
@property @property
def hvac_mode(self) -> str: def hvac_mode(self) -> HVACMode:
"""Return hvac operation ie. auto, heat mode.""" """Return hvac operation ie. auto, heat mode."""
if self._thermostat.mode == MODE_AUTO: if self._thermostat.mode == MODE_AUTO:
return HVAC_MODE_AUTO return HVACMode.AUTO
return HVAC_MODE_HEAT return HVACMode.HEAT
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."""
if hvac_mode == HVAC_MODE_AUTO: if hvac_mode == HVACMode.AUTO:
await self._thermostat.auto() await self._thermostat.auto()
else: else:
await self._thermostat.manual() await self._thermostat.manual()