Rebuild to single data coordinator

This commit is contained in:
Andre Basche 2024-03-29 01:22:44 +01:00
parent 8f1fc627e6
commit a6c2c3e992
16 changed files with 148 additions and 203 deletions

View file

@ -13,7 +13,8 @@ from homeassistant.helpers.typing import HomeAssistantType
from . import const
from .const import DOMAIN
from .hon import HonEntity, unique_entities, get_readable
from .entity import HonEntity
from .util import unique_entities, get_readable
_LOGGER = logging.getLogger(__name__)
@ -214,7 +215,7 @@ async def async_setup_entry(
) -> None:
entities = []
entity: HonSelectEntity | HonConfigSelectEntity
for device in hass.data[DOMAIN][entry.unique_id].appliances:
for device in hass.data[DOMAIN][entry.unique_id]["hon"].appliances:
for description in SELECTS.get(device.appliance_type, []):
if description.key not in device.available_settings:
continue
@ -262,7 +263,7 @@ class HonConfigSelectEntity(HonEntity, SelectEntity):
async def async_select_option(self, option: str) -> None:
setting = self._device.settings[self.entity_description.key]
setting.value = self._option_to_number(option, setting.values)
await self.coordinator.async_refresh()
self.async_write_ha_state()
@callback
def _handle_coordinator_update(self, update: bool = True) -> None:
@ -316,7 +317,7 @@ class HonSelectEntity(HonEntity, SelectEntity):
await self._device.commands[command].send()
if command != "settings":
self._device.sync_command(command, "settings")
await self.coordinator.async_refresh()
self.async_write_ha_state()
@property
def available(self) -> bool: