Clean up Husqvarna Automower number platform (#118641)

Address late review and remove unneeded loop in Husqvarna Automower
This commit is contained in:
Thomas55555 2024-06-03 05:13:02 +02:00 committed by GitHub
parent 6a8a975fae
commit 78e5f9578c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -129,12 +129,11 @@ async def async_setup_entry(
for work_area_id in _work_areas for work_area_id in _work_areas
) )
async_remove_entities(hass, coordinator, entry, mower_id) async_remove_entities(hass, coordinator, entry, mower_id)
entities.extend( entities.extend(
AutomowerNumberEntity(mower_id, coordinator, description) AutomowerNumberEntity(mower_id, coordinator, description)
for mower_id in coordinator.data for description in NUMBER_TYPES
for description in NUMBER_TYPES if description.exists_fn(coordinator.data[mower_id])
if description.exists_fn(coordinator.data[mower_id]) )
)
async_add_entities(entities) async_add_entities(entities)
@ -185,7 +184,6 @@ class AutomowerWorkAreaNumberEntity(AutomowerControlEntity, NumberEntity):
) -> None: ) -> None:
"""Set up AutomowerNumberEntity.""" """Set up AutomowerNumberEntity."""
super().__init__(mower_id, coordinator) super().__init__(mower_id, coordinator)
self.coordinator = coordinator
self.entity_description = description self.entity_description = description
self.work_area_id = work_area_id self.work_area_id = work_area_id
self._attr_unique_id = f"{mower_id}_{work_area_id}_{description.key}" self._attr_unique_id = f"{mower_id}_{work_area_id}_{description.key}"