Use climate enums in schluter (#70733)

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

View file

@ -11,12 +11,11 @@ from homeassistant.components.climate import (
SCAN_INTERVAL, SCAN_INTERVAL,
TEMP_CELSIUS, TEMP_CELSIUS,
ClimateEntity, ClimateEntity,
ClimateEntityFeature,
) )
from homeassistant.components.climate.const import ( from homeassistant.components.climate.const import (
CURRENT_HVAC_HEAT, ClimateEntityFeature,
CURRENT_HVAC_IDLE, HVACAction,
HVAC_MODE_HEAT, HVACMode,
) )
from homeassistant.const import ATTR_TEMPERATURE, CONF_SCAN_INTERVAL from homeassistant.const import ATTR_TEMPERATURE, CONF_SCAN_INTERVAL
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -80,6 +79,8 @@ async def async_setup_platform(
class SchluterThermostat(CoordinatorEntity, ClimateEntity): class SchluterThermostat(CoordinatorEntity, ClimateEntity):
"""Representation of a Schluter thermostat.""" """Representation of a Schluter thermostat."""
_attr_hvac_mode = HVACMode.HEAT
_attr_hvac_modes = [HVACMode.HEAT]
_attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE _attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE
def __init__(self, coordinator, serial_number, api, session_id): def __init__(self, coordinator, serial_number, api, session_id):
@ -110,29 +111,17 @@ class SchluterThermostat(CoordinatorEntity, ClimateEntity):
return self.coordinator.data[self._serial_number].temperature return self.coordinator.data[self._serial_number].temperature
@property @property
def hvac_mode(self): def hvac_action(self) -> HVACAction:
"""Return current mode. Only heat available for floor thermostat."""
return HVAC_MODE_HEAT
@property
def hvac_action(self):
"""Return current operation. Can only be heating or idle.""" """Return current operation. Can only be heating or idle."""
return ( if self.coordinator.data[self._serial_number].is_heating:
CURRENT_HVAC_HEAT return HVACAction.HEATING
if self.coordinator.data[self._serial_number].is_heating return HVACAction.IDLE
else CURRENT_HVAC_IDLE
)
@property @property
def target_temperature(self): def target_temperature(self):
"""Return the temperature we try to reach.""" """Return the temperature we try to reach."""
return self.coordinator.data[self._serial_number].set_point_temp return self.coordinator.data[self._serial_number].set_point_temp
@property
def hvac_modes(self):
"""List of available operation modes."""
return [HVAC_MODE_HEAT]
@property @property
def min_temp(self): def min_temp(self):
"""Identify min_temp in Schluter API.""" """Identify min_temp in Schluter API."""
@ -143,7 +132,7 @@ class SchluterThermostat(CoordinatorEntity, ClimateEntity):
"""Identify max_temp in Schluter API.""" """Identify max_temp in Schluter API."""
return self.coordinator.data[self._serial_number].max_temp return self.coordinator.data[self._serial_number].max_temp
async def async_set_hvac_mode(self, hvac_mode): async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
"""Mode is always heating, so do nothing.""" """Mode is always heating, so do nothing."""
def set_temperature(self, **kwargs): def set_temperature(self, **kwargs):