Improve hood controls

This commit is contained in:
Andre Basche 2023-07-12 00:20:35 +02:00
parent f3325f0ff5
commit fb09c2e559
25 changed files with 93 additions and 25 deletions

View File

@ -247,9 +247,8 @@ For every device exists a button under diagnostics which can be used to log all
#### Controls
| Name | Icon | Entity | Key |
| --- | --- | --- | --- |
| Light status | | `light` | `startProgram.lightStatus` |
| Start Program | `hvac` | `button` | `startProgram` |
| Stop Program | `hvac-off` | `button` | `stopProgram` |
| Hood | `hvac` | `switch` | `startProgram` / `stopProgram` |
| Light status | | `light` | `settings.lightStatus` |
| Wind Speed | | `fan` | `settings.windSpeed` |
#### Sensors
| Name | Icon | Entity | Key |

View File

@ -35,20 +35,6 @@ BUTTONS: dict[str, tuple[ButtonEntityDescription, ...]] = {
translation_key="stop_program",
),
),
"HO": (
ButtonEntityDescription(
key="startProgram",
name="Start Program",
icon="mdi:hvac",
translation_key="start_program",
),
ButtonEntityDescription(
key="stopProgram",
name="Stop Program",
icon="mdi:hvac-off",
translation_key="stop_program",
),
),
}

View File

@ -63,10 +63,6 @@ class HonFanEntity(HonEntity, FanEntity):
def __init__(self, hass, entry, device: HonAppliance, description) -> None:
self._attr_supported_features = FanEntityFeature.SET_SPEED
self._wind_speed: HonParameterRange = device.settings.get(description.key)
self._speed_range = (
int(self._wind_speed.values[1]),
int(self._wind_speed.values[-1]),
)
self._command, self._parameter = description.key.split(".")
super().__init__(hass, entry, device, description)
@ -118,6 +114,15 @@ class HonFanEntity(HonEntity, FanEntity):
@callback
def _handle_coordinator_update(self, update=True) -> None:
self._wind_speed = self._device.settings.get(self.entity_description.key)
if len(self._wind_speed.values) > 1:
self._speed_range = (
int(self._wind_speed.values[1]),
int(self._wind_speed.values[-1]),
)
self._attr_percentage = self.percentage
if update:
self.async_write_ha_state()
@property
def available(self) -> bool:
return super().available and len(self._wind_speed.values) > 1

View File

