182 files

This commit is contained in:
Home Assistant Version Control
2026-08-17 12:11:35 +00:00
parent 7dddf6bb13
commit ece15a1c1b
183 changed files with 11457 additions and 3092 deletions
@@ -12,7 +12,7 @@ from typing import TYPE_CHECKING, Any
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from ..const import CONF_TASKS, DOMAIN, GLOBAL_UNIQUE_ID, MaintenanceStatus
from ..const import CONF_OBJECT, CONF_TASKS, DOMAIN, GLOBAL_UNIQUE_ID, MaintenanceStatus
if TYPE_CHECKING:
from .. import MaintenanceSupporterData
@@ -27,9 +27,46 @@ _COUNTED_STATUSES = (
)
def get_object_entries(hass: HomeAssistant) -> list[ConfigEntry]:
"""Return all non-global config entries for this domain."""
return [entry for entry in hass.config_entries.async_entries(DOMAIN) if entry.unique_id != GLOBAL_UNIQUE_ID]
def object_name(entry: ConfigEntry) -> str:
"""The object's display name, falling back to the entry title.
One rule for the ~13 hand-written fallbacks that existed in four spellings
— half used ``.get("name", title)``, which kept an EMPTY name instead of
falling through to the title."""
return str((entry.data.get(CONF_OBJECT) or {}).get("name") or entry.title)
def merged_tasks(entry: ConfigEntry) -> dict[str, Any]:
"""Merged task data (static ConfigEntry + dynamic Store) for an entry.
THE read path for task dicts outside the coordinator — it was re-implemented
eight times, and only one copy overlaid the in-cycle checklist ticks. The
ticks are overlaid HERE rather than via the Store merge whitelist: merged
dicts feed MaintenanceTask.from_dict all over the coordinator, and this
field is presentation state the model never needs. Degrades to the static
data when the Store is unavailable.
"""
tasks_data: dict[str, Any] = entry.data.get(CONF_TASKS, {})
rd = getattr(entry, "runtime_data", None)
store = getattr(rd, "store", None) if rd else None
if store is None:
return tasks_data
merged: dict[str, Any] = store.merge_all_tasks(tasks_data)
for tid, td in merged.items():
progress = store.get_task_state(tid).get("checklist_progress")
if progress:
td["checklist_progress"] = progress
return merged
def get_object_entries(hass: HomeAssistant, entry_ids: set[str] | None = None) -> list[ConfigEntry]:
"""Return all non-global config entries for this domain, optionally
narrowed to a selection (``entry_ids=None`` means all objects)."""
return [
entry
for entry in hass.config_entries.async_entries(DOMAIN)
if entry.unique_id != GLOBAL_UNIQUE_ID and (entry_ids is None or entry.entry_id in entry_ids)
]
def get_runtime_data(hass: HomeAssistant, entry_id: str) -> MaintenanceSupporterData | None: