Migrate screenlogic to use entry.runtime_data (#121644)

This commit is contained in:
J. Nick Koston 2024-07-09 23:36:02 -07:00 committed by GitHub
parent 6f15352eda
commit fb758bd8b6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 50 additions and 67 deletions

View file

@ -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 (