From 191bcedaa220db5ab6d0fdb30726c522e1cd4a9e Mon Sep 17 00:00:00 2001 From: Vadym Melnychuk Date: Sun, 3 Dec 2023 18:13:45 +0200 Subject: [PATCH 1/7] Water Heater --- custom_components/hon/binary_sensor.py | 10 ++++ custom_components/hon/const.py | 6 +++ custom_components/hon/number.py | 23 +++++++-- custom_components/hon/select.py | 29 ++++++++++- custom_components/hon/sensor.py | 57 ++++++++++++++++++++++ custom_components/hon/switch.py | 38 ++++++++++++--- custom_components/hon/translations/bg.json | 19 ++++++++ custom_components/hon/translations/cs.json | 17 +++++++ custom_components/hon/translations/de.json | 17 +++++++ custom_components/hon/translations/el.json | 17 +++++++ custom_components/hon/translations/en.json | 17 +++++++ custom_components/hon/translations/es.json | 17 +++++++ custom_components/hon/translations/fr.json | 17 +++++++ custom_components/hon/translations/he.json | 17 +++++++ custom_components/hon/translations/hr.json | 17 +++++++ custom_components/hon/translations/it.json | 17 +++++++ custom_components/hon/translations/nl.json | 17 +++++++ custom_components/hon/translations/pl.json | 17 +++++++ custom_components/hon/translations/pt.json | 17 +++++++ custom_components/hon/translations/ro.json | 17 +++++++ custom_components/hon/translations/ru.json | 17 +++++++ custom_components/hon/translations/sk.json | 17 +++++++ custom_components/hon/translations/sl.json | 17 +++++++ custom_components/hon/translations/sr.json | 17 +++++++ custom_components/hon/translations/tr.json | 17 +++++++ custom_components/hon/translations/zh.json | 17 +++++++ 26 files changed, 493 insertions(+), 12 deletions(-) diff --git a/custom_components/hon/binary_sensor.py b/custom_components/hon/binary_sensor.py index d33d689..0dd7902 100644 --- a/custom_components/hon/binary_sensor.py +++ b/custom_components/hon/binary_sensor.py @@ -284,6 +284,16 @@ BINARY_SENSORS: dict[str, tuple[HonBinarySensorEntityDescription, ...]] = { translation_key="on", ), ), + "WH": ( + HonBinarySensorEntityDescription( + key="onOffStatus", + name="Power State", + icon="mdi:power-standby", + device_class=BinarySensorDeviceClass.POWER, + on_value=1, + translation_key="power-state", + ), + ), } BINARY_SENSORS["WD"] = unique_entities(BINARY_SENSORS["WM"], BINARY_SENSORS["TD"]) diff --git a/custom_components/hon/const.py b/custom_components/hon/const.py index 69bc540..1d82148 100644 --- a/custom_components/hon/const.py +++ b/custom_components/hon/const.py @@ -282,3 +282,9 @@ AC_POSITION_VERTICAL = { 7: "position_5", 8: "swing", } + +WH_MACH_MODE: dict[int, str] = { + 1: "eco", + 2: "max", + 3: "bps", +} diff --git a/custom_components/hon/number.py b/custom_components/hon/number.py index 7c0e504..5b4fbd3 100644 --- a/custom_components/hon/number.py +++ b/custom_components/hon/number.py @@ -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() diff --git a/custom_components/hon/select.py b/custom_components/hon/select.py index 60bb071..2d78715 100644 --- a/custom_components/hon/select.py +++ b/custom_components/hon/select.py @@ -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() diff --git a/custom_components/hon/sensor.py b/custom_components/hon/sensor.py index db88b17..bb76f7a 100644 --- a/custom_components/hon/sensor.py +++ b/custom_components/hon/sensor.py @@ -780,6 +780,63 @@ SENSORS: dict[str, tuple[SensorEntityDescription, ...]] = { translation_key="air_quality", ), ), + "WH": ( + HonSensorEntityDescription( + key="temp", + name="Temperature", + state_class=SensorStateClass.MEASUREMENT, + device_class=SensorDeviceClass.TEMPERATURE, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + translation_key="temperature", + ), + HonSensorEntityDescription( + key="tempZ1", + name="Temp Z1", + state_class=SensorStateClass.MEASUREMENT, + device_class=SensorDeviceClass.TEMPERATURE, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + ), + HonSensorEntityDescription( + key="tempZ2", + name="Temp Z2", + state_class=SensorStateClass.MEASUREMENT, + device_class=SensorDeviceClass.TEMPERATURE, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + ), + HonSensorEntityDescription( + key="tempSel", + name="Target Temperature", + icon="mdi:thermometer", + state_class=SensorStateClass.MEASUREMENT, + device_class=SensorDeviceClass.TEMPERATURE, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + translation_key="target_temperature", + ), + HonSensorEntityDescription( + key="machMode", + name="Mode", + icon="mdi:information", + device_class=SensorDeviceClass.ENUM, + option_list=const.WH_MACH_MODE, + translation_key="mach_modes_wh", + ), + HonSensorEntityDescription( + key="smartTestStatus", + name="Smart Test Status", + ), + HonSensorEntityDescription( + key="anodeMaintenanceStatus", + name="Anode Maintenance Status", + ), + HonSensorEntityDescription( + key="tankMaintenanceStatus", + name="Tank Maintenance Status", + ), + HonSensorEntityDescription( + key="heatingStatus", + name="Heating Status", + ), + ), } SENSORS["WD"] = unique_entities(SENSORS["WM"], SENSORS["TD"]) diff --git a/custom_components/hon/switch.py b/custom_components/hon/switch.py index 8c32ccd..ee11321 100644 --- a/custom_components/hon/switch.py +++ b/custom_components/hon/switch.py @@ -22,6 +22,10 @@ _LOGGER = logging.getLogger(__name__) class HonControlSwitchEntityDescription(SwitchEntityDescription): turn_on_key: str = "" turn_off_key: str = "" + only_mandatory_parameters: bool = False + on_value: bool | float = True + off_value: bool | float = False + to_sync: bool = False class HonSwitchEntityDescription(SwitchEntityDescription): @@ -374,6 +378,20 @@ SWITCHES: dict[str, tuple[SwitchEntityDescription, ...]] = { translation_key="touch_tone", ), ), + "WH": ( + HonControlSwitchEntityDescription( + key="onOffStatus", + name="Power", + icon="mdi:power-standby", + turn_on_key="startProgram", + turn_off_key="stopProgram", + translation_key="power", + only_mandatory_parameters=True, + on_value=1, + off_value=0, + to_sync=True, + ), + ), } SWITCHES["WD"] = unique_entities(SWITCHES["WD"], SWITCHES["WM"]) @@ -464,20 +482,26 @@ class HonControlSwitchEntity(HonEntity, SwitchEntity): @property def is_on(self) -> bool | None: """Return True if entity is on.""" - return self._device.get(self.entity_description.key, False) + on_value = self.entity_description.on_value + off_value = self.entity_description.off_value + return self._device.get(self.entity_description.key, off_value) == on_value async def async_turn_on(self, **kwargs: Any) -> None: - self._device.sync_command(self.entity_description.turn_on_key, "settings") + desc = self.entity_description + self._device.sync_command(desc.turn_on_key, "settings", desc.to_sync) await self.coordinator.async_refresh() - await self._device.commands[self.entity_description.turn_on_key].send() - self._device.attributes[self.entity_description.key] = True + command = self._device.commands[desc.turn_on_key] + await command.send(desc.only_mandatory_parameters) + self._device.attributes[desc.key] = desc.on_value self.async_write_ha_state() async def async_turn_off(self, **kwargs: Any) -> None: - self._device.sync_command(self.entity_description.turn_off_key, "settings") + desc = self.entity_description + self._device.sync_command(desc.turn_off_key, "settings", desc.to_sync) await self.coordinator.async_refresh() - await self._device.commands[self.entity_description.turn_off_key].send() - self._device.attributes[self.entity_description.key] = False + command = self._device.commands[desc.turn_off_key] + await command.send(desc.only_mandatory_parameters) + self._device.attributes[desc.key] = desc.off_value self.async_write_ha_state() @property diff --git a/custom_components/hon/translations/bg.json b/custom_components/hon/translations/bg.json index b457373..b371441 100644 --- a/custom_components/hon/translations/bg.json +++ b/custom_components/hon/translations/bg.json @@ -72,6 +72,13 @@ "13": "Готови за съхранение H-2", "14": "Екстра сухо H-3" } + }, + "mach_modes_wh": { + "state": { + "eco": "Eco", + "max": "Max", + "bps": "BPS" + } } }, "select": { @@ -82,6 +89,18 @@ "13": "Готови за съхранение H-2", "14": "Екстра сухо H-3" } + }, + "mach_modes_wh": { + "state": { + "eco": "Eco", + "max": "Max", + "bps": "BPS" + } + } + }, + "binary_sensor": { + "power-state": { + "name": "Power State" } } } diff --git a/custom_components/hon/translations/cs.json b/custom_components/hon/translations/cs.json index 3ecf296..fd408a5 100644 --- a/custom_components/hon/translations/cs.json +++ b/custom_components/hon/translations/cs.json @@ -917,6 +917,13 @@ "high": "Vysoká" }, "name": "Úroveň vlhkosti" + }, + "mach_modes_wh": { + "state": { + "eco": "Eco", + "max": "Max", + "bps": "BPS" + } } }, "select": { @@ -1788,6 +1795,13 @@ "position_5": "Pevný - Poloha 5", "swing": "Pohyb lamel" } + }, + "mach_modes_wh": { + "state": { + "eco": "Eco", + "max": "Max", + "bps": "BPS" + } } }, "switch": { @@ -1987,6 +2001,9 @@ }, "filter_replacement": { "name": "Výměna filtru" + }, + "power-state": { + "name": "Power State" } }, "button": { diff --git a/custom_components/hon/translations/de.json b/custom_components/hon/translations/de.json index 71b8e72..80913b5 100644 --- a/custom_components/hon/translations/de.json +++ b/custom_components/hon/translations/de.json @@ -917,6 +917,13 @@ "high": "Hoch" }, "name": "Grad der Luftfeuchtigkeit" + }, + "mach_modes_wh": { + "state": { + "eco": "Eco", + "max": "Max", + "bps": "BPS" + } } }, "select": { @@ -1788,6 +1795,13 @@ "position_5": "Fest - Position 5", "swing": "Schwenkbewegung" } + }, + "mach_modes_wh": { + "state": { + "eco": "Eco", + "max": "Max", + "bps": "BPS" + } } }, "switch": { @@ -1987,6 +2001,9 @@ }, "filter_replacement": { "name": "Filteraustausch" + }, + "power-state": { + "name": "Power State" } }, "button": { diff --git a/custom_components/hon/translations/el.json b/custom_components/hon/translations/el.json index cb46299..cfadf47 100644 --- a/custom_components/hon/translations/el.json +++ b/custom_components/hon/translations/el.json @@ -917,6 +917,13 @@ "high": "Υψηλός" }, "name": "Επίπεδο υγρασίας" + }, + "mach_modes_wh": { + "state": { + "eco": "Eco", + "max": "Max", + "bps": "BPS" + } } }, "select": { @@ -1788,6 +1795,13 @@ "position_5": "Σταθερός - Θέση 5", "swing": "Ταλάντευση" } + }, + "mach_modes_wh": { + "state": { + "eco": "Eco", + "max": "Max", + "bps": "BPS" + } } }, "switch": { @@ -1987,6 +2001,9 @@ }, "filter_replacement": { "name": "Αντικατάσταση φίλτρου" + }, + "power-state": { + "name": "Power State" } }, "button": { diff --git a/custom_components/hon/translations/en.json b/custom_components/hon/translations/en.json index 1374407..23296fb 100644 --- a/custom_components/hon/translations/en.json +++ b/custom_components/hon/translations/en.json @@ -937,6 +937,13 @@ "high": "High" }, "name": "Humidity level" + }, + "mach_modes_wh": { + "state": { + "eco": "Eco", + "max": "Max", + "bps": "BPS" + } } }, "select": { @@ -1815,6 +1822,13 @@ "position_5": "Fixed - Position 5", "swing": "Swing" } + }, + "mach_modes_wh": { + "state": { + "eco": "Eco", + "max": "Max", + "bps": "BPS" + } } }, "switch": { @@ -2014,6 +2028,9 @@ }, "filter_replacement": { "name": "Filter replacement" + }, + "power-state": { + "name": "Power State" } }, "button": { diff --git a/custom_components/hon/translations/es.json b/custom_components/hon/translations/es.json index 437885b..e8d62a7 100644 --- a/custom_components/hon/translations/es.json +++ b/custom_components/hon/translations/es.json @@ -917,6 +917,13 @@ "high": "Alto" }, "name": "Nivel de humedad" + }, + "mach_modes_wh": { + "state": { + "eco": "Eco", + "max": "Max", + "bps": "BPS" + } } }, "select": { @@ -1788,6 +1795,13 @@ "position_5": "Fijo - Posición 5", "swing": "Oscilar" } + }, + "mach_modes_wh": { + "state": { + "eco": "Eco", + "max": "Max", + "bps": "BPS" + } } }, "switch": { @@ -1987,6 +2001,9 @@ }, "filter_replacement": { "name": "Sustitución del filtro" + }, + "power-state": { + "name": "Power State" } }, "button": { diff --git a/custom_components/hon/translations/fr.json b/custom_components/hon/translations/fr.json index c84f4c5..8ae2b4b 100644 --- a/custom_components/hon/translations/fr.json +++ b/custom_components/hon/translations/fr.json @@ -917,6 +917,13 @@ "high": "Élevé" }, "name": "Niveau d’humidité" + }, + "mach_modes_wh": { + "state": { + "eco": "Eco", + "max": "Max", + "bps": "BPS" + } } }, "select": { @@ -1788,6 +1795,13 @@ "position_5": "Fixe - Position 5", "swing": "Oscillation" } + }, + "mach_modes_wh": { + "state": { + "eco": "Eco", + "max": "Max", + "bps": "BPS" + } } }, "switch": { @@ -1987,6 +2001,9 @@ }, "filter_replacement": { "name": "Remplacement du filtre" + }, + "power-state": { + "name": "Power State" } }, "button": { diff --git a/custom_components/hon/translations/he.json b/custom_components/hon/translations/he.json index f2841b3..a0ced54 100644 --- a/custom_components/hon/translations/he.json +++ b/custom_components/hon/translations/he.json @@ -445,6 +445,13 @@ "high": "גָבוֹהַ" }, "name": "Humidity level" + }, + "mach_modes_wh": { + "state": { + "eco": "Eco", + "max": "Max", + "bps": "BPS" + } } }, "select": { @@ -853,6 +860,13 @@ "position_5": "Fixed - Position 5", "swing": "Swing" } + }, + "mach_modes_wh": { + "state": { + "eco": "Eco", + "max": "Max", + "bps": "BPS" + } } }, "switch": { @@ -1052,6 +1066,9 @@ }, "filter_replacement": { "name": "Filter replacement" + }, + "power-state": { + "name": "Power State" } }, "button": { diff --git a/custom_components/hon/translations/hr.json b/custom_components/hon/translations/hr.json index 1bc65a1..6ab87e5 100644 --- a/custom_components/hon/translations/hr.json +++ b/custom_components/hon/translations/hr.json @@ -917,6 +917,13 @@ "high": "Visoko" }, "name": "Razina vlažnosti" + }, + "mach_modes_wh": { + "state": { + "eco": "Eco", + "max": "Max", + "bps": "BPS" + } } }, "select": { @@ -1788,6 +1795,13 @@ "position_5": "Fiksno - Položaj 5", "swing": "Njihanje" } + }, + "mach_modes_wh": { + "state": { + "eco": "Eco", + "max": "Max", + "bps": "BPS" + } } }, "switch": { @@ -1987,6 +2001,9 @@ }, "filter_replacement": { "name": "Zamjena filtra" + }, + "power-state": { + "name": "Power State" } }, "button": { diff --git a/custom_components/hon/translations/it.json b/custom_components/hon/translations/it.json index 004b8c5..0c044a6 100644 --- a/custom_components/hon/translations/it.json +++ b/custom_components/hon/translations/it.json @@ -924,6 +924,13 @@ "high": "Alto" }, "name": "Livello di umidità" + }, + "mach_modes_wh": { + "state": { + "eco": "Eco", + "max": "Max", + "bps": "BPS" + } } }, "select": { @@ -1797,6 +1804,13 @@ "position_5": "Fissa - Posizione 5", "swing": "Swing" } + }, + "mach_modes_wh": { + "state": { + "eco": "Eco", + "max": "Max", + "bps": "BPS" + } } }, "switch": { @@ -1996,6 +2010,9 @@ }, "filter_replacement": { "name": "Sostituzione filtro" + }, + "power-state": { + "name": "Power State" } }, "button": { diff --git a/custom_components/hon/translations/nl.json b/custom_components/hon/translations/nl.json index 961cb7a..97d4117 100644 --- a/custom_components/hon/translations/nl.json +++ b/custom_components/hon/translations/nl.json @@ -917,6 +917,13 @@ "high": "Hoog" }, "name": "Vochtigheidsniveau" + }, + "mach_modes_wh": { + "state": { + "eco": "Eco", + "max": "Max", + "bps": "BPS" + } } }, "select": { @@ -1788,6 +1795,13 @@ "position_5": "Vast - Positie 5", "swing": "Draaiend" } + }, + "mach_modes_wh": { + "state": { + "eco": "Eco", + "max": "Max", + "bps": "BPS" + } } }, "switch": { @@ -1987,6 +2001,9 @@ }, "filter_replacement": { "name": "Filter vervangen" + }, + "power-state": { + "name": "Power State" } }, "button": { diff --git a/custom_components/hon/translations/pl.json b/custom_components/hon/translations/pl.json index b59b87a..04d1870 100644 --- a/custom_components/hon/translations/pl.json +++ b/custom_components/hon/translations/pl.json @@ -917,6 +917,13 @@ "high": "Wysokie" }, "name": "Poziom wilgotności" + }, + "mach_modes_wh": { + "state": { + "eco": "Eco", + "max": "Max", + "bps": "BPS" + } } }, "select": { @@ -1788,6 +1795,13 @@ "position_5": "Stały - Pozycja 5", "swing": "Swing" } + }, + "mach_modes_wh": { + "state": { + "eco": "Eco", + "max": "Max", + "bps": "BPS" + } } }, "switch": { @@ -1987,6 +2001,9 @@ }, "filter_replacement": { "name": "Wymiana filtra" + }, + "power-state": { + "name": "Power State" } }, "button": { diff --git a/custom_components/hon/translations/pt.json b/custom_components/hon/translations/pt.json index abeb471..e1fa9ad 100644 --- a/custom_components/hon/translations/pt.json +++ b/custom_components/hon/translations/pt.json @@ -917,6 +917,13 @@ "high": "Alta" }, "name": "Nível de humidade" + }, + "mach_modes_wh": { + "state": { + "eco": "Eco", + "max": "Max", + "bps": "BPS" + } } }, "select": { @@ -1788,6 +1795,13 @@ "position_5": "Fixa - Posição 5", "swing": "Oscilação" } + }, + "mach_modes_wh": { + "state": { + "eco": "Eco", + "max": "Max", + "bps": "BPS" + } } }, "switch": { @@ -1987,6 +2001,9 @@ }, "filter_replacement": { "name": "Substituição do filtro" + }, + "power-state": { + "name": "Power State" } }, "button": { diff --git a/custom_components/hon/translations/ro.json b/custom_components/hon/translations/ro.json index 2fc4e21..9437b82 100644 --- a/custom_components/hon/translations/ro.json +++ b/custom_components/hon/translations/ro.json @@ -917,6 +917,13 @@ "high": "Crescută" }, "name": "Nivelul de umiditate" + }, + "mach_modes_wh": { + "state": { + "eco": "Eco", + "max": "Max", + "bps": "BPS" + } } }, "select": { @@ -1788,6 +1795,13 @@ "position_5": "Fix - Poziție 5", "swing": "Baleiere" } + }, + "mach_modes_wh": { + "state": { + "eco": "Eco", + "max": "Max", + "bps": "BPS" + } } }, "switch": { @@ -1987,6 +2001,9 @@ }, "filter_replacement": { "name": "Înlocuirea filtrului" + }, + "power-state": { + "name": "Power State" } }, "button": { diff --git a/custom_components/hon/translations/ru.json b/custom_components/hon/translations/ru.json index 162fb93..eccdbf6 100644 --- a/custom_components/hon/translations/ru.json +++ b/custom_components/hon/translations/ru.json @@ -917,6 +917,13 @@ "high": "Высок." }, "name": "Уровень влажности" + }, + "mach_modes_wh": { + "state": { + "eco": "Eco", + "max": "Max", + "bps": "BPS" + } } }, "select": { @@ -1788,6 +1795,13 @@ "position_5": "Фиксированное - Позиция 5", "swing": "Качание" } + }, + "mach_modes_wh": { + "state": { + "eco": "Eco", + "max": "Max", + "bps": "BPS" + } } }, "switch": { @@ -1987,6 +2001,9 @@ }, "filter_replacement": { "name": "Замена фильтра" + }, + "power-state": { + "name": "Power State" } }, "button": { diff --git a/custom_components/hon/translations/sk.json b/custom_components/hon/translations/sk.json index b0fb17f..16be24e 100644 --- a/custom_components/hon/translations/sk.json +++ b/custom_components/hon/translations/sk.json @@ -917,6 +917,13 @@ "high": "Vysoké" }, "name": "Úroveň vlhkosti" + }, + "mach_modes_wh": { + "state": { + "eco": "Eco", + "max": "Max", + "bps": "BPS" + } } }, "select": { @@ -1788,6 +1795,13 @@ "position_5": "Pevný - Poloha 5", "swing": "Otáčanie" } + }, + "mach_modes_wh": { + "state": { + "eco": "Eco", + "max": "Max", + "bps": "BPS" + } } }, "switch": { @@ -1987,6 +2001,9 @@ }, "filter_replacement": { "name": "Výmena filtra" + }, + "power-state": { + "name": "Power State" } }, "button": { diff --git a/custom_components/hon/translations/sl.json b/custom_components/hon/translations/sl.json index 8eda7ec..9535fc2 100644 --- a/custom_components/hon/translations/sl.json +++ b/custom_components/hon/translations/sl.json @@ -917,6 +917,13 @@ "high": "High" }, "name": "Nivo vlažnosti" + }, + "mach_modes_wh": { + "state": { + "eco": "Eco", + "max": "Max", + "bps": "BPS" + } } }, "select": { @@ -1788,6 +1795,13 @@ "position_5": "Fiksno - Položaj 5", "swing": "Nihanje" } + }, + "mach_modes_wh": { + "state": { + "eco": "Eco", + "max": "Max", + "bps": "BPS" + } } }, "switch": { @@ -1987,6 +2001,9 @@ }, "filter_replacement": { "name": "Menjava filtra" + }, + "power-state": { + "name": "Power State" } }, "button": { diff --git a/custom_components/hon/translations/sr.json b/custom_components/hon/translations/sr.json index ab581d1..798a79b 100644 --- a/custom_components/hon/translations/sr.json +++ b/custom_components/hon/translations/sr.json @@ -917,6 +917,13 @@ "high": "Visoka" }, "name": "Nivo vlage" + }, + "mach_modes_wh": { + "state": { + "eco": "Eco", + "max": "Max", + "bps": "BPS" + } } }, "select": { @@ -1788,6 +1795,13 @@ "position_5": "Fiksiran - Položaj 5", "swing": "Njihanje" } + }, + "mach_modes_wh": { + "state": { + "eco": "Eco", + "max": "Max", + "bps": "BPS" + } } }, "switch": { @@ -1987,6 +2001,9 @@ }, "filter_replacement": { "name": "Zamena filtera" + }, + "power-state": { + "name": "Power State" } }, "button": { diff --git a/custom_components/hon/translations/tr.json b/custom_components/hon/translations/tr.json index ad348f0..9c2802a 100644 --- a/custom_components/hon/translations/tr.json +++ b/custom_components/hon/translations/tr.json @@ -917,6 +917,13 @@ "high": "Yüksek" }, "name": "Nem seviyesi" + }, + "mach_modes_wh": { + "state": { + "eco": "Eco", + "max": "Max", + "bps": "BPS" + } } }, "select": { @@ -1788,6 +1795,13 @@ "position_5": "Sabit - Pozisyon 5", "swing": "Salınım" } + }, + "mach_modes_wh": { + "state": { + "eco": "Eco", + "max": "Max", + "bps": "BPS" + } } }, "switch": { @@ -1987,6 +2001,9 @@ }, "filter_replacement": { "name": "Filtre değişimi" + }, + "power-state": { + "name": "Power State" } }, "button": { diff --git a/custom_components/hon/translations/zh.json b/custom_components/hon/translations/zh.json index d1e0fef..ad0d3fa 100644 --- a/custom_components/hon/translations/zh.json +++ b/custom_components/hon/translations/zh.json @@ -910,6 +910,13 @@ "high": "高" }, "name": "湿度水平" + }, + "mach_modes_wh": { + "state": { + "eco": "Eco", + "max": "Max", + "bps": "BPS" + } } }, "select": { @@ -1774,6 +1781,13 @@ "position_5": "固定 - 位置 5", "swing": "摆动" } + }, + "mach_modes_wh": { + "state": { + "eco": "Eco", + "max": "Max", + "bps": "BPS" + } } }, "switch": { @@ -1973,6 +1987,9 @@ }, "filter_replacement": { "name": "更换过滤器" + }, + "power-state": { + "name": "Power State" } }, "button": { From 4772374db7df6748101f117e003d0473acd89827 Mon Sep 17 00:00:00 2001 From: Vadym Melnychuk Date: Sun, 3 Dec 2023 20:31:46 +0200 Subject: [PATCH 2/7] fix pipeline --- custom_components/hon/number.py | 3 ++- custom_components/hon/select.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/custom_components/hon/number.py b/custom_components/hon/number.py index 5b4fbd3..28e9e33 100644 --- a/custom_components/hon/number.py +++ b/custom_components/hon/number.py @@ -6,6 +6,7 @@ from homeassistant.components.number import ( NumberEntity, NumberEntityDescription, NumberDeviceClass, + NumberMode, ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import UnitOfTime, UnitOfTemperature @@ -200,7 +201,7 @@ NUMBERS: dict[str, tuple[NumberEntityDescription, ...]] = { key="settings.tempSel", name="Target Temperature", icon="mdi:thermometer", - mode="slider", + mode=NumberMode.SLIDER, device_class=NumberDeviceClass.TEMPERATURE, native_unit_of_measurement=UnitOfTemperature.CELSIUS, translation_key="target_temperature", diff --git a/custom_components/hon/select.py b/custom_components/hon/select.py index 2d78715..97db69d 100644 --- a/custom_components/hon/select.py +++ b/custom_components/hon/select.py @@ -316,7 +316,7 @@ class HonSelectEntity(HonEntity, SelectEntity): command = key_parts[0] if (self.entity_description.send_key_only): - await self._device.commands[command].send_specific(key_parts[1]) + await self._device.commands[command].send_specific([key_parts[1]]) else: await self._device.commands[command].send() From 6ba50f8456a4dd9cbf08a28a4661926b14b7b4d1 Mon Sep 17 00:00:00 2001 From: Vadym Melnychuk Date: Sun, 3 Dec 2023 20:50:37 +0200 Subject: [PATCH 3/7] removed mode --- custom_components/hon/number.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/custom_components/hon/number.py b/custom_components/hon/number.py index 28e9e33..bce170c 100644 --- a/custom_components/hon/number.py +++ b/custom_components/hon/number.py @@ -6,7 +6,6 @@ from homeassistant.components.number import ( NumberEntity, NumberEntityDescription, NumberDeviceClass, - NumberMode, ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import UnitOfTime, UnitOfTemperature @@ -201,7 +200,6 @@ NUMBERS: dict[str, tuple[NumberEntityDescription, ...]] = { key="settings.tempSel", name="Target Temperature", icon="mdi:thermometer", - mode=NumberMode.SLIDER, device_class=NumberDeviceClass.TEMPERATURE, native_unit_of_measurement=UnitOfTemperature.CELSIUS, translation_key="target_temperature", From 5647cc24e6001d978470fe09b9e025dd10b8d387 Mon Sep 17 00:00:00 2001 From: Vadym Melnychuk Date: Sun, 3 Dec 2023 20:57:27 +0200 Subject: [PATCH 4/7] fix black checks --- custom_components/hon/select.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/custom_components/hon/select.py b/custom_components/hon/select.py index 97db69d..408ba60 100644 --- a/custom_components/hon/select.py +++ b/custom_components/hon/select.py @@ -314,12 +314,10 @@ class HonSelectEntity(HonEntity, SelectEntity): setting.value = self._option_to_number(option, setting.values) key_parts = self.entity_description.key.split(".") command = key_parts[0] - - if (self.entity_description.send_key_only): + 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() From f66bd14ed13aaa0eece4cd37412d02fcbd00177d Mon Sep 17 00:00:00 2001 From: Vadym Melnychuk Date: Thu, 22 Aug 2024 18:32:04 +0300 Subject: [PATCH 5/7] remove old stuff --- custom_components/hon/switch.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/custom_components/hon/switch.py b/custom_components/hon/switch.py index f6290f8..209d069 100644 --- a/custom_components/hon/switch.py +++ b/custom_components/hon/switch.py @@ -510,7 +510,6 @@ class HonControlSwitchEntity(HonEntity, SwitchEntity): async def async_turn_on(self, **kwargs: Any) -> None: desc = self.entity_description self._device.sync_command(desc.turn_on_key, "settings", desc.to_sync) - //await self.coordinator.async_refresh() self.coordinator.async_set_updated_data({}) command = self._device.commands[desc.turn_on_key] await command.send(desc.only_mandatory_parameters) @@ -520,7 +519,6 @@ class HonControlSwitchEntity(HonEntity, SwitchEntity): async def async_turn_off(self, **kwargs: Any) -> None: desc = self.entity_description self._device.sync_command(desc.turn_off_key, "settings", desc.to_sync) - //await self.coordinator.async_refresh() self.coordinator.async_set_updated_data({}) command = self._device.commands[desc.turn_off_key] await command.send(desc.only_mandatory_parameters) From e81b1503de20c3dd8d171ed7ac496475528fa519 Mon Sep 17 00:00:00 2001 From: Vadym Melnychuk Date: Mon, 23 Mar 2026 12:17:06 +0200 Subject: [PATCH 6/7] Small changes fixed power switch Revert "fixed power switch" This reverts commit a1a2b04444a10c9dba9731ea62571ff20b56ede1. new HON switch stable --- custom_components/hon/__init__.py | 11 +++++----- custom_components/hon/binary_sensor.py | 5 ++--- custom_components/hon/button.py | 2 +- custom_components/hon/climate.py | 3 +-- custom_components/hon/entity.py | 5 ++--- custom_components/hon/fan.py | 3 +-- custom_components/hon/light.py | 3 +-- custom_components/hon/lock.py | 3 +-- custom_components/hon/number.py | 7 +++---- custom_components/hon/select.py | 28 ++++++++++++-------------- custom_components/hon/sensor.py | 8 ++++---- custom_components/hon/switch.py | 22 +++++++++++--------- 12 files changed, 48 insertions(+), 52 deletions(-) diff --git a/custom_components/hon/__init__.py b/custom_components/hon/__init__.py index 1e38a2d..81b81bb 100644 --- a/custom_components/hon/__init__.py +++ b/custom_components/hon/__init__.py @@ -5,8 +5,8 @@ from typing import Any import voluptuous as vol # type: ignore[import-untyped] from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_EMAIL, CONF_PASSWORD +from homeassistant.core import HomeAssistant as HomeAssistantType from homeassistant.helpers import config_validation as cv, aiohttp_client -from homeassistant.helpers.typing import HomeAssistantType from homeassistant.helpers.update_coordinator import DataUpdateCoordinator from pyhon import Hon @@ -53,10 +53,11 @@ async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool hass.data.setdefault(DOMAIN, {}) hass.data[DOMAIN][entry.unique_id] = {"hon": hon, "coordinator": coordinator} - for platform in PLATFORMS: - hass.async_create_task( - hass.config_entries.async_forward_entry_setup(entry, platform) - ) + await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS) + #for platform in PLATFORMS: + # hass.async_create_task( + # hass.config_entries.async_forward_entry_setups(entry, platform) + # ) return True diff --git a/custom_components/hon/binary_sensor.py b/custom_components/hon/binary_sensor.py index 4f85635..23de62e 100644 --- a/custom_components/hon/binary_sensor.py +++ b/custom_components/hon/binary_sensor.py @@ -7,9 +7,8 @@ from homeassistant.components.binary_sensor import ( BinarySensorEntity, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.core import callback +from homeassistant.core import HomeAssistant as HomeAssistantType, callback from homeassistant.helpers.entity_platform import AddEntitiesCallback -from homeassistant.helpers.typing import HomeAssistantType from .const import DOMAIN from .entity import HonEntity @@ -356,4 +355,4 @@ class HonBinarySensorEntity(HonEntity, BinarySensorEntity): == self.entity_description.on_value ) if update: - self.async_write_ha_state() + self.schedule_update_ha_state() diff --git a/custom_components/hon/button.py b/custom_components/hon/button.py index ce0f548..03e4f5e 100644 --- a/custom_components/hon/button.py +++ b/custom_components/hon/button.py @@ -4,9 +4,9 @@ from pathlib import Path from homeassistant.components import persistent_notification from homeassistant.components.button import ButtonEntityDescription, ButtonEntity from homeassistant.config_entries import ConfigEntry +from homeassistant.core import HomeAssistant as HomeAssistantType from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity_platform import AddEntitiesCallback -from homeassistant.helpers.typing import HomeAssistantType from pyhon.appliance import HonAppliance from .const import DOMAIN diff --git a/custom_components/hon/climate.py b/custom_components/hon/climate.py index f3ce937..5f574a0 100644 --- a/custom_components/hon/climate.py +++ b/custom_components/hon/climate.py @@ -19,9 +19,8 @@ from homeassistant.const import ( ATTR_TEMPERATURE, UnitOfTemperature, ) -from homeassistant.core import callback +from homeassistant.core import HomeAssistant as HomeAssistantType, callback from homeassistant.helpers.entity_platform import AddEntitiesCallback -from homeassistant.helpers.typing import HomeAssistantType from pyhon.appliance import HonAppliance from pyhon.parameter.range import HonParameterRange diff --git a/custom_components/hon/entity.py b/custom_components/hon/entity.py index a597052..154ce32 100644 --- a/custom_components/hon/entity.py +++ b/custom_components/hon/entity.py @@ -1,9 +1,8 @@ from typing import Optional, Any from homeassistant.config_entries import ConfigEntry -from homeassistant.core import callback +from homeassistant.core import HomeAssistant as HomeAssistantType, callback from homeassistant.helpers.entity import DeviceInfo -from homeassistant.helpers.typing import HomeAssistantType from homeassistant.helpers.update_coordinator import ( CoordinatorEntity, ) @@ -53,4 +52,4 @@ class HonEntity(CoordinatorEntity[DataUpdateCoordinator[dict[str, Any]]]): @callback def _handle_coordinator_update(self, update: bool = True) -> None: if update: - self.async_write_ha_state() + self.schedule_update_ha_state() diff --git a/custom_components/hon/fan.py b/custom_components/hon/fan.py index a07a08f..2432b83 100644 --- a/custom_components/hon/fan.py +++ b/custom_components/hon/fan.py @@ -8,9 +8,8 @@ from homeassistant.components.fan import ( FanEntityFeature, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.core import callback +from homeassistant.core import HomeAssistant as HomeAssistantType, callback from homeassistant.helpers.entity_platform import AddEntitiesCallback -from homeassistant.helpers.typing import HomeAssistantType from homeassistant.util.percentage import ( percentage_to_ranged_value, ranged_value_to_percentage, diff --git a/custom_components/hon/light.py b/custom_components/hon/light.py index d38a994..840c5d6 100644 --- a/custom_components/hon/light.py +++ b/custom_components/hon/light.py @@ -8,9 +8,8 @@ from homeassistant.components.light import ( ATTR_BRIGHTNESS, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.core import callback +from homeassistant.core import HomeAssistant as HomeAssistantType, callback from homeassistant.helpers.entity_platform import AddEntitiesCallback -from homeassistant.helpers.typing import HomeAssistantType from pyhon.appliance import HonAppliance from pyhon.parameter.range import HonParameterRange diff --git a/custom_components/hon/lock.py b/custom_components/hon/lock.py index 1ecb744..d098ab0 100644 --- a/custom_components/hon/lock.py +++ b/custom_components/hon/lock.py @@ -3,9 +3,8 @@ from typing import Any from homeassistant.components.lock import LockEntity, LockEntityDescription from homeassistant.config_entries import ConfigEntry -from homeassistant.core import callback +from homeassistant.core import HomeAssistant as HomeAssistantType, callback from homeassistant.helpers.entity_platform import AddEntitiesCallback -from homeassistant.helpers.typing import HomeAssistantType from pyhon.parameter.base import HonParameter from pyhon.parameter.range import HonParameterRange diff --git a/custom_components/hon/number.py b/custom_components/hon/number.py index 5864c36..9edf360 100644 --- a/custom_components/hon/number.py +++ b/custom_components/hon/number.py @@ -9,10 +9,9 @@ from homeassistant.components.number import ( ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import UnitOfTime, UnitOfTemperature -from homeassistant.core import callback +from homeassistant.core import HomeAssistant as HomeAssistantType, callback from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity_platform import AddEntitiesCallback -from homeassistant.helpers.typing import HomeAssistantType from pyhon.appliance import HonAppliance from pyhon.parameter.range import HonParameterRange @@ -284,7 +283,7 @@ class HonNumberEntity(HonEntity, NumberEntity): self._attr_native_step = setting.step self._attr_native_value = self.native_value if update: - self.async_write_ha_state() + self.schedule_update_ha_state() @property def available(self) -> bool: @@ -340,4 +339,4 @@ class HonConfigNumberEntity(HonEntity, NumberEntity): self._attr_native_step = setting.step self._attr_native_value = self.native_value if update: - self.async_write_ha_state() + self.schedule_update_ha_state() diff --git a/custom_components/hon/select.py b/custom_components/hon/select.py index 90fd98a..7eb5bbf 100644 --- a/custom_components/hon/select.py +++ b/custom_components/hon/select.py @@ -6,10 +6,9 @@ from dataclasses import dataclass from homeassistant.components.select import SelectEntity, SelectEntityDescription from homeassistant.config_entries import ConfigEntry from homeassistant.const import UnitOfTemperature, UnitOfTime, REVOLUTIONS_PER_MINUTE -from homeassistant.core import callback +from homeassistant.core import HomeAssistant as HomeAssistantType, callback from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity_platform import AddEntitiesCallback -from homeassistant.helpers.typing import HomeAssistantType from . import const from .const import DOMAIN @@ -187,14 +186,6 @@ SELECTS: dict[str, tuple[SelectEntityDescription, ...]] = { ), ), "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", @@ -202,7 +193,7 @@ SELECTS: dict[str, tuple[SelectEntityDescription, ...]] = { icon="mdi:information", option_list=const.WH_MACH_MODE, translation_key="mach_modes_wh", - ), + ), ), "FRE": ( HonConfigSelectEntityDescription( @@ -303,9 +294,16 @@ class HonSelectEntity(HonEntity, SelectEntity): @property def current_option(self) -> str | None: - if not (setting := self._device.settings.get(self.entity_description.key)): - return None - value = get_readable(self.entity_description, setting.value) + key = self.entity_description.key + if self.entity_description.send_key_only: + key = key.split('.')[1] + value = self._device.get(key, "") + value = get_readable(self.entity_description, value) + else: + if not (setting := self._device.settings.get(self.entity_description.key)): + return None + value = get_readable(self.entity_description, setting.value) + if value not in self._attr_options: return None return str(value) @@ -357,4 +355,4 @@ class HonSelectEntity(HonEntity, SelectEntity): self._attr_options = self.options self._attr_current_option = self.current_option if update: - self.async_write_ha_state() + self.schedule_update_ha_state() diff --git a/custom_components/hon/sensor.py b/custom_components/hon/sensor.py index cc741bb..20ae360 100644 --- a/custom_components/hon/sensor.py +++ b/custom_components/hon/sensor.py @@ -21,10 +21,10 @@ from homeassistant.const import ( UnitOfTime, UnitOfTemperature, ) -from homeassistant.core import callback +from homeassistant.core import HomeAssistant as HomeAssistantType, callback from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity_platform import AddEntitiesCallback -from homeassistant.helpers.typing import HomeAssistantType +from pyhon.attributes import HonAttribute from . import const from .const import DOMAIN @@ -903,7 +903,7 @@ class HonSensorEntity(HonEntity, SensorEntity): self._attr_native_value = 0 self._attr_native_value = value if update: - self.async_write_ha_state() + self.schedule_update_ha_state() class HonConfigSensorEntity(HonEntity, SensorEntity): @@ -931,4 +931,4 @@ class HonConfigSensorEntity(HonEntity, SensorEntity): value = get_readable(self.entity_description, value) self._attr_native_value = value if update: - self.async_write_ha_state() + self.schedule_update_ha_state() diff --git a/custom_components/hon/switch.py b/custom_components/hon/switch.py index 209d069..94ff523 100644 --- a/custom_components/hon/switch.py +++ b/custom_components/hon/switch.py @@ -8,7 +8,7 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.core import callback from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity_platform import AddEntitiesCallback -from homeassistant.helpers.typing import HomeAssistantType +from homeassistant.core import HomeAssistant from pyhon.parameter.base import HonParameter from pyhon.parameter.range import HonParameterRange @@ -394,7 +394,7 @@ SWITCHES: dict[str, tuple[SwitchEntityDescription, ...]] = { turn_on_key="startProgram", turn_off_key="stopProgram", translation_key="power", - only_mandatory_parameters=True, + only_mandatory_parameters=False, on_value=1, off_value=0, to_sync=True, @@ -421,7 +421,7 @@ SWITCHES["WD"] = unique_entities(SWITCHES["WD"], SWITCHES["TD"]) async def async_setup_entry( - hass: HomeAssistantType, entry: ConfigEntry, async_add_entities: AddEntitiesCallback + hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback ) -> None: entities = [] entity: HonConfigSwitchEntity | HonControlSwitchEntity | HonSwitchEntity @@ -494,7 +494,7 @@ class HonSwitchEntity(HonEntity, SwitchEntity): def _handle_coordinator_update(self, update: bool = True) -> None: self._attr_is_on = self.is_on if update: - self.async_write_ha_state() + self.schedule_update_ha_state() class HonControlSwitchEntity(HonEntity, SwitchEntity): @@ -512,9 +512,13 @@ class HonControlSwitchEntity(HonEntity, SwitchEntity): self._device.sync_command(desc.turn_on_key, "settings", desc.to_sync) self.coordinator.async_set_updated_data({}) command = self._device.commands[desc.turn_on_key] + if self._device.appliance_type == "WH": + command.settings["machMode"].value = self._device.get("machMode", "") + command.settings["tempSel"].value = self._device.get("tempSel", "") + await command.send(desc.only_mandatory_parameters) self._device.attributes[desc.key] = desc.on_value - self.async_write_ha_state() + self.schedule_update_ha_state() async def async_turn_off(self, **kwargs: Any) -> None: desc = self.entity_description @@ -523,7 +527,7 @@ class HonControlSwitchEntity(HonEntity, SwitchEntity): command = self._device.commands[desc.turn_off_key] await command.send(desc.only_mandatory_parameters) self._device.attributes[desc.key] = desc.off_value - self.async_write_ha_state() + self.schedule_update_ha_state() @property def available(self) -> bool: @@ -566,7 +570,7 @@ class HonConfigSwitchEntity(HonEntity, SwitchEntity): return setting.value = setting.max if isinstance(setting, HonParameterRange) else "1" self.coordinator.async_set_updated_data({}) - self.async_write_ha_state() + self.schedule_update_ha_state() async def async_turn_off(self, **kwargs: Any) -> None: setting = self._device.settings[self.entity_description.key] @@ -574,10 +578,10 @@ class HonConfigSwitchEntity(HonEntity, SwitchEntity): return setting.value = setting.min if isinstance(setting, HonParameterRange) else "0" self.coordinator.async_set_updated_data({}) - self.async_write_ha_state() + self.schedule_update_ha_state() @callback def _handle_coordinator_update(self, update: bool = True) -> None: self._attr_is_on = self.is_on if update: - self.async_write_ha_state() + self.schedule_update_ha_state() From d3913a2e2a91ae5d47972fb6bade782d6cc8298a Mon Sep 17 00:00:00 2001 From: Vadym Melnychuk Date: Thu, 2 Apr 2026 13:36:23 +0300 Subject: [PATCH 7/7] removed alias --- custom_components/hon/__init__.py | 11 ++++------- custom_components/hon/binary_sensor.py | 5 +++-- custom_components/hon/button.py | 8 ++++---- custom_components/hon/climate.py | 8 ++++---- custom_components/hon/entity.py | 4 ++-- custom_components/hon/fan.py | 6 +++--- custom_components/hon/light.py | 6 +++--- custom_components/hon/lock.py | 4 ++-- custom_components/hon/number.py | 8 ++++---- custom_components/hon/select.py | 4 ++-- custom_components/hon/sensor.py | 4 ++-- 11 files changed, 33 insertions(+), 35 deletions(-) diff --git a/custom_components/hon/__init__.py b/custom_components/hon/__init__.py index 81b81bb..e29abd7 100644 --- a/custom_components/hon/__init__.py +++ b/custom_components/hon/__init__.py @@ -5,8 +5,8 @@ from typing import Any import voluptuous as vol # type: ignore[import-untyped] from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_EMAIL, CONF_PASSWORD -from homeassistant.core import HomeAssistant as HomeAssistantType from homeassistant.helpers import config_validation as cv, aiohttp_client +from homeassistant.core import HomeAssistant from homeassistant.helpers.update_coordinator import DataUpdateCoordinator from pyhon import Hon @@ -27,7 +27,7 @@ CONFIG_SCHEMA = vol.Schema( ) -async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool: +async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: session = aiohttp_client.async_get_clientsession(hass) if (config_dir := hass.config.config_dir) is None: raise ValueError("Missing Config Dir") @@ -54,14 +54,11 @@ async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool hass.data[DOMAIN][entry.unique_id] = {"hon": hon, "coordinator": coordinator} await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS) - #for platform in PLATFORMS: - # hass.async_create_task( - # hass.config_entries.async_forward_entry_setups(entry, platform) - # ) + return True -async def async_unload_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool: +async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: refresh_token = hass.data[DOMAIN][entry.unique_id]["hon"].api.auth.refresh_token hass.config_entries.async_update_entry( diff --git a/custom_components/hon/binary_sensor.py b/custom_components/hon/binary_sensor.py index 23de62e..33a0526 100644 --- a/custom_components/hon/binary_sensor.py +++ b/custom_components/hon/binary_sensor.py @@ -7,8 +7,9 @@ from homeassistant.components.binary_sensor import ( BinarySensorEntity, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.core import HomeAssistant as HomeAssistantType, callback +from homeassistant.core import callback from homeassistant.helpers.entity_platform import AddEntitiesCallback +from homeassistant.core import HomeAssistant from .const import DOMAIN from .entity import HonEntity @@ -326,7 +327,7 @@ BINARY_SENSORS["WD"] = unique_entities(BINARY_SENSORS["WM"], BINARY_SENSORS["TD" async def async_setup_entry( - hass: HomeAssistantType, entry: ConfigEntry, async_add_entities: AddEntitiesCallback + hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback ) -> None: entities = [] for device in hass.data[DOMAIN][entry.unique_id]["hon"].appliances: diff --git a/custom_components/hon/button.py b/custom_components/hon/button.py index 03e4f5e..4a30ef8 100644 --- a/custom_components/hon/button.py +++ b/custom_components/hon/button.py @@ -4,9 +4,9 @@ from pathlib import Path from homeassistant.components import persistent_notification from homeassistant.components.button import ButtonEntityDescription, ButtonEntity from homeassistant.config_entries import ConfigEntry -from homeassistant.core import HomeAssistant as HomeAssistantType from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity_platform import AddEntitiesCallback +from homeassistant.core import HomeAssistant from pyhon.appliance import HonAppliance from .const import DOMAIN @@ -56,7 +56,7 @@ BUTTONS: dict[str, tuple[ButtonEntityDescription, ...]] = { async def async_setup_entry( - hass: HomeAssistantType, entry: ConfigEntry, async_add_entities: AddEntitiesCallback + hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback ) -> None: entities: list[HonButtonType] = [] for device in hass.data[DOMAIN][entry.unique_id]["hon"].appliances: @@ -88,7 +88,7 @@ class HonButtonEntity(HonEntity, ButtonEntity): class HonDeviceInfo(HonEntity, ButtonEntity): def __init__( - self, hass: HomeAssistantType, entry: ConfigEntry, device: HonAppliance + self, hass: HomeAssistant, entry: ConfigEntry, device: HonAppliance ) -> None: super().__init__(hass, entry, device) @@ -108,7 +108,7 @@ class HonDeviceInfo(HonEntity, ButtonEntity): class HonDataArchive(HonEntity, ButtonEntity): def __init__( - self, hass: HomeAssistantType, entry: ConfigEntry, device: HonAppliance + self, hass: HomeAssistant, entry: ConfigEntry, device: HonAppliance ) -> None: super().__init__(hass, entry, device) diff --git a/custom_components/hon/climate.py b/custom_components/hon/climate.py index 5f574a0..94c03de 100644 --- a/custom_components/hon/climate.py +++ b/custom_components/hon/climate.py @@ -19,7 +19,7 @@ from homeassistant.const import ( ATTR_TEMPERATURE, UnitOfTemperature, ) -from homeassistant.core import HomeAssistant as HomeAssistantType, callback +from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.entity_platform import AddEntitiesCallback from pyhon.appliance import HonAppliance from pyhon.parameter.range import HonParameterRange @@ -103,7 +103,7 @@ CLIMATES: dict[ async def async_setup_entry( - hass: HomeAssistantType, entry: ConfigEntry, async_add_entities: AddEntitiesCallback + hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback ) -> None: entities = [] entity: HonClimateEntity | HonACClimateEntity @@ -129,7 +129,7 @@ class HonACClimateEntity(HonEntity, ClimateEntity): def __init__( self, - hass: HomeAssistantType, + hass: HomeAssistant, entry: ConfigEntry, device: HonAppliance, description: HonACClimateEntityDescription, @@ -298,7 +298,7 @@ class HonClimateEntity(HonEntity, ClimateEntity): def __init__( self, - hass: HomeAssistantType, + hass: HomeAssistant, entry: ConfigEntry, device: HonAppliance, description: HonClimateEntityDescription, diff --git a/custom_components/hon/entity.py b/custom_components/hon/entity.py index 154ce32..18880c9 100644 --- a/custom_components/hon/entity.py +++ b/custom_components/hon/entity.py @@ -1,7 +1,7 @@ from typing import Optional, Any from homeassistant.config_entries import ConfigEntry -from homeassistant.core import HomeAssistant as HomeAssistantType, callback +from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.update_coordinator import ( CoordinatorEntity, @@ -19,7 +19,7 @@ class HonEntity(CoordinatorEntity[DataUpdateCoordinator[dict[str, Any]]]): def __init__( self, - hass: HomeAssistantType, + hass: HomeAssistant, entry: ConfigEntry, device: HonAppliance, description: Optional[HonEntityDescription] = None, diff --git a/custom_components/hon/fan.py b/custom_components/hon/fan.py index 2432b83..f0ac960 100644 --- a/custom_components/hon/fan.py +++ b/custom_components/hon/fan.py @@ -8,7 +8,7 @@ from homeassistant.components.fan import ( FanEntityFeature, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.core import HomeAssistant as HomeAssistantType, callback +from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.util.percentage import ( percentage_to_ranged_value, @@ -35,7 +35,7 @@ FANS: dict[str, tuple[FanEntityDescription, ...]] = { async def async_setup_entry( - hass: HomeAssistantType, entry: ConfigEntry, async_add_entities: AddEntitiesCallback + hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback ) -> None: entities = [] for device in hass.data[DOMAIN][entry.unique_id]["hon"].appliances: @@ -55,7 +55,7 @@ class HonFanEntity(HonEntity, FanEntity): def __init__( self, - hass: HomeAssistantType, + hass: HomeAssistant, entry: ConfigEntry, device: HonAppliance, description: FanEntityDescription, diff --git a/custom_components/hon/light.py b/custom_components/hon/light.py index 840c5d6..a23f781 100644 --- a/custom_components/hon/light.py +++ b/custom_components/hon/light.py @@ -8,7 +8,7 @@ from homeassistant.components.light import ( ATTR_BRIGHTNESS, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.core import HomeAssistant as HomeAssistantType, callback +from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.entity_platform import AddEntitiesCallback from pyhon.appliance import HonAppliance from pyhon.parameter.range import HonParameterRange @@ -52,7 +52,7 @@ LIGHTS: dict[str, tuple[LightEntityDescription, ...]] = { async def async_setup_entry( - hass: HomeAssistantType, entry: ConfigEntry, async_add_entities: AddEntitiesCallback + hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback ) -> None: entities = [] for device in hass.data[DOMAIN][entry.unique_id]["hon"].appliances: @@ -72,7 +72,7 @@ class HonLightEntity(HonEntity, LightEntity): def __init__( self, - hass: HomeAssistantType, + hass: HomeAssistant, entry: ConfigEntry, device: HonAppliance, description: LightEntityDescription, diff --git a/custom_components/hon/lock.py b/custom_components/hon/lock.py index d098ab0..a98aebe 100644 --- a/custom_components/hon/lock.py +++ b/custom_components/hon/lock.py @@ -3,7 +3,7 @@ from typing import Any from homeassistant.components.lock import LockEntity, LockEntityDescription from homeassistant.config_entries import ConfigEntry -from homeassistant.core import HomeAssistant as HomeAssistantType, callback +from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.entity_platform import AddEntitiesCallback from pyhon.parameter.base import HonParameter from pyhon.parameter.range import HonParameterRange @@ -25,7 +25,7 @@ LOCKS: dict[str, tuple[LockEntityDescription, ...]] = { async def async_setup_entry( - hass: HomeAssistantType, entry: ConfigEntry, async_add_entities: AddEntitiesCallback + hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback ) -> None: entities = [] for device in hass.data[DOMAIN][entry.unique_id]["hon"].appliances: diff --git a/custom_components/hon/number.py b/custom_components/hon/number.py index 9edf360..213aa2b 100644 --- a/custom_components/hon/number.py +++ b/custom_components/hon/number.py @@ -9,7 +9,7 @@ from homeassistant.components.number import ( ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import UnitOfTime, UnitOfTemperature -from homeassistant.core import HomeAssistant as HomeAssistantType, callback +from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity_platform import AddEntitiesCallback from pyhon.appliance import HonAppliance @@ -218,7 +218,7 @@ NUMBERS["WD"] = unique_entities(NUMBERS["WM"], NUMBERS["TD"]) async def async_setup_entry( - hass: HomeAssistantType, entry: ConfigEntry, async_add_entities: AddEntitiesCallback + hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback ) -> None: entities = [] entity: HonNumberEntity | HonConfigNumberEntity @@ -241,7 +241,7 @@ class HonNumberEntity(HonEntity, NumberEntity): def __init__( self, - hass: HomeAssistantType, + hass: HomeAssistant, entry: ConfigEntry, device: HonAppliance, description: HonNumberEntityDescription, @@ -300,7 +300,7 @@ class HonConfigNumberEntity(HonEntity, NumberEntity): def __init__( self, - hass: HomeAssistantType, + hass: HomeAssistant, entry: ConfigEntry, device: HonAppliance, description: HonConfigNumberEntityDescription, diff --git a/custom_components/hon/select.py b/custom_components/hon/select.py index 7eb5bbf..9417c63 100644 --- a/custom_components/hon/select.py +++ b/custom_components/hon/select.py @@ -6,7 +6,7 @@ from dataclasses import dataclass from homeassistant.components.select import SelectEntity, SelectEntityDescription from homeassistant.config_entries import ConfigEntry from homeassistant.const import UnitOfTemperature, UnitOfTime, REVOLUTIONS_PER_MINUTE -from homeassistant.core import HomeAssistant as HomeAssistantType, callback +from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -221,7 +221,7 @@ SELECTS["WD"] = unique_entities(SELECTS["WM"], SELECTS["TD"]) async def async_setup_entry( - hass: HomeAssistantType, entry: ConfigEntry, async_add_entities: AddEntitiesCallback + hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback ) -> None: entities = [] entity: HonSelectEntity | HonConfigSelectEntity diff --git a/custom_components/hon/sensor.py b/custom_components/hon/sensor.py index 20ae360..091b49c 100644 --- a/custom_components/hon/sensor.py +++ b/custom_components/hon/sensor.py @@ -21,7 +21,7 @@ from homeassistant.const import ( UnitOfTime, UnitOfTemperature, ) -from homeassistant.core import HomeAssistant as HomeAssistantType, callback +from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity_platform import AddEntitiesCallback from pyhon.attributes import HonAttribute @@ -865,7 +865,7 @@ SENSORS["WD"] = unique_entities(SENSORS["WM"], SENSORS["TD"]) async def async_setup_entry( - hass: HomeAssistantType, entry: ConfigEntry, async_add_entities: AddEntitiesCallback + hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback ) -> None: entities = [] entity: HonSensorEntity | HonConfigSensorEntity