From cb660fa9e057f5bda170e997b4afd51775706d07 Mon Sep 17 00:00:00 2001 From: Andre Basche Date: Sun, 28 May 2023 07:50:59 +0200 Subject: [PATCH] Add climate entites for fridge #41 --- README.md | 33 +++--- custom_components/hon/climate.py | 123 ++++++++++++++++++++- custom_components/hon/manifest.json | 4 +- custom_components/hon/sensor.py | 1 - custom_components/hon/switch.py | 15 +-- custom_components/hon/translations/cs.json | 27 +++++ custom_components/hon/translations/de.json | 27 +++++ custom_components/hon/translations/el.json | 27 +++++ custom_components/hon/translations/en.json | 27 +++++ custom_components/hon/translations/es.json | 27 +++++ custom_components/hon/translations/fr.json | 27 +++++ custom_components/hon/translations/he.json | 27 +++++ custom_components/hon/translations/hr.json | 27 +++++ custom_components/hon/translations/it.json | 27 +++++ custom_components/hon/translations/nl.json | 27 +++++ custom_components/hon/translations/pl.json | 27 +++++ custom_components/hon/translations/pt.json | 27 +++++ custom_components/hon/translations/ro.json | 27 +++++ custom_components/hon/translations/ru.json | 27 +++++ custom_components/hon/translations/sk.json | 27 +++++ custom_components/hon/translations/sl.json | 27 +++++ custom_components/hon/translations/sr.json | 27 +++++ custom_components/hon/translations/tr.json | 27 +++++ custom_components/hon/translations/zh.json | 27 +++++ info.md | 1 + scripts/generate_translation.py | 39 ++++++- scripts/sensor_docs.py | 15 +-- 27 files changed, 706 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index 8df2315..95cab8d 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,7 @@ Support has been confirmed for these models, but many more will work. Please add - Hoover HFB 6B2S3FX - Hoover HLE C10DCE-80 - Hoover HSOT3161WG +- Hoover HW 68AMC/1-80 - Hoover HWPD 69AMBC/1-S - Hoover HWPS4954DAMR-11 - Hoover NDE H10A2TCE-80 @@ -155,18 +156,18 @@ For every device exists a hidden button which can be used to log all infos of yo #### Controls | Name | Icon | Entity | Key | | --- | --- | --- | --- | -| 10° Heating | `heat-wave` | `switch` | `settings.10degreeHeatingStatus` | +| 10° Heating | `heat-wave` | `switch` | `10degreeHeatingStatus` | | Air Conditioner | `air-conditioner` | `climate` | `settings` | -| Echo | `account-voice` | `switch` | `settings.echoStatus` | -| Eco Mode | | `switch` | `settings.ecoMode` | +| Echo | `account-voice` | `switch` | `echoStatus` | +| Eco Mode | | `switch` | `ecoMode` | | Eco Pilot | `run` | `select` | `settings.humanSensingStatus` | -| Health Mode | `medication-outline` | `switch` | `settings.healthMode` | -| Mute | `volume-off` | `switch` | `settings.muteStatus` | -| Rapid Mode | `run-fast` | `switch` | `settings.rapidMode` | -| Screen Display | `monitor-small` | `switch` | `settings.screenDisplayStatus` | -| Self Cleaning | `air-filter` | `switch` | `settings.selfCleaningStatus` | -| Self Cleaning 56 | `air-filter` | `switch` | `settings.selfCleaning56Status` | -| Silent Sleep | `bed` | `switch` | `settings.silentSleepStatus` | +| Health Mode | `medication-outline` | `switch` | `healthMode` | +| Mute | `volume-off` | `switch` | `muteStatus` | +| Rapid Mode | `run-fast` | `switch` | `rapidMode` | +| Screen Display | `monitor-small` | `switch` | `screenDisplayStatus` | +| Self Cleaning | `air-filter` | `switch` | `selfCleaningStatus` | +| Self Cleaning 56 | `air-filter` | `switch` | `selfCleaning56Status` | +| Silent Sleep | `bed` | `switch` | `silentSleepStatus` | | Target Temperature | `thermometer` | `number` | `settings.tempSel` | #### Sensors | Name | Icon | Entity | Key | @@ -187,7 +188,7 @@ For every device exists a hidden button which can be used to log all infos of yo #### Controls | Name | Icon | Entity | Key | | --- | --- | --- | --- | -| Buzzer Disabled | `volume-off` | `switch` | `settings.buzzerDisabled` | +| Buzzer Disabled | `volume-off` | `switch` | `buzzerDisabled` | | Dish Washer | `dishwasher` | `switch` | `startProgram` / `stopProgram` | #### Configs | Name | Icon | Entity | Key | @@ -272,14 +273,16 @@ For every device exists a hidden button which can be used to log all infos of yo #### Controls | Name | Icon | Entity | Key | | --- | --- | --- | --- | -| Auto-Set Mode | `thermometer-auto` | `switch` | `settings.intelligenceMode` | +| Auto-Set Mode | `thermometer-auto` | `switch` | `intelligenceMode` | +| Freezer | `snowflake-thermometer` | `climate` | `settings.tempSelZ2` | | Freezer Temperature | `thermometer` | `number` | `settings.tempSelZ2` | +| Fridge | `thermometer` | `climate` | `settings.tempSelZ1` | | Fridge Temperature | `thermometer` | `number` | `settings.tempSelZ1` | -| Holiday Mode | `palm-tree` | `switch` | `settings.holidayMode` | +| Holiday Mode | `palm-tree` | `switch` | `holidayMode` | | Program Start | `play` | `button` | `startProgram` | | Program Stop | `stop` | `button` | `stopProgram` | -| Super Cool | `snowflake` | `switch` | `settings.quickModeZ2` | -| Super Freeze | `snowflake-variant` | `switch` | `settings.quickModeZ1` | +| Super Cool | `snowflake` | `switch` | `quickModeZ2` | +| Super Freeze | `snowflake-variant` | `switch` | `quickModeZ1` | #### Configs | Name | Icon | Entity | Key | | --- | --- | --- | --- | diff --git a/custom_components/hon/climate.py b/custom_components/hon/climate.py index 7690e35..9691633 100644 --- a/custom_components/hon/climate.py +++ b/custom_components/hon/climate.py @@ -1,4 +1,5 @@ import logging +from dataclasses import dataclass from homeassistant.components.climate import ( ClimateEntity, @@ -20,6 +21,7 @@ from homeassistant.const import ( TEMP_CELSIUS, ) from homeassistant.core import callback +from pyhon import helper from pyhon.appliance import HonAppliance from .const import HON_HVAC_MODE, HON_FAN, HON_HVAC_PROGRAM, DOMAIN @@ -27,15 +29,40 @@ from .hon import HonEntity _LOGGER = logging.getLogger(__name__) + +@dataclass +class HonACClimateEntityDescription(ClimateEntityDescription): + pass + + +@dataclass +class HonREFClimateEntityDescription(ClimateEntityDescription): + pass + + CLIMATES = { "AC": ( - ClimateEntityDescription( + HonACClimateEntityDescription( key="settings", name="Air Conditioner", icon="mdi:air-conditioner", translation_key="air_conditioner", ), ), + "REF": ( + HonREFClimateEntityDescription( + key="settings.tempSelZ1", + name="Fridge", + icon="mdi:thermometer", + translation_key="fridge", + ), + HonREFClimateEntityDescription( + key="settings.tempSelZ2", + name="Freezer", + icon="mdi:snowflake-thermometer", + translation_key="freezer", + ), + ), } @@ -43,15 +70,22 @@ async def async_setup_entry(hass, entry: ConfigEntry, async_add_entities) -> Non entities = [] for device in hass.data[DOMAIN][entry.unique_id].appliances: for description in CLIMATES.get(device.appliance_type, []): - if description.key not in list(device.commands): + if isinstance(description, HonACClimateEntityDescription): + if description.key not in list(device.commands): + continue + entity = HonACClimateEntity(hass, entry, device, description) + elif isinstance(description, HonREFClimateEntityDescription): + if description.key not in device.available_settings: + continue + entity = HonREFClimateEntity(hass, entry, device, description) + else: continue - entity = HonClimateEntity(hass, entry, device, description) await entity.coordinator.async_config_entry_first_refresh() entities.append(entity) async_add_entities(entities) -class HonClimateEntity(HonEntity, ClimateEntity): +class HonACClimateEntity(HonEntity, ClimateEntity): def __init__(self, hass, entry, device: HonAppliance, description) -> None: super().__init__(hass, entry, device, description) @@ -81,6 +115,10 @@ class HonClimateEntity(HonEntity, ClimateEntity): self._handle_coordinator_update(update=False) async def async_set_hvac_mode(self, hvac_mode): + if self._device.get("onOffStatus") == "0": + self._attr_hvac_mode = HVACMode.OFF + else: + self._attr_hvac_mode = HON_HVAC_MODE[self._device.get("machMode")] if hvac_mode == HVACMode.OFF: await self._device.commands["stopProgram"].send() else: @@ -129,7 +167,7 @@ class HonClimateEntity(HonEntity, ClimateEntity): if self._device.get("onOffStatus") == "0": self._attr_hvac_mode = HVACMode.OFF else: - self._attr_hvac_mode = HON_HVAC_MODE[self._device.get("machMode") or "0"] + self._attr_hvac_mode = HON_HVAC_MODE[self._device.get("machMode")] self._attr_fan_mode = HON_FAN[self._device.get("windSpeed")] @@ -145,3 +183,78 @@ class HonClimateEntity(HonEntity, ClimateEntity): self._attr_swing_mode = SWING_OFF if update: self.async_write_ha_state() + + +class HonREFClimateEntity(HonEntity, ClimateEntity): + def __init__(self, hass, entry, device: HonAppliance, description) -> None: + super().__init__(hass, entry, device, description) + + self._attr_temperature_unit = TEMP_CELSIUS + self._attr_target_temperature_step = PRECISION_WHOLE + self._attr_max_temp = device.settings[description.key].max + self._attr_min_temp = device.settings[description.key].min + + self._attr_hvac_modes = [HVACMode.COOL] + self._attr_supported_features = ( + ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.PRESET_MODE + ) + + self._handle_coordinator_update(update=False) + + modes = ["no_mode"] + for mode, data in device.commands["startProgram"].categories.items(): + if zone := data.parameters.get("zone"): + if self.entity_description.name.lower() in zone.values: + modes.append(mode) + self._attr_preset_modes = modes + + @property + def target_temperature(self) -> int | None: + """Return the temperature we try to reach.""" + return int(self._device.get(self.entity_description.key)) + + @property + def current_temperature(self) -> int | None: + """Return the current temperature.""" + temp_key = self.entity_description.key.split(".")[-1].replace("Sel", "") + return int(self._device.get(temp_key)) + + async def async_set_temperature(self, **kwargs): + if (temperature := kwargs.get(ATTR_TEMPERATURE)) is None: + return False + self._device.settings[self.entity_description.key].value = str(int(temperature)) + await self._device.commands["settings"].send() + self.async_write_ha_state() + + @property + def preset_mode(self) -> str | None: + """Return the current Preset for this channel.""" + return self._device.get(f"mode{self.entity_description.key[-2:]}", "no_mode") + + async def async_set_preset_mode(self, preset_mode: str) -> None: + """Set the new preset mode.""" + if preset_mode == "no_mode": + self._device.sync_command("stopProgram", "settings") + await self.coordinator.async_refresh() + await self._device.commands["stopProgram"].send() + else: + self._device.settings["startProgram.program"].value = preset_mode + self._device.settings[ + "startProgram.zone" + ].value = self.entity_description.name.lower() + self._device.sync_command("startProgram", "settings") + await self.coordinator.async_refresh() + await self._device.commands["startProgram"].send() + self.async_write_ha_state() + + @callback + def _handle_coordinator_update(self, update=True) -> None: + self._attr_target_temperature = int( + float(self._device.get(self.entity_description.key)) + ) + temp_key = self.entity_description.key.split(".")[-1].replace("Sel", "") + self._attr_current_temperature = int(self._device.get(temp_key)) + + self._attr_hvac_mode = HVACMode.COOL + if update: + self.async_write_ha_state() diff --git a/custom_components/hon/manifest.json b/custom_components/hon/manifest.json index a07b706..ead2196 100644 --- a/custom_components/hon/manifest.json +++ b/custom_components/hon/manifest.json @@ -9,7 +9,7 @@ "iot_class": "cloud_polling", "issue_tracker": "https://github.com/Andre0512/hon/issues", "requirements": [ - "pyhOn==0.11.1" + "pyhOn==0.11.2" ], - "version": "0.8.0-beta.5" + "version": "0.8.0-beta.6" } diff --git a/custom_components/hon/sensor.py b/custom_components/hon/sensor.py index 8ceba4a..838cde1 100644 --- a/custom_components/hon/sensor.py +++ b/custom_components/hon/sensor.py @@ -543,7 +543,6 @@ class HonConfigSensorEntity(HonEntity, SensorEntity): value = self._device.settings.get(self.entity_description.key, None) if self.entity_description.state_class is not None: if value and value.value: - print(value.value, type(value.value)) self._attr_native_value = ( float(value.value) if "." in str(value.value) else int(value.value) ) diff --git a/custom_components/hon/switch.py b/custom_components/hon/switch.py index 9c0e9e1..01d3f81 100644 --- a/custom_components/hon/switch.py +++ b/custom_components/hon/switch.py @@ -344,8 +344,9 @@ async def async_setup_entry(hass, entry: ConfigEntry, async_add_entities) -> Non continue entity = HonControlSwitchEntity(hass, entry, device, description) elif isinstance(description, HonSwitchEntityDescription): - if description.key not in device.available_settings or not device.get( - description.key + if ( + f"settings.{description.key}" not in device.available_settings + or not device.get(description.key) ): continue entity = HonSwitchEntity(hass, entry, device, description) @@ -366,7 +367,7 @@ class HonSwitchEntity(HonEntity, SwitchEntity): return self._device.get(self.entity_description.key, "0") == "1" async def async_turn_on(self, **kwargs: Any) -> None: - setting = self._device.settings[self.entity_description.key] + setting = self._device.settings[f"settings.{self.entity_description.key}"] if type(setting) == HonParameter: return setting.value = setting.max if isinstance(setting, HonParameterRange) else "1" @@ -375,7 +376,7 @@ class HonSwitchEntity(HonEntity, SwitchEntity): await self.coordinator.async_refresh() async def async_turn_off(self, **kwargs: Any) -> None: - setting = self._device.settings[self.entity_description.key] + setting = self._device.settings[f"settings.{self.entity_description.key}"] if type(setting) == HonParameter: return setting.value = setting.min if isinstance(setting, HonParameterRange) else "0" @@ -431,9 +432,9 @@ class HonConfigSwitchEntity(HonEntity, SwitchEntity): """Return True if entity is on.""" setting = self._device.settings[self.entity_description.key] return ( - setting.value == "1" - or hasattr(setting, "min") - and setting.value != setting.min + setting.value != setting.min + if hasattr(setting, "min") + else setting.value == "1" ) async def async_turn_on(self, **kwargs: Any) -> None: diff --git a/custom_components/hon/translations/cs.json b/custom_components/hon/translations/cs.json index ec0f574..a1bffee 100644 --- a/custom_components/hon/translations/cs.json +++ b/custom_components/hon/translations/cs.json @@ -1330,6 +1330,33 @@ "climate": { "air_conditioner": { "name": "Klimatizační jednotka" + }, + "fridge": { + "name": "Chladnička", + "state_attributes": { + "preset_mode": { + "name": "Režimy chladničky", + "state": { + "auto_set": "Automatické nastavení", + "super_cool": "Super Cool", + "holiday": "Holiday", + "no_mode": "Není vybrán žádný režim" + } + } + } + }, + "freezer": { + "name": "Mraznička", + "state_attributes": { + "preset_mode": { + "name": "Režimy mrazničky", + "state": { + "auto_set": "Automatické nastavení", + "super_freeze": "Super Freeze", + "no_mode": "Není vybrán žádný režim" + } + } + } } } }, diff --git a/custom_components/hon/translations/de.json b/custom_components/hon/translations/de.json index d8068b4..8384518 100644 --- a/custom_components/hon/translations/de.json +++ b/custom_components/hon/translations/de.json @@ -1330,6 +1330,33 @@ "climate": { "air_conditioner": { "name": "Klimaanlage" + }, + "fridge": { + "name": "Kühlschrank", + "state_attributes": { + "preset_mode": { + "name": "Kühlschrank-Modi", + "state": { + "auto_set": "Auto-Set", + "super_cool": "Super Cool", + "holiday": "Holiday", + "no_mode": "Kein Modus ausgewählt" + } + } + } + }, + "freezer": { + "name": "Gefrierschrank", + "state_attributes": { + "preset_mode": { + "name": "Gefrierschrank-Modi", + "state": { + "auto_set": "Auto-Set", + "super_freeze": "Super Freeze", + "no_mode": "Kein Modus ausgewählt" + } + } + } } } }, diff --git a/custom_components/hon/translations/el.json b/custom_components/hon/translations/el.json index e6d6f29..679e40f 100644 --- a/custom_components/hon/translations/el.json +++ b/custom_components/hon/translations/el.json @@ -1330,6 +1330,33 @@ "climate": { "air_conditioner": { "name": "Κλιματιστικό" + }, + "fridge": { + "name": "Ψυγείο", + "state_attributes": { + "preset_mode": { + "name": "Λειτουργίες ψυγείου", + "state": { + "auto_set": "Αυτόματη ρύθμιση", + "super_cool": "Super Cool", + "holiday": "Holiday", + "no_mode": "Δεν επιλέχθηκε λειτουργία" + } + } + } + }, + "freezer": { + "name": "Καταψύκτης", + "state_attributes": { + "preset_mode": { + "name": "Λειτουργίες κατάψυξης", + "state": { + "auto_set": "Αυτόματη ρύθμιση", + "super_freeze": "Super Freeze", + "no_mode": "Δεν επιλέχθηκε λειτουργία" + } + } + } } } }, diff --git a/custom_components/hon/translations/en.json b/custom_components/hon/translations/en.json index 9616ad5..9e73857 100644 --- a/custom_components/hon/translations/en.json +++ b/custom_components/hon/translations/en.json @@ -1394,6 +1394,33 @@ "climate": { "air_conditioner": { "name": "Air conditioner" + }, + "fridge": { + "name": "Fridge", + "state_attributes": { + "preset_mode": { + "name": "Fridge modes", + "state": { + "auto_set": "Auto-Set", + "super_cool": "Super Cool", + "holiday": "Holiday", + "no_mode": "No mode selected" + } + } + } + }, + "freezer": { + "name": "Freezer", + "state_attributes": { + "preset_mode": { + "name": "Freezer modes", + "state": { + "auto_set": "Auto-Set", + "super_freeze": "Super Freeze", + "no_mode": "No mode selected" + } + } + } } } } diff --git a/custom_components/hon/translations/es.json b/custom_components/hon/translations/es.json index 37e1747..3fd9436 100644 --- a/custom_components/hon/translations/es.json +++ b/custom_components/hon/translations/es.json @@ -1330,6 +1330,33 @@ "climate": { "air_conditioner": { "name": "Aire acondicionado" + }, + "fridge": { + "name": "Frigorífico", + "state_attributes": { + "preset_mode": { + "name": "Modos de frigorífico", + "state": { + "auto_set": "Auto-Set", + "super_cool": "Super Cool", + "holiday": "Holiday", + "no_mode": "No se ha seleccionado ningún modo" + } + } + } + }, + "freezer": { + "name": "Congelador", + "state_attributes": { + "preset_mode": { + "name": "Modos congelador", + "state": { + "auto_set": "Auto-Set", + "super_freeze": "Super Freeze", + "no_mode": "No se ha seleccionado ningún modo" + } + } + } } } }, diff --git a/custom_components/hon/translations/fr.json b/custom_components/hon/translations/fr.json index 89f8ebd..e9a6d70 100644 --- a/custom_components/hon/translations/fr.json +++ b/custom_components/hon/translations/fr.json @@ -1330,6 +1330,33 @@ "climate": { "air_conditioner": { "name": "Climatiseur" + }, + "fridge": { + "name": "Réfrigérateur", + "state_attributes": { + "preset_mode": { + "name": "Modes réfrigérateur", + "state": { + "auto_set": "Réglage automatique", + "super_cool": "Super Cool", + "holiday": "Holiday", + "no_mode": "Aucun mode sélectionné" + } + } + } + }, + "freezer": { + "name": "Congélateur", + "state_attributes": { + "preset_mode": { + "name": "Modes congélateur", + "state": { + "auto_set": "Réglage automatique", + "super_freeze": "Super Freeze", + "no_mode": "Aucun mode sélectionné" + } + } + } } } }, diff --git a/custom_components/hon/translations/he.json b/custom_components/hon/translations/he.json index 32370f7..57754e5 100644 --- a/custom_components/hon/translations/he.json +++ b/custom_components/hon/translations/he.json @@ -778,6 +778,33 @@ "climate": { "air_conditioner": { "name": "Air conditioner" + }, + "fridge": { + "name": "Fridge", + "state_attributes": { + "preset_mode": { + "name": "Fridge modes", + "state": { + "auto_set": "Auto-Set", + "super_cool": "Super Cool", + "holiday": "Holiday", + "no_mode": "No mode selected" + } + } + } + }, + "freezer": { + "name": "Freezer", + "state_attributes": { + "preset_mode": { + "name": "Freezer modes", + "state": { + "auto_set": "Auto-Set", + "super_freeze": "Super Freeze", + "no_mode": "No mode selected" + } + } + } } } }, diff --git a/custom_components/hon/translations/hr.json b/custom_components/hon/translations/hr.json index ad83654..21f0ee6 100644 --- a/custom_components/hon/translations/hr.json +++ b/custom_components/hon/translations/hr.json @@ -1330,6 +1330,33 @@ "climate": { "air_conditioner": { "name": "Klimatizacijski uređaj" + }, + "fridge": { + "name": "Hladnjak", + "state_attributes": { + "preset_mode": { + "name": "Načini rada za hladnjak", + "state": { + "auto_set": "Automatsko postavljanje", + "super_cool": "Super Cool", + "holiday": "Holiday", + "no_mode": "Nije odabran način rada" + } + } + } + }, + "freezer": { + "name": "Zamrzivač", + "state_attributes": { + "preset_mode": { + "name": "Načini rada za zamrzavanje", + "state": { + "auto_set": "Automatsko postavljanje", + "super_freeze": "Super Freeze", + "no_mode": "Nije odabran način rada" + } + } + } } } }, diff --git a/custom_components/hon/translations/it.json b/custom_components/hon/translations/it.json index aee11ae..566185a 100644 --- a/custom_components/hon/translations/it.json +++ b/custom_components/hon/translations/it.json @@ -1382,6 +1382,33 @@ "climate": { "air_conditioner": { "name": "Condizionatore" + }, + "fridge": { + "name": "Frigorifero", + "state_attributes": { + "preset_mode": { + "name": "Modalità del frigorifero", + "state": { + "auto_set": "Impostazione automatica", + "super_cool": "Super Cool", + "holiday": "Holiday", + "no_mode": "Nessuna modalità selezionata" + } + } + } + }, + "freezer": { + "name": "Congelatore", + "state_attributes": { + "preset_mode": { + "name": "Modalità del congelatore", + "state": { + "auto_set": "Impostazione automatica", + "super_freeze": "Super Freeze", + "no_mode": "Nessuna modalità selezionata" + } + } + } } } } diff --git a/custom_components/hon/translations/nl.json b/custom_components/hon/translations/nl.json index b5f63e1..4da4450 100644 --- a/custom_components/hon/translations/nl.json +++ b/custom_components/hon/translations/nl.json @@ -1330,6 +1330,33 @@ "climate": { "air_conditioner": { "name": "Airconditioner" + }, + "fridge": { + "name": "Koelkast", + "state_attributes": { + "preset_mode": { + "name": "Koelkastmodi", + "state": { + "auto_set": "Automatisch instellen", + "super_cool": "Super Cool", + "holiday": "Holiday", + "no_mode": "Geen modus geselecteerd" + } + } + } + }, + "freezer": { + "name": "Vriezer", + "state_attributes": { + "preset_mode": { + "name": "Vriezermodi", + "state": { + "auto_set": "Automatisch instellen", + "super_freeze": "Super Freeze", + "no_mode": "Geen modus geselecteerd" + } + } + } } } }, diff --git a/custom_components/hon/translations/pl.json b/custom_components/hon/translations/pl.json index 1abd892..d567c16 100644 --- a/custom_components/hon/translations/pl.json +++ b/custom_components/hon/translations/pl.json @@ -1330,6 +1330,33 @@ "climate": { "air_conditioner": { "name": "Klimatyzator" + }, + "fridge": { + "name": "Lodówka", + "state_attributes": { + "preset_mode": { + "name": "Tryby pracy lodówki", + "state": { + "auto_set": "Ustawianie automatyczne", + "super_cool": "Super Cool", + "holiday": "Holiday", + "no_mode": "Nie wybrano żadnego trybu" + } + } + } + }, + "freezer": { + "name": "Zamrażarka", + "state_attributes": { + "preset_mode": { + "name": "Tryby pracy zamrażarki", + "state": { + "auto_set": "Ustawianie automatyczne", + "super_freeze": "Super Freeze", + "no_mode": "Nie wybrano żadnego trybu" + } + } + } } } }, diff --git a/custom_components/hon/translations/pt.json b/custom_components/hon/translations/pt.json index 12ed37e..c0194a8 100644 --- a/custom_components/hon/translations/pt.json +++ b/custom_components/hon/translations/pt.json @@ -1330,6 +1330,33 @@ "climate": { "air_conditioner": { "name": "Ar Condicionado" + }, + "fridge": { + "name": "Frigorífico", + "state_attributes": { + "preset_mode": { + "name": "Modos do frigorífico", + "state": { + "auto_set": "Ajuste automático", + "super_cool": "Super Cool", + "holiday": "Holiday", + "no_mode": "Nenhum modo selecionado" + } + } + } + }, + "freezer": { + "name": "Congelador", + "state_attributes": { + "preset_mode": { + "name": "Modos do congelador", + "state": { + "auto_set": "Ajuste automático", + "super_freeze": "Super Freeze", + "no_mode": "Nenhum modo selecionado" + } + } + } } } }, diff --git a/custom_components/hon/translations/ro.json b/custom_components/hon/translations/ro.json index f8f8329..2013abf 100644 --- a/custom_components/hon/translations/ro.json +++ b/custom_components/hon/translations/ro.json @@ -1330,6 +1330,33 @@ "climate": { "air_conditioner": { "name": "Aer condiționat" + }, + "fridge": { + "name": "Frigider", + "state_attributes": { + "preset_mode": { + "name": "Moduri frigider", + "state": { + "auto_set": "Setare automată", + "super_cool": "Super Cool", + "holiday": "Holiday", + "no_mode": "Niciun mod selectat" + } + } + } + }, + "freezer": { + "name": "Congelator", + "state_attributes": { + "preset_mode": { + "name": "Moduri de congelare", + "state": { + "auto_set": "Setare automată", + "super_freeze": "Super Freeze", + "no_mode": "Niciun mod selectat" + } + } + } } } }, diff --git a/custom_components/hon/translations/ru.json b/custom_components/hon/translations/ru.json index 0b7c819..9a9b6e0 100644 --- a/custom_components/hon/translations/ru.json +++ b/custom_components/hon/translations/ru.json @@ -1330,6 +1330,33 @@ "climate": { "air_conditioner": { "name": "Кондиционер воздуха" + }, + "fridge": { + "name": "Холодильник", + "state_attributes": { + "preset_mode": { + "name": "Режимы холодильника", + "state": { + "auto_set": "Автоматическая установка", + "super_cool": "Super Cool", + "holiday": "Holiday", + "no_mode": "Режим не выбран" + } + } + } + }, + "freezer": { + "name": "Морозильник", + "state_attributes": { + "preset_mode": { + "name": "Режимы морозильного отделения", + "state": { + "auto_set": "Автоматическая установка", + "super_freeze": "Super Freeze", + "no_mode": "Режим не выбран" + } + } + } } } }, diff --git a/custom_components/hon/translations/sk.json b/custom_components/hon/translations/sk.json index e883362..d5c98b3 100644 --- a/custom_components/hon/translations/sk.json +++ b/custom_components/hon/translations/sk.json @@ -1330,6 +1330,33 @@ "climate": { "air_conditioner": { "name": "Klimatizácia" + }, + "fridge": { + "name": "Chladnička", + "state_attributes": { + "preset_mode": { + "name": "Režimy chladničky", + "state": { + "auto_set": "Automatické nastavenie", + "super_cool": "Super Cool", + "holiday": "Holiday", + "no_mode": "Nie je vybraný žiadny režim" + } + } + } + }, + "freezer": { + "name": "Mraznička", + "state_attributes": { + "preset_mode": { + "name": "Režimy mrazničky", + "state": { + "auto_set": "Automatické nastavenie", + "super_freeze": "Super Freeze", + "no_mode": "Nie je vybraný žiadny režim" + } + } + } } } }, diff --git a/custom_components/hon/translations/sl.json b/custom_components/hon/translations/sl.json index eb5dbab..d8837bf 100644 --- a/custom_components/hon/translations/sl.json +++ b/custom_components/hon/translations/sl.json @@ -1330,6 +1330,33 @@ "climate": { "air_conditioner": { "name": "Klimatska naprava" + }, + "fridge": { + "name": "Hladilnik", + "state_attributes": { + "preset_mode": { + "name": "Načini hladilnika", + "state": { + "auto_set": "Samodejna nastavitev", + "super_cool": "Super Cool", + "holiday": "Holiday", + "no_mode": "Izbran ni noben način" + } + } + } + }, + "freezer": { + "name": "Zamrzovalnik", + "state_attributes": { + "preset_mode": { + "name": "Načini zamrzovalnika", + "state": { + "auto_set": "Samodejna nastavitev", + "super_freeze": "Super Freeze", + "no_mode": "Izbran ni noben način" + } + } + } } } }, diff --git a/custom_components/hon/translations/sr.json b/custom_components/hon/translations/sr.json index 18694e1..c33a825 100644 --- a/custom_components/hon/translations/sr.json +++ b/custom_components/hon/translations/sr.json @@ -1330,6 +1330,33 @@ "climate": { "air_conditioner": { "name": "Klima uređaj" + }, + "fridge": { + "name": "Frižider", + "state_attributes": { + "preset_mode": { + "name": "Režimi frižidera", + "state": { + "auto_set": "Automatsko podešavanje", + "super_cool": "Super Cool", + "holiday": "Holiday", + "no_mode": "Nije izabran nijedan režim" + } + } + } + }, + "freezer": { + "name": "Zamrzivač", + "state_attributes": { + "preset_mode": { + "name": "Režimi zamrzivača", + "state": { + "auto_set": "Automatsko podešavanje", + "super_freeze": "Super Freeze", + "no_mode": "Nije izabran nijedan režim" + } + } + } } } }, diff --git a/custom_components/hon/translations/tr.json b/custom_components/hon/translations/tr.json index 32654c7..62e9eff 100644 --- a/custom_components/hon/translations/tr.json +++ b/custom_components/hon/translations/tr.json @@ -1330,6 +1330,33 @@ "climate": { "air_conditioner": { "name": "Klima" + }, + "fridge": { + "name": "Buzdolabı", + "state_attributes": { + "preset_mode": { + "name": "Buzdolabı modları", + "state": { + "auto_set": "Otomatik Ayarla", + "super_cool": "Super Cool", + "holiday": "Holiday", + "no_mode": "Hiç mod seçilmedi" + } + } + } + }, + "freezer": { + "name": "Dondurucu", + "state_attributes": { + "preset_mode": { + "name": "Dondurucu modları", + "state": { + "auto_set": "Otomatik Ayarla", + "super_freeze": "Super Freeze", + "no_mode": "Hiç mod seçilmedi" + } + } + } } } }, diff --git a/custom_components/hon/translations/zh.json b/custom_components/hon/translations/zh.json index 4cf64bb..4dd374e 100644 --- a/custom_components/hon/translations/zh.json +++ b/custom_components/hon/translations/zh.json @@ -1330,6 +1330,33 @@ "climate": { "air_conditioner": { "name": "空调" + }, + "fridge": { + "name": "冰箱", + "state_attributes": { + "preset_mode": { + "name": "冰箱模式", + "state": { + "auto_set": "自动设置", + "super_cool": "Super Cool", + "holiday": "Holiday", + "no_mode": "未选择模式" + } + } + } + }, + "freezer": { + "name": "冷藏箱", + "state_attributes": { + "preset_mode": { + "name": "冷藏室模式", + "state": { + "auto_set": "自动设置", + "super_freeze": "Super Freeze", + "no_mode": "未选择模式" + } + } + } } } }, diff --git a/info.md b/info.md index 07cb11c..ae81957 100644 --- a/info.md +++ b/info.md @@ -73,6 +73,7 @@ Support has been confirmed for these models, but many more will work. Please add - Hoover HFB 6B2S3FX - Hoover HLE C10DCE-80 - Hoover HSOT3161WG +- Hoover HW 68AMC/1-80 - Hoover HWPD 69AMBC/1-S - Hoover HWPS4954DAMR-11 - Hoover NDE H10A2TCE-80 diff --git a/scripts/generate_translation.py b/scripts/generate_translation.py index 2b068b0..c437420 100755 --- a/scripts/generate_translation.py +++ b/scripts/generate_translation.py @@ -44,6 +44,30 @@ PROGRAMS = { }, } +CLIMATE = { + "fridge": { + "preset_mode": { + "name": "REF_CMD&CTRL.MODE_SELECTION_DRAWER_FRIDGE.FRIDGE_MODE_TITLE", + "state": { + "auto_set": "REF_CMD&CTRL.MODALITIES.ECO", + "super_cool": "REF_CMD&CTRL.MODALITIES.SUPER_COOL", + "holiday": "REF_CMD&CTRL.MODALITIES.BACK_FROM_HOLIDAY", + "no_mode": "REF_CMD&CTRL.MODALITIES.NO_MODE_SELECTED", + }, + } + }, + "freezer": { + "preset_mode": { + "name": "REF_CMD&CTRL.MODE_SELECTION_DRAWER_FREEZER.FREEZER_MODE_TITLE", + "state": { + "auto_set": "REF_CMD&CTRL.MODALITIES.ECO", + "super_freeze": "REF_CMD&CTRL.MODALITIES.SHOCK_FREEZE", + "no_mode": "REF_CMD&CTRL.MODALITIES.NO_MODE_SELECTED", + }, + } + }, +} + NAMES = { "switch": { "anti_crease": "HDRY_CMD&CTRL.PROGRAM_CYCLE_DETAIL.ANTICREASE_TITLE", @@ -197,7 +221,11 @@ NAMES = { "freezer_temp_sel": ["OV.COMMON.GOAL_TEMPERATURE", "REF.ZONES.FREEZER"], "fridge_temp_sel": ["OV.COMMON.GOAL_TEMPERATURE", "REF.ZONES.FRIDGE"], }, - "climate": {"air_conditioner": "GLOBALS.APPLIANCES_NAME.AC"}, + "climate": { + "air_conditioner": "GLOBALS.APPLIANCES_NAME.AC", + "fridge": "REF.ZONES.FRIDGE", + "freezer": "REF.ZONES.FREEZER", + }, } @@ -298,6 +326,15 @@ def main(): for name, key in data.items(): select = old.setdefault("entity", {}).setdefault(entity, {}) select.setdefault(name, {})["name"] = load_key(key, original, fallback) + for name, modes in CLIMATE.items(): + climate = old.setdefault("entity", {}).setdefault("climate", {}) + attr = climate.setdefault(name, {}).setdefault("state_attributes", {}) + for mode, data in modes.items(): + mode_name = load_key(data["name"], original, fallback) + attr.setdefault(mode, {})["name"] = mode_name + for state, key in data["state"].items(): + mode_state = load_key(key, original, fallback) + attr[mode].setdefault("state", {})[state] = mode_state translate_login(old, original, fallback) save_json(base_path / f"{language}.json", old) diff --git a/scripts/sensor_docs.py b/scripts/sensor_docs.py index 022027c..655dbf6 100755 --- a/scripts/sensor_docs.py +++ b/scripts/sensor_docs.py @@ -14,7 +14,11 @@ from custom_components.hon.climate import CLIMATES from custom_components.hon.number import NUMBERS from custom_components.hon.select import SELECTS from custom_components.hon.sensor import SENSORS -from custom_components.hon.switch import SWITCHES, HonSwitchEntityDescription +from custom_components.hon.switch import ( + SWITCHES, + HonControlSwitchEntityDescription, + HonSwitchEntityDescription, +) APPLIANCES = { "AC": "Air conditioner", @@ -50,11 +54,7 @@ result = {} for entity_type, appliances in entities.items(): for appliance, data in appliances.items(): for entity in data: - if ( - isinstance(entity, HonSwitchEntityDescription) - and entity.entity_category != "config" - and "settings." not in entity.key - ): + if isinstance(entity, HonControlSwitchEntityDescription): key = f"{entity.turn_on_key}` / `{entity.turn_off_key}" else: key = entity.key @@ -62,7 +62,8 @@ for entity_type, appliances in entities.items(): category = ( "control" if entity.key.startswith("settings") - or hasattr(entity, "turn_on_key") + or isinstance(entity, HonSwitchEntityDescription) + or isinstance(entity, HonControlSwitchEntityDescription) or entity_type in ["button", "climate"] else "sensor" )