Bump screenlogicpy to v0.9.0 (#92475)
Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
parent
8de3945bd4
commit
092580a3ed
28 changed files with 3821 additions and 652 deletions
|
@ -1,21 +1,19 @@
|
|||
"""Support for a ScreenLogic 'circuit' switch."""
|
||||
from dataclasses import dataclass
|
||||
import logging
|
||||
|
||||
from screenlogicpy.const import (
|
||||
CODE,
|
||||
DATA as SL_DATA,
|
||||
GENERIC_CIRCUIT_NAMES,
|
||||
INTERFACE_GROUP,
|
||||
)
|
||||
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
|
||||
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 . import ScreenlogicDataUpdateCoordinator
|
||||
from .const import DOMAIN, LIGHT_CIRCUIT_FUNCTIONS
|
||||
from .entity import ScreenLogicCircuitEntity
|
||||
from .const import DOMAIN as SL_DOMAIN, LIGHT_CIRCUIT_FUNCTIONS
|
||||
from .coordinator import ScreenlogicDataUpdateCoordinator
|
||||
from .entity import ScreenLogicCircuitEntity, ScreenLogicPushEntityDescription
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -26,24 +24,43 @@ async def async_setup_entry(
|
|||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up entry."""
|
||||
coordinator: ScreenlogicDataUpdateCoordinator = hass.data[DOMAIN][
|
||||
entities: list[ScreenLogicSwitch] = []
|
||||
coordinator: ScreenlogicDataUpdateCoordinator = hass.data[SL_DOMAIN][
|
||||
config_entry.entry_id
|
||||
]
|
||||
circuits = coordinator.gateway_data[SL_DATA.KEY_CIRCUITS]
|
||||
async_add_entities(
|
||||
[
|
||||
gateway = coordinator.gateway
|
||||
for circuit_index, circuit_data in gateway.get_data(DEVICE.CIRCUIT).items():
|
||||
if circuit_data[ATTR.FUNCTION] in LIGHT_CIRCUIT_FUNCTIONS:
|
||||
continue
|
||||
circuit_name = circuit_data[ATTR.NAME]
|
||||
circuit_interface = INTERFACE(circuit_data[ATTR.INTERFACE])
|
||||
entities.append(
|
||||
ScreenLogicSwitch(
|
||||
coordinator,
|
||||
circuit_num,
|
||||
CODE.STATUS_CHANGED,
|
||||
circuit["name"] not in GENERIC_CIRCUIT_NAMES
|
||||
and circuit["interface"] != INTERFACE_GROUP.DONT_SHOW,
|
||||
ScreenLogicSwitchDescription(
|
||||
subscription_code=CODE.STATUS_CHANGED,
|
||||
data_path=(DEVICE.CIRCUIT, circuit_index),
|
||||
key=circuit_index,
|
||||
name=circuit_name,
|
||||
entity_registry_enabled_default=(
|
||||
circuit_name not in GENERIC_CIRCUIT_NAMES
|
||||
and circuit_interface != INTERFACE.DONT_SHOW
|
||||
),
|
||||
),
|
||||
)
|
||||
for circuit_num, circuit in circuits.items()
|
||||
if circuit["function"] not in LIGHT_CIRCUIT_FUNCTIONS
|
||||
]
|
||||
)
|
||||
)
|
||||
|
||||
async_add_entities(entities)
|
||||
|
||||
|
||||
@dataclass
|
||||
class ScreenLogicSwitchDescription(
|
||||
SwitchEntityDescription, ScreenLogicPushEntityDescription
|
||||
):
|
||||
"""Describes a ScreenLogic switch entity."""
|
||||
|
||||
|
||||
class ScreenLogicSwitch(ScreenLogicCircuitEntity, SwitchEntity):
|
||||
"""Class to represent a ScreenLogic Switch."""
|
||||
|
||||
entity_description: ScreenLogicSwitchDescription
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue