Migrate screenlogic to use entry.runtime_data (#121644)
This commit is contained in:
parent
6f15352eda
commit
fb758bd8b6
10 changed files with 50 additions and 67 deletions
|
@ -1,26 +1,22 @@
|
|||
"""Support for a ScreenLogic 'circuit' switch."""
|
||||
|
||||
from dataclasses import dataclass
|
||||
import logging
|
||||
|
||||
from screenlogicpy.const.data import ATTR, DEVICE
|
||||
from screenlogicpy.const.msg import CODE
|
||||
from screenlogicpy.device_const.circuit import GENERIC_CIRCUIT_NAMES, INTERFACE
|
||||
|
||||
from homeassistant.components.switch import SwitchEntity, SwitchEntityDescription
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from .const import DOMAIN as SL_DOMAIN, LIGHT_CIRCUIT_FUNCTIONS
|
||||
from .coordinator import ScreenlogicDataUpdateCoordinator
|
||||
from .const import LIGHT_CIRCUIT_FUNCTIONS
|
||||
from .entity import (
|
||||
ScreenLogicCircuitEntity,
|
||||
ScreenLogicPushEntityDescription,
|
||||
ScreenLogicSwitchingEntity,
|
||||
)
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
from .types import ScreenLogicConfigEntry
|
||||
|
||||
|
||||
@dataclass(frozen=True, kw_only=True)
|
||||
|
@ -32,14 +28,12 @@ class ScreenLogicCircuitSwitchDescription(
|
|||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant,
|
||||
config_entry: ConfigEntry,
|
||||
config_entry: ScreenLogicConfigEntry,
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up entry."""
|
||||
entities: list[ScreenLogicSwitchingEntity] = []
|
||||
coordinator: ScreenlogicDataUpdateCoordinator = hass.data[SL_DOMAIN][
|
||||
config_entry.entry_id
|
||||
]
|
||||
coordinator = config_entry.runtime_data
|
||||
gateway = coordinator.gateway
|
||||
for circuit_index, circuit_data in gateway.get_data(DEVICE.CIRCUIT).items():
|
||||
if (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue