Merge branch 'main' into main

This commit is contained in:
Vadym
2024-08-22 18:23:28 +03:00
committed by GitHub
49 changed files with 17484 additions and 261 deletions
+13 -7
View File
@@ -17,7 +17,8 @@ from pyhon.appliance import HonAppliance
from pyhon.parameter.range import HonParameterRange
from .const import DOMAIN
from .hon import HonEntity, unique_entities
from .entity import HonEntity
from .util import unique_entities
@dataclass(frozen=True)
@@ -140,6 +141,12 @@ NUMBERS: dict[str, tuple[NumberEntityDescription, ...]] = {
icon="mdi:water",
translation_key="water_hard",
),
HonNumberEntityDescription(
key="settings.waterHard",
name="Water hard",
icon="mdi:water",
translation_key="water_hard",
),
),
"AC": (
HonNumberEntityDescription(
@@ -216,7 +223,7 @@ async def async_setup_entry(
) -> None:
entities = []
entity: HonNumberEntity | HonConfigNumberEntity
for device in hass.data[DOMAIN][entry.unique_id].appliances:
for device in hass.data[DOMAIN][entry.unique_id]["hon"].appliances:
for description in NUMBERS.get(device.appliance_type, []):
if description.key not in device.available_settings:
continue
@@ -226,7 +233,6 @@ async def async_setup_entry(
entity = HonConfigNumberEntity(hass, entry, device, description)
else:
continue
await entity.coordinator.async_config_entry_first_refresh()
entities.append(entity)
async_add_entities(entities)
@@ -267,7 +273,7 @@ class HonNumberEntity(HonEntity, NumberEntity):
await self._device.commands[command].send()
if command != "settings":
self._device.sync_command(command, "settings")
await self.coordinator.async_refresh()
self.coordinator.async_set_updated_data({})
@callback
def _handle_coordinator_update(self, update: bool = True) -> None:
@@ -286,7 +292,7 @@ class HonNumberEntity(HonEntity, NumberEntity):
return (
super().available
and int(self._device.get("remoteCtrValid", 1)) == 1
and self._device.get("attributes.lastConnEvent.category") != "DISCONNECTED"
and self._device.connection
)
@@ -310,7 +316,7 @@ class HonConfigNumberEntity(HonEntity, NumberEntity):
@property
def native_value(self) -> float | None:
if value := self._device.settings[self.entity_description.key].value:
if (value := self._device.settings[self.entity_description.key].value) != "":
return float(value)
return None
@@ -318,7 +324,7 @@ class HonConfigNumberEntity(HonEntity, NumberEntity):
setting = self._device.settings[self.entity_description.key]
if isinstance(setting, HonParameterRange):
setting.value = value
await self.coordinator.async_refresh()
self.coordinator.async_set_updated_data({})
@property
def available(self) -> bool: