mirror of
https://github.com/Andre0512/hon.git
synced 2025-05-12 22:25:36 -04:00
Refactor get coordinator
This commit is contained in:
parent
9518031f24
commit
e9d1bb2056
9 changed files with 43 additions and 69 deletions
|
@ -1,8 +1,6 @@
|
|||
import logging
|
||||
from dataclasses import dataclass
|
||||
|
||||
from pyhon import Hon
|
||||
|
||||
from homeassistant.components.binary_sensor import (
|
||||
BinarySensorEntityDescription,
|
||||
BinarySensorDeviceClass,
|
||||
|
@ -10,8 +8,10 @@ from homeassistant.components.binary_sensor import (
|
|||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import callback
|
||||
from pyhon import Hon
|
||||
|
||||
from .const import DOMAIN
|
||||
from .hon import HonCoordinator, HonEntity, unique_entities
|
||||
from .hon import HonEntity, unique_entities, get_coordinator
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -251,14 +251,9 @@ BINARY_SENSORS["WD"] = unique_entities(BINARY_SENSORS["WM"], BINARY_SENSORS["TD"
|
|||
|
||||
async def async_setup_entry(hass, entry: ConfigEntry, async_add_entities) -> None:
|
||||
hon: Hon = hass.data[DOMAIN][entry.unique_id]
|
||||
coordinators = hass.data[DOMAIN]["coordinators"]
|
||||
appliances = []
|
||||
for device in hon.appliances:
|
||||
if device.unique_id in coordinators:
|
||||
coordinator = hass.data[DOMAIN]["coordinators"][device.unique_id]
|
||||
else:
|
||||
coordinator = HonCoordinator(hass, device)
|
||||
hass.data[DOMAIN]["coordinators"][device.unique_id] = coordinator
|
||||
coordinator = get_coordinator(hass, device)
|
||||
await coordinator.async_config_entry_first_refresh()
|
||||
|
||||
if descriptions := BINARY_SENSORS.get(device.appliance_type):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue