mirror of
https://github.com/Andre0512/hon.git
synced 2025-05-14 07:04:23 -04:00
Rebuild to single data coordinator
This commit is contained in:
parent
8f1fc627e6
commit
a6c2c3e992
16 changed files with 148 additions and 203 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue