1 """Support for mill wifi-enabled home heaters."""
6 from mill_local
import OperationMode
7 import voluptuous
as vol
41 SERVICE_SET_ROOM_TEMP,
43 from .coordinator
import MillDataUpdateCoordinator
45 SET_ROOM_TEMP_SCHEMA = vol.Schema(
47 vol.Required(ATTR_ROOM_NAME): cv.string,
48 vol.Optional(ATTR_AWAY_TEMP): cv.positive_int,
49 vol.Optional(ATTR_COMFORT_TEMP): cv.positive_int,
50 vol.Optional(ATTR_SLEEP_TEMP): cv.positive_int,
56 hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
58 """Set up the Mill climate."""
59 if entry.data.get(CONNECTION_TYPE) == LOCAL:
60 mill_data_coordinator = hass.data[DOMAIN][LOCAL][entry.data[CONF_IP_ADDRESS]]
64 mill_data_coordinator = hass.data[DOMAIN][CLOUD][entry.data[CONF_USERNAME]]
68 for mill_device
in mill_data_coordinator.data.values()
69 if isinstance(mill_device, mill.Heater)
73 async
def set_room_temp(service: ServiceCall) ->
None:
75 room_name = service.data.get(ATTR_ROOM_NAME)
76 sleep_temp = service.data.get(ATTR_SLEEP_TEMP)
77 comfort_temp = service.data.get(ATTR_COMFORT_TEMP)
78 away_temp = service.data.get(ATTR_AWAY_TEMP)
79 await mill_data_coordinator.mill_data_connection.set_room_temperatures_by_name(
80 room_name, sleep_temp, comfort_temp, away_temp
83 hass.services.async_register(
84 DOMAIN, SERVICE_SET_ROOM_TEMP, set_room_temp, schema=SET_ROOM_TEMP_SCHEMA
89 """Representation of a Mill Thermostat device."""
91 _attr_has_entity_name =
True
92 _attr_hvac_modes = [HVACMode.HEAT, HVACMode.OFF]
93 _attr_max_temp = MAX_TEMP
94 _attr_min_temp = MIN_TEMP
96 _attr_supported_features = (
97 ClimateEntityFeature.TARGET_TEMPERATURE
98 | ClimateEntityFeature.TURN_OFF
99 | ClimateEntityFeature.TURN_ON
101 _attr_target_temperature_step = PRECISION_TENTHS
102 _attr_temperature_unit = UnitOfTemperature.CELSIUS
103 _enable_turn_on_off_backwards_compatibility =
False
106 self, coordinator: MillDataUpdateCoordinator, heater: mill.Heater
108 """Initialize the thermostat."""
114 self.
_id_id = heater.device_id
117 identifiers={(DOMAIN, heater.device_id)},
118 manufacturer=MANUFACTURER,
126 """Set new target temperature."""
127 if (temperature := kwargs.get(ATTR_TEMPERATURE))
is None:
129 await self.coordinator.mill_data_connection.set_heater_temp(
135 """Set new target hvac mode."""
136 if hvac_mode == HVACMode.HEAT:
137 await self.coordinator.mill_data_connection.heater_control(
138 self.
_id_id, power_status=
True
141 elif hvac_mode == HVACMode.OFF:
142 await self.coordinator.mill_data_connection.heater_control(
143 self.
_id_id, power_status=
False
149 """Return True if entity is available."""
150 return super().available
and self.
_available_available
154 """Handle updated data from the coordinator."""
162 "open_window": heater.open_window,
163 "controlled_by_tibber": heater.tibber_control,
172 if heater.is_heating:
176 if heater.power_status:
183 """Representation of a Mill Thermostat device."""
185 _attr_has_entity_name =
True
186 _attr_hvac_modes = [HVACMode.HEAT, HVACMode.OFF]
187 _attr_max_temp = MAX_TEMP
188 _attr_min_temp = MIN_TEMP
190 _attr_supported_features = (
191 ClimateEntityFeature.TARGET_TEMPERATURE
192 | ClimateEntityFeature.TURN_OFF
193 | ClimateEntityFeature.TURN_ON
195 _attr_target_temperature_step = PRECISION_TENTHS
196 _attr_temperature_unit = UnitOfTemperature.CELSIUS
197 _enable_turn_on_off_backwards_compatibility =
False
199 def __init__(self, coordinator: MillDataUpdateCoordinator) ->
None:
200 """Initialize the thermostat."""
202 if mac := coordinator.mill_data_connection.mac_address:
205 connections={(CONNECTION_NETWORK_MAC, mac)},
206 configuration_url=self.coordinator.mill_data_connection.url,
207 manufacturer=MANUFACTURER,
208 model=
"Generation 3",
209 name=coordinator.mill_data_connection.name,
210 sw_version=coordinator.mill_data_connection.version,
216 """Set new target temperature."""
217 if (temperature := kwargs.get(ATTR_TEMPERATURE))
is None:
219 await self.coordinator.mill_data_connection.set_target_temperature(
225 """Set new target hvac mode."""
226 if hvac_mode == HVACMode.HEAT:
227 await self.coordinator.mill_data_connection.set_operation_mode_control_individually()
229 elif hvac_mode == HVACMode.OFF:
230 await self.coordinator.mill_data_connection.set_operation_mode_off()
235 """Handle updated data from the coordinator."""
241 data = self.coordinator.data
245 if data[
"operation_mode"] == OperationMode.OFF.value:
250 if data[
"current_power"] > 0:
None __init__(self, MillDataUpdateCoordinator coordinator)
None _handle_coordinator_update(self)
_attr_current_temperature
None async_set_temperature(self, **Any kwargs)
None async_set_hvac_mode(self, HVACMode hvac_mode)
_attr_extra_state_attributes
_attr_current_temperature
def _update_attr(self, heater)
None async_set_temperature(self, **Any kwargs)
None __init__(self, MillDataUpdateCoordinator coordinator, mill.Heater heater)
None _handle_coordinator_update(self)
None async_set_hvac_mode(self, HVACMode hvac_mode)
None async_write_ha_state(self)
None async_request_refresh(self)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)