Dateien nach "/" hochladen

This commit is contained in:
2026-06-11 11:34:40 +00:00
parent b0228df5b8
commit 080e7f2a05
5 changed files with 312 additions and 0 deletions

54
coordinator.py Normal file
View File

@@ -0,0 +1,54 @@
"""Coordinator for the Notification Store integration."""
from __future__ import annotations
from datetime import timedelta
from typing import Any
import logging
from homeassistant.core import HomeAssistant
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
from .const import DOMAIN, NAME
_LOGGER = logging.getLogger(__name__)
from .store import NotificationStore
class NotificationStoreCoordinator(DataUpdateCoordinator[dict[str, Any]]):
"""Coordinate notification store updates."""
def __init__(
self,
hass: HomeAssistant,
store: NotificationStore,
update_interval: timedelta,
) -> None:
"""Initialize the coordinator."""
super().__init__(
hass,
logger=_LOGGER,
name=NAME,
update_interval=update_interval,
always_update=False,
)
self.store = store
async def _async_update_data(self) -> dict[str, Any]:
"""Fetch data from the notification store."""
return await self.store.async_load()
@property
def notifications(self) -> list[dict[str, Any]]:
"""Return all notifications."""
return list((self.data or {}).get("notifications", []))
@property
def unread_notifications(self) -> list[dict[str, Any]]:
"""Return unread notifications."""
return [
item
for item in self.notifications
if item.get("status", "unread") == "unread"
]