Fix some bugs for hoover appliances, fix #31

This commit is contained in:
Andre Basche 2023-04-24 04:36:14 +02:00
parent 8c1bba2468
commit f1e16312ff
5 changed files with 29 additions and 6 deletions

View File

@ -226,6 +226,7 @@ I moved the api related stuff into the package [pyhOn](https://github.com/Andre0
| Name | Icon | Entity | Key | Auto-Translation |
| --- | --- | --- | --- | --- |
| Anti-Crease | `timer` | `switch` | `startProgram.antiCreaseTime` | ✔ |
| Anti-Crease | `timer` | `switch` | `startProgram.anticrease` | ✔ |
| Delay time | `timer-plus` | `number` | `startProgram.delayTime` | ✔ |
| Dry Time | | `number` | `startProgram.dryTime` | ✔ |
| Dry Time | `timer` | `select` | `startProgram.dryTimeMM` | ✔ |

View File

@ -6,6 +6,6 @@
"documentation": "https://github.com/Andre0512/hon/",
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/Andre0512/hon/issues",
"requirements": ["pyhOn==0.8.6"],
"version": "0.7.0-beta.5"
"requirements": ["pyhOn==0.9.0"],
"version": "0.7.0-beta.6"
}

View File

@ -1,6 +1,8 @@
from __future__ import annotations
from pyhon import Hon
from pyhon.parameter.base import HonParameter
from pyhon.parameter.fixed import HonParameterFixed
from pyhon.parameter.range import HonParameterRange
from homeassistant.components.number import (
@ -179,7 +181,11 @@ class HonNumberEntity(HonEntity, NumberEntity):
return self._device.get(self.entity_description.key)
async def async_set_native_value(self, value: float) -> None:
self._device.settings[self.entity_description.key].value = value
setting = self._device.settings[self.entity_description.key]
if not (
isinstance(setting, HonParameter) or isinstance(setting, HonParameterFixed)
):
setting.value = value
await self.coordinator.async_refresh()
@callback

View File

@ -182,6 +182,7 @@ SENSORS: dict[str, tuple[SensorEntityDescription, ...]] = {
name="Suggested Load",
icon="mdi:weight-kilogram",
entity_category=EntityCategory.CONFIG,
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=UnitOfMass.KILOGRAMS,
translation_key="suggested_load",
),
@ -444,7 +445,9 @@ async def async_setup_entry(hass, entry: ConfigEntry, async_add_entities) -> Non
if descriptions := SENSORS.get(device.appliance_type):
for description in descriptions:
if not device.get(description.key):
if not device.get(description.key) and not device.settings.get(
description.key
):
_LOGGER.warning(
"[%s] Can't setup %s", device.appliance_type, description.key
)
@ -467,9 +470,15 @@ class HonSensorEntity(HonEntity, SensorEntity):
@property
def native_value(self) -> StateType:
return self._device.get(self.entity_description.key, "")
value = self._device.get(self.entity_description.key, "")
if not value and self.entity_description.state_class is not None:
return 0
return value
@callback
def _handle_coordinator_update(self):
self._attr_native_value = self._device.get(self.entity_description.key, "")
value = self._device.get(self.entity_description.key, "")
if not value and self.entity_description.state_class is not None:
self._attr_native_value = 0
self._attr_native_value = value
self.async_write_ha_state()

View File

@ -97,6 +97,13 @@ SWITCHES: dict[str, tuple[HonSwitchEntityDescription, ...]] = {
icon="mdi:timer",
translation_key="anti_crease",
),
HonSwitchEntityDescription(
key="startProgram.anticrease",
name="Anti-Crease",
entity_category=EntityCategory.CONFIG,
icon="mdi:timer",
translation_key="anti_crease",
),
),
"OV": (
HonSwitchEntityDescription(