257 files

This commit is contained in:
Home Assistant Version Control
2026-10-02 16:06:24 +00:00
parent 7c55603942
commit c29f5cc088
258 changed files with 24621 additions and 3136 deletions
@@ -79,6 +79,9 @@ def _build_export_object(
"created_at": tdata.get("created_at"),
"archived_at": tdata.get("archived_at"),
"archived_reason": tdata.get("archived_reason"),
# #193: a paused task stays paused after a restore.
"paused_at": tdata.get("paused_at"),
"paused_until": tdata.get("paused_until"),
"schedule_type": sched["schedule_type"],
"interval_days": sched["interval_days"],
"interval_unit": sched["interval_unit"],
@@ -163,6 +166,16 @@ def _build_export_object(
# restored fleet task is a plain inspection task.
if tdata.get(BATTERY_FLEET_TASK_FLAG):
task[BATTERY_FLEET_TASK_FLAG] = True
# The fleet's replacement log and low latch live in the task's
# Store state, which merged_tasks does not overlay — a backup
# lost every recorded battery swap (round-trip audit 2026-09-29).
from .helpers.battery_fleet import LOW_LATCH_KEY
from .helpers.battery_lifetime import REPLACEMENT_LOG_KEY
state = store.get_task_state(tid) if store is not None else {}
for key in (REPLACEMENT_LOG_KEY, LOW_LATCH_KEY):
if state.get(key):
task[key] = state[key]
if include_history:
task["history"] = tdata.get("history") or []
@@ -280,7 +293,7 @@ def serialize_export(data: dict[str, Any], fmt: str = "json") -> str:
"""
if fmt == "yaml":
try:
import yaml # type: ignore[import-untyped]
import yaml
# Normalize through JSON first: yaml.safe_dump rejects types the
# JSON path coerces (e.g. tuples → lists), so YAML export would
@@ -368,4 +381,11 @@ def build_settings_export(hass: HomeAssistant) -> dict[str, Any]:
):
if key in opts:
settings[key] = opts[key]
return {"version": 1, "global_settings": settings}
out: dict[str, Any] = {"version": 1, "global_settings": settings}
# Group members and vacation exemptions point at tasks by id; a move to
# another instance mints new ids, so name them (helpers.import_mapping).
from .helpers.import_mapping import TASK_NAMES_KEY, settings_task_names
if task_names := settings_task_names(hass, settings):
out[TASK_NAMES_KEY] = task_names
return out