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,
TEMP_CELSIUS,
ClimateEntity,
ClimateEntityFeature,
)
from homeassistant.components.climate.const import (
CURRENT_HVAC_HEAT,
CURRENT_HVAC_IDLE,
HVAC_MODE_HEAT,
ClimateEntityFeature,
HVACAction,
HVACMode,
)
from homeassistant.const import ATTR_TEMPERATURE, CONF_SCAN_INTERVAL
from homeassistant.core import HomeAssistant
@ -80,6 +79,8 @@ async def async_setup_platform(
class SchluterThermostat(CoordinatorEntity, ClimateEntity):
"""Representation of a Schluter thermostat."""
_attr_hvac_mode = HVACMode.HEAT
_attr_hvac_modes = [HVACMode.HEAT]
_attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE
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
@property
def hvac_mode(self):
"""Return current mode. Only heat available for floor thermostat."""
return HVAC_MODE_HEAT
@property
def hvac_action(self):
def hvac_action(self) -> HVACAction:
"""Return current operation. Can only be heating or idle."""
return (
CURRENT_HVAC_HEAT
if self.coordinator.data[self._serial_number].is_heating
else CURRENT_HVAC_IDLE
)
if self.coordinator.data[self._serial_number].is_heating:
return HVACAction.HEATING
return HVACAction.IDLE
@property
def target_temperature(self):
"""Return the temperature we try to reach."""
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
def min_temp(self):
"""Identify min_temp in Schluter API."""
@ -143,7 +132,7 @@ class SchluterThermostat(CoordinatorEntity, ClimateEntity):
"""Identify max_temp in Schluter API."""
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."""
def set_temperature(self, **kwargs):