Use new Mill api (#97497)

* Mill, new api. Wip

Signed-off-by: Daniel Hjelseth Høyer <github@dahoiv.net>

* Mill, new api. Wip

Signed-off-by: Daniel Hjelseth Høyer <github@dahoiv.net>

* Mill, new api. Wip

Signed-off-by: Daniel Hjelseth Høyer <github@dahoiv.net>

* Mill, new api. Wip

Signed-off-by: Daniel Hjelseth Høyer <github@dahoiv.net>

* Mill, new api. Wip

Signed-off-by: Daniel Hjelseth Høyer <github@dahoiv.net>

* Mill, new api. Wip

Signed-off-by: Daniel Hjelseth Høyer <github@dahoiv.net>

* Mill, new api. Wip

Signed-off-by: Daniel Hjelseth Høyer <github@dahoiv.net>

* Mill, new api. Wip

Signed-off-by: Daniel Hjelseth Høyer <github@dahoiv.net>

* Mill, new api. Wip

Signed-off-by: Daniel Hjelseth Høyer <github@dahoiv.net>

* Mill, new api. Wip

Signed-off-by: Daniel Hjelseth Høyer <github@dahoiv.net>

* Mill, new api. Wip

Signed-off-by: Daniel Hjelseth Høyer <github@dahoiv.net>

* Mill, new api. Wip

Signed-off-by: Daniel Hjelseth Høyer <github@dahoiv.net>

* Mill, new api. Wip

Signed-off-by: Daniel Hjelseth Høyer <github@dahoiv.net>

* Mill, new api. Wip

Signed-off-by: Daniel Hjelseth Høyer <github@dahoiv.net>

* Mill, new api. Wip

Signed-off-by: Daniel Hjelseth Høyer <github@dahoiv.net>

* Mill, new api. Wip

Signed-off-by: Daniel Hjelseth Høyer <github@dahoiv.net>

* Mill, new api. Wip

Signed-off-by: Daniel Hjelseth Høyer <github@dahoiv.net>

* Mill, new api

Signed-off-by: Daniel Hjelseth Høyer <github@dahoiv.net>

* Mill, new api

Signed-off-by: Daniel Hjelseth Høyer <github@dahoiv.net>

* Mill, new api

Signed-off-by: Daniel Hjelseth Høyer <github@dahoiv.net>

* Update homeassistant/components/mill/sensor.py

Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>

* Update homeassistant/components/mill/sensor.py

Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>

* Mill, new api

Signed-off-by: Daniel Hjelseth Høyer <github@dahoiv.net>

* Update homeassistant/components/mill/climate.py

Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>

* Update homeassistant/components/mill/climate.py

Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>

---------

Signed-off-by: Daniel Hjelseth Høyer <github@dahoiv.net>
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
This commit is contained in:
Daniel Hjelseth Høyer 2023-08-05 22:46:03 +02:00 committed by GitHub
parent c7b7ca8769
commit 41c684f36e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 47 deletions

View File

@ -5,8 +5,6 @@ import mill
import voluptuous as vol
from homeassistant.components.climate import (
FAN_OFF,
FAN_ON,
ClimateEntity,
ClimateEntityFeature,
HVACAction,
@ -18,7 +16,7 @@ from homeassistant.const import (
CONF_IP_ADDRESS,
CONF_USERNAME,
PRECISION_HALVES,
PRECISION_WHOLE,
PRECISION_TENTHS,
UnitOfTemperature,
)
from homeassistant.core import HomeAssistant, ServiceCall, callback
@ -90,11 +88,13 @@ async def async_setup_entry(
class MillHeater(CoordinatorEntity[MillDataUpdateCoordinator], ClimateEntity):
"""Representation of a Mill Thermostat device."""
_attr_fan_modes = [FAN_ON, FAN_OFF]
_attr_has_entity_name = True
_attr_hvac_modes = [HVACMode.HEAT, HVACMode.OFF]
_attr_max_temp = MAX_TEMP
_attr_min_temp = MIN_TEMP
_attr_name = None
_attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE
_attr_target_temperature_step = PRECISION_TENTHS
_attr_temperature_unit = UnitOfTemperature.CELSIUS
def __init__(
@ -111,22 +111,9 @@ class MillHeater(CoordinatorEntity[MillDataUpdateCoordinator], ClimateEntity):
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, heater.device_id)},
manufacturer=MANUFACTURER,
model=f"Generation {heater.generation}",
model=heater.model,
name=heater.name,
)
if heater.is_gen1:
self._attr_hvac_modes = [HVACMode.HEAT]
else:
self._attr_hvac_modes = [HVACMode.HEAT, HVACMode.OFF]
if heater.generation < 3:
self._attr_supported_features = (
ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.FAN_MODE
)
self._attr_target_temperature_step = PRECISION_WHOLE
else:
self._attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE
self._attr_target_temperature_step = PRECISION_HALVES
self._update_attr(heater)
@ -139,26 +126,16 @@ class MillHeater(CoordinatorEntity[MillDataUpdateCoordinator], ClimateEntity):
)
await self.coordinator.async_request_refresh()
async def async_set_fan_mode(self, fan_mode: str) -> None:
"""Set new target fan mode."""
fan_status = 1 if fan_mode == FAN_ON else 0
await self.coordinator.mill_data_connection.heater_control(
self._id, fan_status=fan_status
)
await self.coordinator.async_request_refresh()
async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
"""Set new target hvac mode."""
heater = self.coordinator.data[self._id]
if hvac_mode == HVACMode.HEAT:
await self.coordinator.mill_data_connection.heater_control(
self._id, power_status=1
self._id, power_status=True
)
await self.coordinator.async_request_refresh()
elif hvac_mode == HVACMode.OFF and not heater.is_gen1:
elif hvac_mode == HVACMode.OFF:
await self.coordinator.mill_data_connection.heater_control(
self._id, power_status=0
self._id, power_status=False
)
await self.coordinator.async_request_refresh()
@ -178,23 +155,20 @@ class MillHeater(CoordinatorEntity[MillDataUpdateCoordinator], ClimateEntity):
self._available = heater.available
self._attr_extra_state_attributes = {
"open_window": heater.open_window,
"heating": heater.is_heating,
"controlled_by_tibber": heater.tibber_control,
"heater_generation": heater.generation,
}
if heater.room:
self._attr_extra_state_attributes["room"] = heater.room.name
self._attr_extra_state_attributes["avg_room_temp"] = heater.room.avg_temp
if heater.room_name:
self._attr_extra_state_attributes["room"] = heater.room_name
self._attr_extra_state_attributes["avg_room_temp"] = heater.room_avg_temp
else:
self._attr_extra_state_attributes["room"] = "Independent device"
self._attr_target_temperature = heater.set_temp
self._attr_current_temperature = heater.current_temp
self._attr_fan_mode = FAN_ON if heater.fan_status == 1 else HVACMode.OFF
if heater.is_heating == 1:
if heater.is_heating:
self._attr_hvac_action = HVACAction.HEATING
else:
self._attr_hvac_action = HVACAction.IDLE
if heater.is_gen1 or heater.power_status == 1:
if heater.power_status:
self._attr_hvac_mode = HVACMode.HEAT
else:
self._attr_hvac_mode = HVACMode.OFF

