Water Heater

This commit is contained in:
Vadym Melnychuk
2023-12-03 18:13:45 +02:00
parent f19c0cfcd2
commit 191bcedaa2
26 changed files with 493 additions and 12 deletions
+20 -3
View File
@@ -5,6 +5,7 @@ from dataclasses import dataclass
from homeassistant.components.number import (
NumberEntity,
NumberEntityDescription,
NumberDeviceClass,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import UnitOfTime, UnitOfTemperature
@@ -26,7 +27,7 @@ class HonConfigNumberEntityDescription(NumberEntityDescription):
@dataclass
class HonNumberEntityDescription(NumberEntityDescription):
pass
send_key_only: bool = False
NUMBERS: dict[str, tuple[NumberEntityDescription, ...]] = {
@@ -194,6 +195,18 @@ NUMBERS: dict[str, tuple[NumberEntityDescription, ...]] = {
translation_key="pollen_level",
),
),
"WH": (
HonNumberEntityDescription(
key="settings.tempSel",
name="Target Temperature",
icon="mdi:thermometer",
mode="slider",
device_class=NumberDeviceClass.TEMPERATURE,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
translation_key="target_temperature",
send_key_only=True,
),
),
}
NUMBERS["WD"] = unique_entities(NUMBERS["WM"], NUMBERS["TD"])
@@ -247,8 +260,12 @@ class HonNumberEntity(HonEntity, NumberEntity):
setting = self._device.settings[self.entity_description.key]
if isinstance(setting, HonParameterRange):
setting.value = value
command = self.entity_description.key.split(".")[0]
await self._device.commands[command].send()
key_parts = self.entity_description.key.split(".")
command = key_parts[0]
if self.entity_description.send_key_only:
await self._device.commands[command].send_specific([key_parts[1]])
else:
await self._device.commands[command].send()
if command != "settings":
self._device.sync_command(command, "settings")
await self.coordinator.async_refresh()