コード例 #1
0
ファイル: switch.py プロジェクト: djtimca/home-assistant-dev
async def async_setup_entry(
    hass: HomeAssistant,
    entry: ConfigEntry,
    async_add_entities: Callable[[List[Entity], bool], None],
) -> None:
    """Set up Bond generic devices."""
    hub: BondHub = hass.data[DOMAIN][entry.entry_id]

    switches = [
        BondSwitch(hub, device) for device in hub.devices
        if DeviceType.is_generic(device.type)
    ]

    async_add_entities(switches, True)
コード例 #2
0
ファイル: switch.py プロジェクト: OpenPeerPower/core
async def async_setup_entry(
    opp: OpenPeerPower,
    entry: ConfigEntry,
    async_add_entities: AddEntitiesCallback,
) -> None:
    """Set up Bond generic devices."""
    data = opp.data[DOMAIN][entry.entry_id]
    hub: BondHub = data[HUB]
    bpup_subs: BPUPSubscriptions = data[BPUP_SUBS]

    switches: list[Entity] = [
        BondSwitch(hub, device, bpup_subs) for device in hub.devices
        if DeviceType.is_generic(device.type)
    ]

    async_add_entities(switches, True)
コード例 #3
0
async def async_setup_entry(
    hass: HomeAssistant,
    entry: ConfigEntry,
    async_add_entities: Callable[[list[Entity], bool], None],
) -> None:
    """Set up Bond generic devices."""
    data = hass.data[DOMAIN][entry.entry_id]
    hub: BondHub = data[HUB]
    bpup_subs: BPUPSubscriptions = data[BPUP_SUBS]

    switches: list[Entity] = [
        BondSwitch(hub, device, bpup_subs) for device in hub.devices
        if DeviceType.is_generic(device.type)
    ]

    async_add_entities(switches, True)
コード例 #4
0
async def async_setup_entry(
    hass: HomeAssistant,
    entry: ConfigEntry,
    async_add_entities: AddEntitiesCallback,
) -> None:
    """Set up Bond generic devices."""
    data = hass.data[DOMAIN][entry.entry_id]
    hub: BondHub = data[HUB]
    bpup_subs: BPUPSubscriptions = data[BPUP_SUBS]
    platform = entity_platform.async_get_current_platform()

    switches: list[Entity] = [
        BondSwitch(hub, device, bpup_subs) for device in hub.devices
        if DeviceType.is_generic(device.type)
    ]

    platform.async_register_entity_service(
        SERVICE_SET_POWER_TRACKED_STATE,
        {vol.Required(ATTR_POWER_STATE): cv.boolean},
        "async_set_power_belief",
    )

    async_add_entities(switches, True)