@ -28,7 +28,7 @@ LIGHTS = {
),
"HO": (
LightEntityDescription(
key="startProgram.lightStatus",
key="settings.lightStatus",
name="Light status",
translation_key="light",
),
@ -76,8 +76,7 @@ class HonLightEntity(HonEntity, LightEntity):
@property
def is_on(self) -> bool:
"""Return true if light is on."""
light = self._device.settings.get(self.entity_description.key)
return light.value != light.min
return self._device.get(self.entity_description.key.split(".")[-1]) > 0
async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn on or control the light."""
@ -120,3 +119,10 @@ class HonLightEntity(HonEntity, LightEntity):
self._attr_brightness = self.brightness
if update:
self.async_write_ha_state()
@property
def available(self) -> bool:
return (
super().available
and len(self._device.settings.get(self.entity_description.key).values) > 1
)

View File

@ -337,6 +337,16 @@ SWITCHES: dict[str, tuple[HonSwitchEntityDescription, ...]] = {
translation_key="holiday_mode",
),
),
"HO": (
HonControlSwitchEntityDescription(
key="onOffStatus",
name="Hood",
icon="mdi:hvac",
turn_on_key="startProgram",
turn_off_key="stopProgram",
translation_key="hood",
),
),
"AP": (
HonSwitchEntityDescription(
key="touchToneStatus",
@ -438,11 +448,15 @@ class HonControlSwitchEntity(HonEntity, SwitchEntity):
return self._device.get(self.entity_description.key, False)
async def async_turn_on(self, **kwargs: Any) -> None:
self._device.sync_command(self.entity_description.turn_on_key, "settings")
await self.coordinator.async_refresh()
await self._device.commands[self.entity_description.turn_on_key].send()
self._device.attributes[self.entity_description.key] = True
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")
await self.coordinator.async_refresh()
await self._device.commands[self.entity_description.turn_off_key].send()
self._device.attributes[self.entity_description.key] = False
self.async_write_ha_state()

View File

@ -1787,6 +1787,9 @@
},
"hygiene": {
"name": "Hygienický plus"
},
"hood": {
"name": "Odsavač par"
}
},
"binary_sensor": {

View File

@ -1787,6 +1787,9 @@
},
"hygiene": {
"name": "Hygiene plus"
},
"hood": {
"name": "Abzugshaube"
}
},
"binary_sensor": {

View File

@ -1787,6 +1787,9 @@
},
"hygiene": {
"name": "Hygiene plus"
},
"hood": {
"name": "Απορροφητήρας"
}
},
"binary_sensor": {

View File

@ -1814,6 +1814,9 @@
},
"hygiene": {
"name": "Hygiene plus"
},
"hood": {
"name": "Hood"
}
},
"binary_sensor": {

View File

@ -1787,6 +1787,9 @@
},
"hygiene": {
"name": "Higiene extra"
},
"hood": {
"name": "Campana extractora"
}
},
"binary_sensor": {

View File

@ -1787,6 +1787,9 @@
},
"hygiene": {
"name": "Hygiène plus"
},
"hood": {
"name": "Hotte"
}
},
"binary_sensor": {

View File

@ -908,6 +908,9 @@
},
"hygiene": {
"name": "היגיינה פלוס"
},
"hood": {
"name": "Hood"
}
},
"binary_sensor": {

View File

@ -1787,6 +1787,9 @@
},
"hygiene": {
"name": "Hygiene Plus"
},
"hood": {
"name": "Napa"
}
},
"binary_sensor": {

View File

@ -1792,6 +1792,9 @@
},
"hygiene": {
"name": "Hygiene plus"
},
"hood": {
"name": "Cappa"
}
},
"binary_sensor": {

View File

@ -1787,6 +1787,9 @@
},
"hygiene": {
"name": "Hygiëne plus"
},
"hood": {
"name": "Afzuigkap"
}
},
"binary_sensor": {

View File

@ -1787,6 +1787,9 @@
},
"hygiene": {
"name": "Higiena plus"
},
"hood": {
"name": "Okap"
}
},
"binary_sensor": {

View File

@ -1787,6 +1787,9 @@
},
"hygiene": {
"name": "Higiene mais"
},
"hood": {
"name": "Exaustor"
}
},
"binary_sensor": {

View File

@ -1787,6 +1787,9 @@
},
"hygiene": {
"name": "Igienizare plus"
},
"hood": {
"name": "Hotă"
}
},
"binary_sensor": {

View File

@ -1787,6 +1787,9 @@
},
"hygiene": {
"name": "Гигиена плюс"
},
"hood": {
"name": "Вытяжка"
}
},
"binary_sensor": {

View File

@ -1787,6 +1787,9 @@
},
"hygiene": {
"name": "Hygiena plus"
},
"hood": {
"name": "Digestor"
}
},
"binary_sensor": {

View File

@ -1787,6 +1787,9 @@
},
"hygiene": {
"name": "Higiena plus"
},
"hood": {
"name": "Kuhinjska napa"
}
},
"binary_sensor": {

View File

@ -1787,6 +1787,9 @@
},
"hygiene": {
"name": "Higijenski plus"
},
"hood": {
"name": "Aspirator"
}
},
"binary_sensor": {

View File

@ -1787,6 +1787,9 @@
},
"hygiene": {
"name": "Hygiene plus"
},
"hood": {
"name": "Davlumbaz"
}
},
"binary_sensor": {

View File

@ -1787,6 +1787,9 @@
},
"hygiene": {
"name": "卫生增强"
},
"hood": {
"name": "机盖"
}
},
"binary_sensor": {

View File

@ -241,6 +241,7 @@ NAMES = {
"refrigerator": "REF.NAME",
"touch_tone": "AP.FOOTER_MENU_MORE.TOUCH_TONE_VOLUME",
"hygiene": "WASHING_CMD&CTRL.PROGRAM_CYCLE_DETAIL_OTHER_OPTIONS.HYGIENE",
"hood": "GLOBALS.APPLIANCES_NAME.HO",
},
"binary_sensor": {
"door_lock": "WASHING_CMD&CTRL.CHECK_UP_RESULTS.DOOR_LOCK",