View File

@ -6,5 +6,5 @@
"documentation": "https://www.home-assistant.io/integrations/mill",
"iot_class": "local_polling",
"loggers": ["mill", "mill_local"],
"requirements": ["millheater==0.10.0", "mill-local==0.2.0"]
"requirements": ["millheater==0.11.0", "mill-local==0.2.0"]
}

View File

@ -172,13 +172,10 @@ class MillSensor(CoordinatorEntity, SensorEntity):
self._attr_unique_id = f"{mill_device.device_id}_{entity_description.key}"
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, mill_device.device_id)},
name=self.name,
name=mill_device.name,
manufacturer=MANUFACTURER,
model=mill_device.model,
)
if isinstance(mill_device, mill.Heater):
self._attr_device_info["model"] = f"Generation {mill_device.generation}"
elif isinstance(mill_device, mill.Sensor):
self._attr_device_info["model"] = "Mill Sense Air"
self._update_attr(mill_device)
@callback

View File

@ -1207,7 +1207,7 @@ micloud==0.5
mill-local==0.2.0
# homeassistant.components.mill
millheater==0.10.0
millheater==0.11.0
# homeassistant.components.minio
minio==7.1.12

View File

@ -924,7 +924,7 @@ micloud==0.5
mill-local==0.2.0
# homeassistant.components.mill
millheater==0.10.0
millheater==0.11.0
# homeassistant.components.minio
minio==7.1.12