185 files

This commit is contained in:
Home Assistant Version Control
2026-08-19 11:38:13 +00:00
parent 5f9330abd7
commit a718af6423
185 changed files with 16868 additions and 3088 deletions
@@ -12,6 +12,7 @@ once this module is in place. They call self.notifications.fire(...).
from __future__ import annotations
import contextlib
import logging
from dataclasses import dataclass
from typing import Any
@@ -539,18 +540,20 @@ class NotificationCoordinator:
# Scheduler — time-gated callbacks
# ------------------------------------------------------------------
def cancel_schedules(self) -> None:
"""Cancel all registered time triggers (idempotent; also used on unload)."""
for unsub in self._scheduled_unsubs:
with contextlib.suppress(Exception):
unsub()
self._scheduled_unsubs = []
async def async_setup_schedules(self) -> None:
"""Cancel any existing time callbacks and register fresh ones from current config.
Call this on startup AND after any config change that affects schedules
(e.g. bedtime time edited, custom notification time edited, master toggled).
"""
for unsub in self._scheduled_unsubs:
try:
unsub()
except Exception: # noqa: BLE001
pass
self._scheduled_unsubs = []
self.cancel_schedules()
# Bedtime — per-child time
cfg = self.storage.get_notification_config("bedtime_reminder")