1 """Support for Schluter thermostats."""
3 from __future__
import annotations
8 from requests
import RequestException
9 import voluptuous
as vol
12 PLATFORM_SCHEMA
as CLIMATE_PLATFORM_SCHEMA,
25 DataUpdateCoordinator,
29 from .
import DATA_SCHLUTER_API, DATA_SCHLUTER_SESSION, DOMAIN
31 _LOGGER = logging.getLogger(__name__)
32 PLATFORM_SCHEMA = CLIMATE_PLATFORM_SCHEMA.extend(
33 {vol.Optional(CONF_SCAN_INTERVAL): vol.All(vol.Coerce(int), vol.Range(min=1))}
40 async_add_entities: AddEntitiesCallback,
41 discovery_info: DiscoveryInfoType |
None =
None,
43 """Set up the Schluter thermostats."""
44 if discovery_info
is None:
46 session_id = hass.data[DOMAIN][DATA_SCHLUTER_SESSION]
47 api = hass.data[DOMAIN][DATA_SCHLUTER_API]
49 async
def async_update_data():
51 thermostats = await hass.async_add_executor_job(
52 api.get_thermostats, session_id
54 except RequestException
as err:
55 raise UpdateFailed(f
"Error communicating with Schluter API: {err}")
from err
57 if thermostats
is None:
60 return {thermo.serial_number: thermo
for thermo
in thermostats}
66 update_method=async_update_data,
67 update_interval=SCAN_INTERVAL,
70 await coordinator.async_refresh()
74 for serial_number, thermostat
in coordinator.data.items()
79 """Representation of a Schluter thermostat."""
81 _attr_hvac_mode = HVACMode.HEAT
82 _attr_hvac_modes = [HVACMode.HEAT]
83 _attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE
84 _attr_temperature_unit = UnitOfTemperature.CELSIUS
85 _enable_turn_on_off_backwards_compatibility =
False
87 def __init__(self, coordinator, serial_number, api, session_id):
88 """Initialize the thermostat."""
96 """Return unique ID for this device."""
101 """Return the name of the thermostat."""
102 return self.coordinator.data[self.
_serial_number_serial_number].name
106 """Return the current temperature."""
107 return self.coordinator.data[self.
_serial_number_serial_number].temperature
111 """Return current operation. Can only be heating or idle."""
112 if self.coordinator.data[self.
_serial_number_serial_number].is_heating:
113 return HVACAction.HEATING
114 return HVACAction.IDLE
118 """Return the temperature we try to reach."""
119 return self.coordinator.data[self.
_serial_number_serial_number].set_point_temp
123 """Identify min_temp in Schluter API."""
124 return self.coordinator.data[self.
_serial_number_serial_number].min_temp
128 """Identify max_temp in Schluter API."""
129 return self.coordinator.data[self.
_serial_number_serial_number].max_temp
132 """Mode is always heating, so do nothing."""
135 """Set new target temperature."""
137 target_temp = kwargs.get(ATTR_TEMPERATURE)
138 serial_number = self.coordinator.data[self.
_serial_number_serial_number].serial_number
139 _LOGGER.debug(
"Setting thermostat temperature: %s", target_temp)
142 if target_temp
is not None:
144 except RequestException
as ex:
145 _LOGGER.error(
"An error occurred while setting temperature: %s", ex)
HVACAction hvac_action(self)
None async_set_hvac_mode(self, HVACMode hvac_mode)
def __init__(self, coordinator, serial_number, api, session_id)
def current_temperature(self)
def target_temperature(self)
None set_temperature(self, **Any kwargs)
None async_setup_platform(HomeAssistant hass, ConfigType config, AddEntitiesCallback async_add_entities, DiscoveryInfoType|None discovery_info=None)