Address late fritzbox coordinator runtime device discover review comments (#104267)

replace list comprehension by generator expression
pull/104660/head
Michael 2023-11-20 19:02:02 +01:00 committed by GitHub
parent ce497dd7ed
commit f69045fb64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 26 additions and 38 deletions

View File

@ -75,12 +75,10 @@ async def async_setup_entry(
if not coordinator.new_devices:
return
async_add_entities(
[
FritzboxBinarySensor(coordinator, ain, description)
for ain in coordinator.new_devices
for description in BINARY_SENSOR_TYPES
if description.suitable(coordinator.data.devices[ain])
]
)
entry.async_on_unload(coordinator.async_add_listener(_add_entities))

View File

@ -24,7 +24,7 @@ async def async_setup_entry(
if not coordinator.new_templates:
return
async_add_entities(
[FritzBoxTemplate(coordinator, ain) for ain in coordinator.new_templates]
FritzBoxTemplate(coordinator, ain) for ain in coordinator.new_templates
)
entry.async_on_unload(coordinator.async_add_listener(_add_entities))

View File

@ -57,11 +57,9 @@ async def async_setup_entry(
if not coordinator.new_devices:
return
async_add_entities(
[
FritzboxThermostat(coordinator, ain)
for ain in coordinator.new_devices
if coordinator.data.devices[ain].has_thermostat
]
)
entry.async_on_unload(coordinator.async_add_listener(_add_entities))

View File

@ -29,11 +29,9 @@ async def async_setup_entry(
if not coordinator.new_devices:
return
async_add_entities(
[
FritzboxCover(coordinator, ain)
for ain in coordinator.new_devices
if coordinator.data.devices[ain].has_blind
]
)
entry.async_on_unload(coordinator.async_add_listener(_add_entities))

View File

@ -35,7 +35,6 @@ async def async_setup_entry(
if not coordinator.new_devices:
return
async_add_entities(
[
FritzboxLight(
coordinator,
ain,
@ -44,7 +43,6 @@ async def async_setup_entry(
)
for ain in coordinator.new_devices
if (device := coordinator.data.devices[ain]).has_lightbulb
]
)
entry.async_on_unload(coordinator.async_add_listener(_add_entities))

View File

@ -220,12 +220,10 @@ async def async_setup_entry(
if not coordinator.new_devices:
return
async_add_entities(
[
FritzBoxSensor(coordinator, ain, description)
for ain in coordinator.new_devices
for description in SENSOR_TYPES
if description.suitable(coordinator.data.devices[ain])
]
)
entry.async_on_unload(coordinator.async_add_listener(_add_entities))

View File

@ -24,11 +24,9 @@ async def async_setup_entry(
if not coordinator.new_devices:
return
async_add_entities(
[
FritzboxSwitch(coordinator, ain)
for ain in coordinator.new_devices
if coordinator.data.devices[ain].has_switch
]
)
entry.async_on_unload(coordinator.async_add_listener(_add_entities))