mirror of
https://github.com/Andre0512/hon.git
synced 2024-12-22 18:55:31 +00:00
Fix some bugs for hoover appliances, fix #31
This commit is contained in:
parent
8c1bba2468
commit
f1e16312ff
|
@ -226,6 +226,7 @@ I moved the api related stuff into the package [pyhOn](https://github.com/Andre0
|
||||||
| Name | Icon | Entity | Key | Auto-Translation |
|
| Name | Icon | Entity | Key | Auto-Translation |
|
||||||
| --- | --- | --- | --- | --- |
|
| --- | --- | --- | --- | --- |
|
||||||
| Anti-Crease | `timer` | `switch` | `startProgram.antiCreaseTime` | ✔ |
|
| Anti-Crease | `timer` | `switch` | `startProgram.antiCreaseTime` | ✔ |
|
||||||
|
| Anti-Crease | `timer` | `switch` | `startProgram.anticrease` | ✔ |
|
||||||
| Delay time | `timer-plus` | `number` | `startProgram.delayTime` | ✔ |
|
| Delay time | `timer-plus` | `number` | `startProgram.delayTime` | ✔ |
|
||||||
| Dry Time | | `number` | `startProgram.dryTime` | ✔ |
|
| Dry Time | | `number` | `startProgram.dryTime` | ✔ |
|
||||||
| Dry Time | `timer` | `select` | `startProgram.dryTimeMM` | ✔ |
|
| Dry Time | `timer` | `select` | `startProgram.dryTimeMM` | ✔ |
|
||||||
|
|
|
@ -6,6 +6,6 @@
|
||||||
"documentation": "https://github.com/Andre0512/hon/",
|
"documentation": "https://github.com/Andre0512/hon/",
|
||||||
"iot_class": "cloud_polling",
|
"iot_class": "cloud_polling",
|
||||||
"issue_tracker": "https://github.com/Andre0512/hon/issues",
|
"issue_tracker": "https://github.com/Andre0512/hon/issues",
|
||||||
"requirements": ["pyhOn==0.8.6"],
|
"requirements": ["pyhOn==0.9.0"],
|
||||||
"version": "0.7.0-beta.5"
|
"version": "0.7.0-beta.6"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from pyhon import Hon
|
from pyhon import Hon
|
||||||
|
from pyhon.parameter.base import HonParameter
|
||||||
|
from pyhon.parameter.fixed import HonParameterFixed
|
||||||
from pyhon.parameter.range import HonParameterRange
|
from pyhon.parameter.range import HonParameterRange
|
||||||
|
|
||||||
from homeassistant.components.number import (
|
from homeassistant.components.number import (
|
||||||
|
@ -179,7 +181,11 @@ class HonNumberEntity(HonEntity, NumberEntity):
|
||||||
return self._device.get(self.entity_description.key)
|
return self._device.get(self.entity_description.key)
|
||||||
|
|
||||||
async def async_set_native_value(self, value: float) -> None:
|
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()
|
await self.coordinator.async_refresh()
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
|
|
|
@ -182,6 +182,7 @@ SENSORS: dict[str, tuple[SensorEntityDescription, ...]] = {
|
||||||
name="Suggested Load",
|
name="Suggested Load",
|
||||||
icon="mdi:weight-kilogram",
|
icon="mdi:weight-kilogram",
|
||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=UnitOfMass.KILOGRAMS,
|
native_unit_of_measurement=UnitOfMass.KILOGRAMS,
|
||||||
translation_key="suggested_load",
|
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):
|
if descriptions := SENSORS.get(device.appliance_type):
|
||||||
for description in descriptions:
|
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(
|
_LOGGER.warning(
|
||||||
"[%s] Can't setup %s", device.appliance_type, description.key
|
"[%s] Can't setup %s", device.appliance_type, description.key
|
||||||
)
|
)
|
||||||
|
@ -467,9 +470,15 @@ class HonSensorEntity(HonEntity, SensorEntity):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def native_value(self) -> StateType:
|
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
|
@callback
|
||||||
def _handle_coordinator_update(self):
|
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()
|
self.async_write_ha_state()
|
||||||
|
|
|
@ -97,6 +97,13 @@ SWITCHES: dict[str, tuple[HonSwitchEntityDescription, ...]] = {
|
||||||
icon="mdi:timer",
|
icon="mdi:timer",
|
||||||
translation_key="anti_crease",
|
translation_key="anti_crease",
|
||||||
),
|
),
|
||||||
|
HonSwitchEntityDescription(
|
||||||
|
key="startProgram.anticrease",
|
||||||
|
name="Anti-Crease",
|
||||||
|
entity_category=EntityCategory.CONFIG,
|
||||||
|
icon="mdi:timer",
|
||||||
|
translation_key="anti_crease",
|
||||||
|
),
|
||||||
),
|
),
|
||||||
"OV": (
|
"OV": (
|
||||||
HonSwitchEntityDescription(
|
HonSwitchEntityDescription(
|
||||||
|
|
Loading…
Reference in a new issue