From c3b9815fe2f23574dc2de020957d252e8ef347be Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Mon, 6 Jul 2026 16:17:56 -0500 Subject: [PATCH] Remove clear finished and cancel all --- .../components/local_timer_list/timer_list.py | 21 --------------- .../components/timer_list/__init__.py | 19 ------------- homeassistant/components/timer_list/const.py | 2 -- .../components/timer_list/icons.json | 6 ----- .../components/timer_list/services.yaml | 10 ------- .../components/timer_list/strings.json | 8 ------ tests/components/timer_list/__init__.py | 21 --------------- tests/components/timer_list/test_init.py | 27 ------------------- 8 files changed, 114 deletions(-) diff --git a/homeassistant/components/local_timer_list/timer_list.py b/homeassistant/components/local_timer_list/timer_list.py index e84815d06a04..31a24b07ece9 100644 --- a/homeassistant/components/local_timer_list/timer_list.py +++ b/homeassistant/components/local_timer_list/timer_list.py @@ -112,16 +112,6 @@ class LocalTimerListEntity(TimerListEntity): self._notify(TimerListEventType.CANCELLED, timer) self._enforce_archive_limit() - @override - async def async_cancel_all_timers(self) -> None: - """Cancel every active or paused timer.""" - for timer_id in [ - timer.timer_id - for timer in self._timers.values() - if timer.status in (TimerStatus.ACTIVE, TimerStatus.PAUSED) - ]: - await self.async_cancel_timer(timer_id) - @override async def async_add_time(self, timer_id: str, duration: timedelta) -> None: """Add (or, with a negative duration, remove) time on a timer.""" @@ -149,17 +139,6 @@ class LocalTimerListEntity(TimerListEntity): del self._timers[timer_id] self._notify(TimerListEventType.REMOVED, timer) - @override - async def async_clear_finished_timers(self) -> None: - """Remove all finished and cancelled (archived) timers.""" - for timer_id in [ - timer.timer_id - for timer in self._timers.values() - if timer.status in _FINISHED_STATUSES - ]: - timer = self._timers.pop(timer_id) - self._notify(TimerListEventType.REMOVED, timer) - def _get_timer(self, timer_id: str) -> TimerItem: """Return a timer by id or raise if it does not exist.""" if (timer := self._timers.get(timer_id)) is None: diff --git a/homeassistant/components/timer_list/__init__.py b/homeassistant/components/timer_list/__init__.py index cd91915252c4..a146b87a9ae3 100644 --- a/homeassistant/components/timer_list/__init__.py +++ b/homeassistant/components/timer_list/__init__.py @@ -149,12 +149,6 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: "async_cancel_timer", required_features=[TimerListEntityFeature.CANCEL_TIMER], ) - component.async_register_entity_service( - TimerListServices.CANCEL_ALL_TIMERS, - None, - "async_cancel_all_timers", - required_features=[TimerListEntityFeature.CANCEL_TIMER], - ) component.async_register_entity_service( TimerListServices.ADD_TIME, { @@ -178,11 +172,6 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: {vol.Required(ATTR_TIMER_ID): cv.string}, "async_remove_timer", ) - component.async_register_entity_service( - TimerListServices.CLEAR_FINISHED_TIMERS, - None, - "async_clear_finished_timers", - ) component.async_register_entity_service( TimerListServices.GET_TIMERS, {vol.Optional(ATTR_STATUS): vol.All(cv.ensure_list, [vol.Coerce(TimerStatus)])}, @@ -245,10 +234,6 @@ class TimerListEntity(Entity): """Cancel a timer.""" raise NotImplementedError - async def async_cancel_all_timers(self) -> None: - """Cancel every active or paused timer.""" - raise NotImplementedError - async def async_add_time(self, timer_id: str, duration: timedelta) -> None: """Add (or, with a negative duration, remove) time on a timer.""" raise NotImplementedError @@ -257,10 +242,6 @@ class TimerListEntity(Entity): """Remove a timer from the list regardless of its status.""" raise NotImplementedError - async def async_clear_finished_timers(self) -> None: - """Remove all finished and cancelled (archived) timers.""" - raise NotImplementedError - @final @callback def async_subscribe_updates( diff --git a/homeassistant/components/timer_list/const.py b/homeassistant/components/timer_list/const.py index 537a8c919211..1ea12de10cf6 100644 --- a/homeassistant/components/timer_list/const.py +++ b/homeassistant/components/timer_list/const.py @@ -31,11 +31,9 @@ class TimerListServices(StrEnum): PAUSE_TIMER = "pause_timer" UNPAUSE_TIMER = "unpause_timer" CANCEL_TIMER = "cancel_timer" - CANCEL_ALL_TIMERS = "cancel_all_timers" ADD_TIME = "add_time" REMOVE_TIME = "remove_time" REMOVE_TIMER = "remove_timer" - CLEAR_FINISHED_TIMERS = "clear_finished_timers" GET_TIMERS = "get_timers" diff --git a/homeassistant/components/timer_list/icons.json b/homeassistant/components/timer_list/icons.json index 889af6b6f6f2..49e85c9d58f7 100644 --- a/homeassistant/components/timer_list/icons.json +++ b/homeassistant/components/timer_list/icons.json @@ -8,15 +8,9 @@ "add_time": { "service": "mdi:timer-plus-outline" }, - "cancel_all_timers": { - "service": "mdi:timer-cancel-outline" - }, "cancel_timer": { "service": "mdi:timer-cancel-outline" }, - "clear_finished_timers": { - "service": "mdi:timer-remove-outline" - }, "get_timers": { "service": "mdi:timer-outline" }, diff --git a/homeassistant/components/timer_list/services.yaml b/homeassistant/components/timer_list/services.yaml index 1e922fb69ffa..29e0ea31a8fa 100644 --- a/homeassistant/components/timer_list/services.yaml +++ b/homeassistant/components/timer_list/services.yaml @@ -50,12 +50,6 @@ cancel_timer: example: "01HZ8ABCDEF0123456789ABCDE" selector: text: -cancel_all_timers: - target: - entity: - domain: timer_list - supported_features: - - timer_list.TimerListEntityFeature.CANCEL_TIMER add_time: target: entity: @@ -100,10 +94,6 @@ remove_timer: example: "01HZ8ABCDEF0123456789ABCDE" selector: text: -clear_finished_timers: - target: - entity: - domain: timer_list get_timers: target: entity: diff --git a/homeassistant/components/timer_list/strings.json b/homeassistant/components/timer_list/strings.json index 39a930e3e295..83df1b0e7ab9 100644 --- a/homeassistant/components/timer_list/strings.json +++ b/homeassistant/components/timer_list/strings.json @@ -34,10 +34,6 @@ }, "name": "Add time" }, - "cancel_all_timers": { - "description": "Cancels every active and paused timer on a timer list.", - "name": "Cancel all timers" - }, "cancel_timer": { "description": "Cancels a timer.", "fields": { @@ -48,10 +44,6 @@ }, "name": "Cancel timer" }, - "clear_finished_timers": { - "description": "Removes all finished and cancelled timers from a timer list.", - "name": "Clear finished timers" - }, "get_timers": { "description": "Gets the timers on a timer list.", "fields": { diff --git a/tests/components/timer_list/__init__.py b/tests/components/timer_list/__init__.py index 9dba7af610c2..35ce9929e4c9 100644 --- a/tests/components/timer_list/__init__.py +++ b/tests/components/timer_list/__init__.py @@ -115,16 +115,6 @@ class MockTimerListEntity(TimerListEntity): self._notify(TimerListEventType.CANCELLED, timer) self._enforce_archive_limit() - @override - async def async_cancel_all_timers(self) -> None: - """Cancel every active or paused timer.""" - for timer_id in [ - timer.timer_id - for timer in self._timers.values() - if timer.status in (TimerStatus.ACTIVE, TimerStatus.PAUSED) - ]: - await self.async_cancel_timer(timer_id) - @override async def async_add_time(self, timer_id: str, duration: timedelta) -> None: """Add (or, with a negative duration, remove) time on a timer.""" @@ -152,17 +142,6 @@ class MockTimerListEntity(TimerListEntity): del self._timers[timer_id] self._notify(TimerListEventType.REMOVED, timer) - @override - async def async_clear_finished_timers(self) -> None: - """Remove all finished and cancelled (archived) timers.""" - for timer_id in [ - timer.timer_id - for timer in self._timers.values() - if timer.status in _FINISHED_STATUSES - ]: - timer = self._timers.pop(timer_id) - self._notify(TimerListEventType.REMOVED, timer) - def _get_timer(self, timer_id: str) -> TimerItem: """Return a timer by id or raise if it does not exist.""" if (timer := self._timers.get(timer_id)) is None: diff --git a/tests/components/timer_list/test_init.py b/tests/components/timer_list/test_init.py index 6f6e64c00236..dd688a73c5cf 100644 --- a/tests/components/timer_list/test_init.py +++ b/tests/components/timer_list/test_init.py @@ -172,33 +172,6 @@ async def test_cancel_timer_archives_timer(hass: HomeAssistant) -> None: assert timers[0]["status"] == "cancelled" -@pytest.mark.usefixtures("test_entity") -async def test_cancel_all_timers(hass: HomeAssistant) -> None: - """Test cancelling all timers archives them.""" - await _start_timer(hass) - await _start_timer(hass) - - await _call(hass, "cancel_all_timers") - - assert hass.states.get(TEST_ENTITY_ID).state == "0" - assert len(await _get_timers(hass)) == 2 - - -@pytest.mark.usefixtures("test_entity") -async def test_clear_finished_timers(hass: HomeAssistant) -> None: - """Test clearing finished and cancelled timers.""" - timer_id = await _start_timer(hass) - await _call(hass, "cancel_timer", timer_id=timer_id) - await _start_timer(hass) - assert len(await _get_timers(hass)) == 2 - - await _call(hass, "clear_finished_timers") - - timers = await _get_timers(hass) - assert len(timers) == 1 - assert timers[0]["status"] == "active" - - @pytest.mark.usefixtures("test_entity") async def test_archive_limit_evicts_oldest( hass: HomeAssistant, freezer: FrozenDateTimeFactory