From 833c0ee723d973306b069972f16686ce5b8a6f1e Mon Sep 17 00:00:00 2001 From: Shay Levy Date: Sat, 17 Feb 2024 16:29:35 +0200 Subject: [PATCH] Cleanup Shelly async_setup_block_attribute_entities (#110792) --- homeassistant/components/shelly/entity.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/homeassistant/components/shelly/entity.py b/homeassistant/components/shelly/entity.py index 846c527a5f8..146376e836e 100644 --- a/homeassistant/components/shelly/entity.py +++ b/homeassistant/components/shelly/entity.py @@ -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