mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +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,
|
sensor_class: Callable,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up entities for block attributes."""
|
"""Set up entities for block attributes."""
|
||||||
blocks = []
|
entities = []
|
||||||
|
|
||||||
assert coordinator.device.blocks
|
assert coordinator.device.blocks
|
||||||
|
|
||||||
@ -90,17 +90,14 @@ def async_setup_block_attribute_entities(
|
|||||||
unique_id = f"{coordinator.mac}-{block.description}-{sensor_id}"
|
unique_id = f"{coordinator.mac}-{block.description}-{sensor_id}"
|
||||||
async_remove_shelly_entity(hass, domain, unique_id)
|
async_remove_shelly_entity(hass, domain, unique_id)
|
||||||
else:
|
else:
|
||||||
blocks.append((block, sensor_id, description))
|
entities.append(
|
||||||
|
sensor_class(coordinator, block, sensor_id, description)
|
||||||
|
)
|
||||||
|
|
||||||
if not blocks:
|
if not entities:
|
||||||
return
|
return
|
||||||
|
|
||||||
async_add_entities(
|
async_add_entities(entities)
|
||||||
[
|
|
||||||
sensor_class(coordinator, block, sensor_id, description)
|
|
||||||
for block, sensor_id, description in blocks
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
|
Loading…
x
Reference in New Issue
Block a user