Turn off Mill heaters using local API (#99348)
* Update mill_local * Add ability to turn heater on and off * Use OperationMode from upstream library * Fix: compare against value
This commit is contained in:
parent
169a318ec4
commit
1e6cddaa1d
4 changed files with 22 additions and 8 deletions
|
@ -2,6 +2,7 @@
|
|||
from typing import Any
|
||||
|
||||
import mill
|
||||
from mill_local import OperationMode
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.climate import (
|
||||
|
@ -176,8 +177,7 @@ class LocalMillHeater(CoordinatorEntity[MillDataUpdateCoordinator], ClimateEntit
|
|||
"""Representation of a Mill Thermostat device."""
|
||||
|
||||
_attr_has_entity_name = True
|
||||
_attr_hvac_mode = HVACMode.HEAT
|
||||
_attr_hvac_modes = [HVACMode.HEAT]
|
||||
_attr_hvac_modes = [HVACMode.HEAT, HVACMode.OFF]
|
||||
_attr_max_temp = MAX_TEMP
|
||||
_attr_min_temp = MIN_TEMP
|
||||
_attr_name = None
|
||||
|
@ -210,6 +210,15 @@ class LocalMillHeater(CoordinatorEntity[MillDataUpdateCoordinator], ClimateEntit
|
|||
)
|
||||
await self.coordinator.async_request_refresh()
|
||||
|
||||
async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
|
||||
"""Set new target hvac mode."""
|
||||
if hvac_mode == HVACMode.HEAT:
|
||||
await self.coordinator.mill_data_connection.set_operation_mode_control_individually()
|
||||
await self.coordinator.async_request_refresh()
|
||||
elif hvac_mode == HVACMode.OFF:
|
||||
await self.coordinator.mill_data_connection.set_operation_mode_off()
|
||||
await self.coordinator.async_request_refresh()
|
||||
|
||||
@callback
|
||||
def _handle_coordinator_update(self) -> None:
|
||||
"""Handle updated data from the coordinator."""
|
||||
|
@ -222,7 +231,12 @@ class LocalMillHeater(CoordinatorEntity[MillDataUpdateCoordinator], ClimateEntit
|
|||
self._attr_target_temperature = data["set_temperature"]
|
||||
self._attr_current_temperature = data["ambient_temperature"]
|
||||
|
||||
if data["current_power"] > 0:
|
||||
self._attr_hvac_action = HVACAction.HEATING
|
||||
if data["operation_mode"] == OperationMode.OFF.value:
|
||||
self._attr_hvac_mode = HVACMode.OFF
|
||||
self._attr_hvac_action = HVACAction.OFF
|
||||
else:
|
||||
self._attr_hvac_action = HVACAction.IDLE
|
||||
self._attr_hvac_mode = HVACMode.HEAT
|
||||
if data["current_power"] > 0:
|
||||
self._attr_hvac_action = HVACAction.HEATING
|
||||
else:
|
||||
self._attr_hvac_action = HVACAction.IDLE
|
||||
|
|
|
@ -6,5 +6,5 @@
|
|||
"documentation": "https://www.home-assistant.io/integrations/mill",
|
||||
"iot_class": "local_polling",
|
||||
"loggers": ["mill", "mill_local"],
|
||||
"requirements": ["millheater==0.11.1", "mill-local==0.2.0"]
|
||||
"requirements": ["millheater==0.11.1", "mill-local==0.3.0"]
|
||||
}
|
||||
|
|
|
@ -1210,7 +1210,7 @@ mficlient==0.3.0
|
|||
micloud==0.5
|
||||
|
||||
# homeassistant.components.mill
|
||||
mill-local==0.2.0
|
||||
mill-local==0.3.0
|
||||
|
||||
# homeassistant.components.mill
|
||||
millheater==0.11.1
|
||||
|
|
|
@ -924,7 +924,7 @@ mficlient==0.3.0
|
|||
micloud==0.5
|
||||
|
||||
# homeassistant.components.mill
|
||||
mill-local==0.2.0
|
||||
mill-local==0.3.0
|
||||
|
||||
# homeassistant.components.mill
|
||||
millheater==0.11.1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue