mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Cleanup Shelly async_setup_block_attribute_entities (#110792)
This commit is contained in:
parent
0fbadc274a
commit
833c0ee723
@ -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…
x
Reference in New Issue
Block a user