Cleanup Shelly async_setup_block_attribute_entities (#110792)
This commit is contained in:
parent
0fbadc274a
commit
833c0ee723
1 changed files with 6 additions and 9 deletions
|
@ -67,7 +67,7 @@ def async_setup_block_attribute_entities(
|
|||
sensor_class: Callable,
|
||||
) -> None:
|
||||
"""Set up entities for block attributes."""
|
||||
blocks = []
|
||||
entities = []
|
||||
|
||||
assert coordinator.device.blocks
|
||||
|
||||
|
@ -90,17 +90,14 @@ def async_setup_block_attribute_entities(
|
|||
unique_id = f"{coordinator.mac}-{block.description}-{sensor_id}"
|
||||
async_remove_shelly_entity(hass, domain, unique_id)
|
||||
else:
|
||||
blocks.append((block, sensor_id, description))
|
||||
entities.append(
|
||||
sensor_class(coordinator, block, sensor_id, description)
|
||||
)
|
||||
|
||||
if not blocks:
|
||||
if not entities:
|
||||
return
|
||||
|
||||
async_add_entities(
|
||||
[
|
||||
sensor_class(coordinator, block, sensor_id, description)
|
||||
for block, sensor_id, description in blocks
|
||||
]
|
||||
)
|
||||
async_add_entities(entities)
|
||||
|
||||
|
||||
@callback
|
||||
|
|
Loading…
Add table
Reference in a new issue