mirror of
https://github.com/home-assistant/core.git
synced 2025-07-28 15:47:12 +00:00
Fix Husqvarna Automower coordinator listener list mutating (#148926)
This commit is contained in:
parent
6dc2340c5a
commit
e32e06d7a0
@ -6,6 +6,7 @@ import asyncio
|
|||||||
from collections.abc import Callable
|
from collections.abc import Callable
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
from typing import override
|
||||||
|
|
||||||
from aioautomower.exceptions import (
|
from aioautomower.exceptions import (
|
||||||
ApiError,
|
ApiError,
|
||||||
@ -60,7 +61,12 @@ class AutomowerDataUpdateCoordinator(DataUpdateCoordinator[MowerDictionary]):
|
|||||||
self._devices_last_update: set[str] = set()
|
self._devices_last_update: set[str] = set()
|
||||||
self._zones_last_update: dict[str, set[str]] = {}
|
self._zones_last_update: dict[str, set[str]] = {}
|
||||||
self._areas_last_update: dict[str, set[int]] = {}
|
self._areas_last_update: dict[str, set[int]] = {}
|
||||||
self.async_add_listener(self._on_data_update)
|
|
||||||
|
@override
|
||||||
|
@callback
|
||||||
|
def async_update_listeners(self) -> None:
|
||||||
|
self._on_data_update()
|
||||||
|
super().async_update_listeners()
|
||||||
|
|
||||||
async def _async_update_data(self) -> MowerDictionary:
|
async def _async_update_data(self) -> MowerDictionary:
|
||||||
"""Subscribe for websocket and poll data from the API."""
|
"""Subscribe for websocket and poll data from the API."""
|
||||||
|
@ -462,7 +462,13 @@ async def test_add_and_remove_work_area(
|
|||||||
poll_values[TEST_MOWER_ID].work_area_names.remove("Front lawn")
|
poll_values[TEST_MOWER_ID].work_area_names.remove("Front lawn")
|
||||||
del poll_values[TEST_MOWER_ID].work_area_dict[123456]
|
del poll_values[TEST_MOWER_ID].work_area_dict[123456]
|
||||||
del poll_values[TEST_MOWER_ID].work_areas[123456]
|
del poll_values[TEST_MOWER_ID].work_areas[123456]
|
||||||
del poll_values[TEST_MOWER_ID].calendar.tasks[:2]
|
|
||||||
|
poll_values[TEST_MOWER_ID].calendar.tasks = [
|
||||||
|
task
|
||||||
|
for task in poll_values[TEST_MOWER_ID].calendar.tasks
|
||||||
|
if task.work_area_id not in [1, 123456]
|
||||||
|
]
|
||||||
|
|
||||||
poll_values[TEST_MOWER_ID].mower.work_area_id = 654321
|
poll_values[TEST_MOWER_ID].mower.work_area_id = 654321
|
||||||
mock_automower_client.get_status.return_value = poll_values
|
mock_automower_client.get_status.return_value = poll_values
|
||||||
freezer.tick(SCAN_INTERVAL)
|
freezer.tick(SCAN_INTERVAL)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user