mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Use generators for async_add_entities in Abode (#76569)
This commit is contained in:
parent
52fd63acbc
commit
ca3033b84c
@ -30,12 +30,10 @@ async def async_setup_entry(
|
|||||||
CONST.TYPE_OPENING,
|
CONST.TYPE_OPENING,
|
||||||
]
|
]
|
||||||
|
|
||||||
entities = []
|
async_add_entities(
|
||||||
|
AbodeBinarySensor(data, device)
|
||||||
for device in data.abode.get_devices(generic_type=device_types):
|
for device in data.abode.get_devices(generic_type=device_types)
|
||||||
entities.append(AbodeBinarySensor(data, device))
|
)
|
||||||
|
|
||||||
async_add_entities(entities)
|
|
||||||
|
|
||||||
|
|
||||||
class AbodeBinarySensor(AbodeDevice, BinarySensorEntity):
|
class AbodeBinarySensor(AbodeDevice, BinarySensorEntity):
|
||||||
|
@ -28,12 +28,11 @@ async def async_setup_entry(
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""Set up Abode camera devices."""
|
"""Set up Abode camera devices."""
|
||||||
data: AbodeSystem = hass.data[DOMAIN]
|
data: AbodeSystem = hass.data[DOMAIN]
|
||||||
entities = []
|
|
||||||
|
|
||||||
for device in data.abode.get_devices(generic_type=CONST.TYPE_CAMERA):
|
async_add_entities(
|
||||||
entities.append(AbodeCamera(data, device, TIMELINE.CAPTURE_IMAGE))
|
AbodeCamera(data, device, TIMELINE.CAPTURE_IMAGE)
|
||||||
|
for device in data.abode.get_devices(generic_type=CONST.TYPE_CAMERA)
|
||||||
async_add_entities(entities)
|
)
|
||||||
|
|
||||||
|
|
||||||
class AbodeCamera(AbodeDevice, Camera):
|
class AbodeCamera(AbodeDevice, Camera):
|
||||||
|
@ -19,12 +19,10 @@ async def async_setup_entry(
|
|||||||
"""Set up Abode cover devices."""
|
"""Set up Abode cover devices."""
|
||||||
data: AbodeSystem = hass.data[DOMAIN]
|
data: AbodeSystem = hass.data[DOMAIN]
|
||||||
|
|
||||||
entities = []
|
async_add_entities(
|
||||||
|
AbodeCover(data, device)
|
||||||
for device in data.abode.get_devices(generic_type=CONST.TYPE_COVER):
|
for device in data.abode.get_devices(generic_type=CONST.TYPE_COVER)
|
||||||
entities.append(AbodeCover(data, device))
|
)
|
||||||
|
|
||||||
async_add_entities(entities)
|
|
||||||
|
|
||||||
|
|
||||||
class AbodeCover(AbodeDevice, CoverEntity):
|
class AbodeCover(AbodeDevice, CoverEntity):
|
||||||
|
@ -32,12 +32,10 @@ async def async_setup_entry(
|
|||||||
"""Set up Abode light devices."""
|
"""Set up Abode light devices."""
|
||||||
data: AbodeSystem = hass.data[DOMAIN]
|
data: AbodeSystem = hass.data[DOMAIN]
|
||||||
|
|
||||||
entities = []
|
async_add_entities(
|
||||||
|
AbodeLight(data, device)
|
||||||
for device in data.abode.get_devices(generic_type=CONST.TYPE_LIGHT):
|
for device in data.abode.get_devices(generic_type=CONST.TYPE_LIGHT)
|
||||||
entities.append(AbodeLight(data, device))
|
)
|
||||||
|
|
||||||
async_add_entities(entities)
|
|
||||||
|
|
||||||
|
|
||||||
class AbodeLight(AbodeDevice, LightEntity):
|
class AbodeLight(AbodeDevice, LightEntity):
|
||||||
|
@ -19,12 +19,10 @@ async def async_setup_entry(
|
|||||||
"""Set up Abode lock devices."""
|
"""Set up Abode lock devices."""
|
||||||
data: AbodeSystem = hass.data[DOMAIN]
|
data: AbodeSystem = hass.data[DOMAIN]
|
||||||
|
|
||||||
entities = []
|
async_add_entities(
|
||||||
|
AbodeLock(data, device)
|
||||||
for device in data.abode.get_devices(generic_type=CONST.TYPE_LOCK):
|
for device in data.abode.get_devices(generic_type=CONST.TYPE_LOCK)
|
||||||
entities.append(AbodeLock(data, device))
|
)
|
||||||
|
|
||||||
async_add_entities(entities)
|
|
||||||
|
|
||||||
|
|
||||||
class AbodeLock(AbodeDevice, LockEntity):
|
class AbodeLock(AbodeDevice, LockEntity):
|
||||||
|
@ -42,19 +42,12 @@ async def async_setup_entry(
|
|||||||
"""Set up Abode sensor devices."""
|
"""Set up Abode sensor devices."""
|
||||||
data: AbodeSystem = hass.data[DOMAIN]
|
data: AbodeSystem = hass.data[DOMAIN]
|
||||||
|
|
||||||
entities = []
|
async_add_entities(
|
||||||
|
AbodeSensor(data, device, description)
|
||||||
for device in data.abode.get_devices(generic_type=CONST.TYPE_SENSOR):
|
for description in SENSOR_TYPES
|
||||||
conditions = device.get_value(CONST.STATUSES_KEY)
|
for device in data.abode.get_devices(generic_type=CONST.TYPE_SENSOR)
|
||||||
entities.extend(
|
if description.key in device.get_value(CONST.STATUSES_KEY)
|
||||||
[
|
)
|
||||||
AbodeSensor(data, device, description)
|
|
||||||
for description in SENSOR_TYPES
|
|
||||||
if description.key in conditions
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
async_add_entities(entities)
|
|
||||||
|
|
||||||
|
|
||||||
class AbodeSensor(AbodeDevice, SensorEntity):
|
class AbodeSensor(AbodeDevice, SensorEntity):
|
||||||
|
@ -25,14 +25,16 @@ async def async_setup_entry(
|
|||||||
"""Set up Abode switch devices."""
|
"""Set up Abode switch devices."""
|
||||||
data: AbodeSystem = hass.data[DOMAIN]
|
data: AbodeSystem = hass.data[DOMAIN]
|
||||||
|
|
||||||
entities: list[SwitchEntity] = []
|
entities: list[SwitchEntity] = [
|
||||||
|
AbodeSwitch(data, device)
|
||||||
|
for device_type in DEVICE_TYPES
|
||||||
|
for device in data.abode.get_devices(generic_type=device_type)
|
||||||
|
]
|
||||||
|
|
||||||
for device_type in DEVICE_TYPES:
|
entities.extend(
|
||||||
for device in data.abode.get_devices(generic_type=device_type):
|
AbodeAutomationSwitch(data, automation)
|
||||||
entities.append(AbodeSwitch(data, device))
|
for automation in data.abode.get_automations()
|
||||||
|
)
|
||||||
for automation in data.abode.get_automations():
|
|
||||||
entities.append(AbodeAutomationSwitch(data, automation))
|
|
||||||
|
|
||||||
async_add_entities(entities)
|
async_add_entities(entities)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user