parent
5177fabee0
commit
ad91e4b417
|
@ -26,9 +26,9 @@ async def async_setup_entry(
|
|||
api = tradfri_data[KEY_API]
|
||||
devices = tradfri_data[DEVICES]
|
||||
|
||||
covers = [dev for dev in devices if dev.has_blind_control]
|
||||
if covers:
|
||||
async_add_entities(TradfriCover(cover, api, gateway_id) for cover in covers)
|
||||
async_add_entities(
|
||||
TradfriCover(dev, api, gateway_id) for dev in devices if dev.has_blind_control
|
||||
)
|
||||
|
||||
|
||||
class TradfriCover(TradfriBaseDevice, CoverEntity):
|
||||
|
|
|
@ -31,11 +31,11 @@ async def async_setup_entry(
|
|||
api = tradfri_data[KEY_API]
|
||||
devices = tradfri_data[DEVICES]
|
||||
|
||||
purifiers = [dev for dev in devices if dev.has_air_purifier_control]
|
||||
if purifiers:
|
||||
async_add_entities(
|
||||
TradfriAirPurifierFan(purifier, api, gateway_id) for purifier in purifiers
|
||||
)
|
||||
async_add_entities(
|
||||
TradfriAirPurifierFan(dev, api, gateway_id)
|
||||
for dev in devices
|
||||
if dev.has_air_purifier_control
|
||||
)
|
||||
|
||||
|
||||
def _from_percentage(percentage: int) -> int:
|
||||
|
|
|
@ -49,12 +49,12 @@ async def async_setup_entry(
|
|||
api = tradfri_data[KEY_API]
|
||||
devices = tradfri_data[DEVICES]
|
||||
|
||||
lights = [dev for dev in devices if dev.has_light_control]
|
||||
if lights:
|
||||
async_add_entities(TradfriLight(light, api, gateway_id) for light in lights)
|
||||
|
||||
entities: list[TradfriBaseClass] = [
|
||||
TradfriLight(dev, api, gateway_id) for dev in devices if dev.has_light_control
|
||||
]
|
||||
if config_entry.data[CONF_IMPORT_GROUPS] and (groups := tradfri_data[GROUPS]):
|
||||
async_add_entities(TradfriGroup(group, api, gateway_id) for group in groups)
|
||||
entities.extend([TradfriGroup(group, api, gateway_id) for group in groups])
|
||||
async_add_entities(entities)
|
||||
|
||||
|
||||
class TradfriGroup(TradfriBaseClass, LightEntity):
|
||||
|
|
|
@ -27,17 +27,17 @@ async def async_setup_entry(
|
|||
api = tradfri_data[KEY_API]
|
||||
devices = tradfri_data[DEVICES]
|
||||
|
||||
sensors = (
|
||||
dev
|
||||
async_add_entities(
|
||||
TradfriSensor(dev, api, gateway_id)
|
||||
for dev in devices
|
||||
if not dev.has_light_control
|
||||
and not dev.has_socket_control
|
||||
and not dev.has_blind_control
|
||||
and not dev.has_signal_repeater_control
|
||||
and not dev.has_air_purifier_control
|
||||
if (
|
||||
not dev.has_light_control
|
||||
and not dev.has_socket_control
|
||||
and not dev.has_blind_control
|
||||
and not dev.has_signal_repeater_control
|
||||
and not dev.has_air_purifier_control
|
||||
)
|
||||
)
|
||||
if sensors:
|
||||
async_add_entities(TradfriSensor(sensor, api, gateway_id) for sensor in sensors)
|
||||
|
||||
|
||||
class TradfriSensor(TradfriBaseDevice, SensorEntity):
|
||||
|
|
|
@ -26,11 +26,9 @@ async def async_setup_entry(
|
|||
api = tradfri_data[KEY_API]
|
||||
devices = tradfri_data[DEVICES]
|
||||
|
||||
switches = [dev for dev in devices if dev.has_socket_control]
|
||||
if switches:
|
||||
async_add_entities(
|
||||
TradfriSwitch(switch, api, gateway_id) for switch in switches
|
||||
)
|
||||
async_add_entities(
|
||||
TradfriSwitch(dev, api, gateway_id) for dev in devices if dev.has_socket_control
|
||||
)
|
||||
|
||||
|
||||
class TradfriSwitch(TradfriBaseDevice, SwitchEntity):
|
||||
|
|
Loading…
Reference in New Issue