Simplify setup of tradfri entities (#59343)

* Simplify detection of devices.
This commit is contained in:
jan iversen 2021-11-09 15:18:13 +01:00 committed by GitHub
parent 5177fabee0
commit ad91e4b417
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 27 deletions

View file

@ -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):