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 #### Controls
| Name | Icon | Entity | Key | | Name | Icon | Entity | Key |
| --- | --- | --- | --- | | --- | --- | --- | --- |
| Light status | | `light` | `startProgram.lightStatus` | | Hood | `hvac` | `switch` | `startProgram` / `stopProgram` |
| Start Program | `hvac` | `button` | `startProgram` | | Light status | | `light` | `settings.lightStatus` |
| Stop Program | `hvac-off` | `button` | `stopProgram` |
| Wind Speed | | `fan` | `settings.windSpeed` | | Wind Speed | | `fan` | `settings.windSpeed` |
#### Sensors #### Sensors
| Name | Icon | Entity | Key | | Name | Icon | Entity | Key |

View File

@ -35,20 +35,6 @@ BUTTONS: dict[str, tuple[ButtonEntityDescription, ...]] = {
translation_key="stop_program", 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: def __init__(self, hass, entry, device: HonAppliance, description) -> None:
self._attr_supported_features = FanEntityFeature.SET_SPEED self._attr_supported_features = FanEntityFeature.SET_SPEED
self._wind_speed: HonParameterRange = device.settings.get(description.key) 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(".") self._command, self._parameter = description.key.split(".")
super().__init__(hass, entry, device, description) super().__init__(hass, entry, device, description)
@ -118,6 +114,15 @@ class HonFanEntity(HonEntity, FanEntity):
@callback @callback
def _handle_coordinator_update(self, update=True) -> None: def _handle_coordinator_update(self, update=True) -> None:
self._wind_speed = self._device.settings.get(self.entity_description.key) 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 self._attr_percentage = self.percentage
if update: if update:
self.async_write_ha_state() 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": ( "HO": (
LightEntityDescription( LightEntityDescription(
key="startProgram.lightStatus", key="settings.lightStatus",
name="Light status", name="Light status",
translation_key="light", translation_key="light",
), ),
@ -76,8 +76,7 @@ class HonLightEntity(HonEntity, LightEntity):
@property @property
def is_on(self) -> bool: def is_on(self) -> bool:
"""Return true if light is on.""" """Return true if light is on."""
light = self._device.settings.get(self.entity_description.key) return self._device.get(self.entity_description.key.split(".")[-1]) > 0
return light.value != light.min
async def async_turn_on(self, **kwargs: Any) -> None: async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn on or control the light.""" """Turn on or control the light."""
@ -120,3 +119,10 @@ class HonLightEntity(HonEntity, LightEntity):
self._attr_brightness = self.brightness self._attr_brightness = self.brightness
if update: if update:
self.async_write_ha_state() 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", 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": ( "AP": (
HonSwitchEntityDescription( HonSwitchEntityDescription(
key="touchToneStatus", key="touchToneStatus",
@ -438,11 +448,15 @@ class HonControlSwitchEntity(HonEntity, SwitchEntity):
return self._device.get(self.entity_description.key, False) return self._device.get(self.entity_description.key, False)
async def async_turn_on(self, **kwargs: Any) -> None: 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() await self._device.commands[self.entity_description.turn_on_key].send()
self._device.attributes[self.entity_description.key] = True self._device.attributes[self.entity_description.key] = True
self.async_write_ha_state() self.async_write_ha_state()
async def async_turn_off(self, **kwargs: Any) -> None: 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() await self._device.commands[self.entity_description.turn_off_key].send()
self._device.attributes[self.entity_description.key] = False self._device.attributes[self.entity_description.key] = False
self.async_write_ha_state() self.async_write_ha_state()

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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