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
+27 -2
View File
@@ -21,6 +21,7 @@ _LOGGER = logging.getLogger(__name__)
@dataclass
class HonSelectEntityDescription(SelectEntityDescription):
option_list: dict[int, str] | None = None
send_key_only: bool = False
@dataclass
@@ -184,6 +185,24 @@ SELECTS: dict[str, tuple[SelectEntityDescription, ...]] = {
translation_key="mode",
),
),
"WH": (
HonSelectEntityDescription(
key="settings.tempSel",
name="Target Temperature",
icon="mdi:thermometer",
unit_of_measurement=UnitOfTemperature.CELSIUS,
translation_key="target_temperature",
send_key_only=True,
),
HonSelectEntityDescription(
key="settings.machMode",
name="Mode",
send_key_only=True,
icon="mdi:information",
option_list=const.WH_MACH_MODE,
translation_key="mach_modes_wh",
),
),
}
SELECTS["WD"] = unique_entities(SELECTS["WM"], SELECTS["TD"])
@@ -293,8 +312,14 @@ class HonSelectEntity(HonEntity, SelectEntity):
async def async_select_option(self, option: str) -> None:
setting = self._device.settings[self.entity_description.key]
setting.value = self._option_to_number(option, setting.values)
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()