189 files
This commit is contained in:
@@ -11,9 +11,11 @@ from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .const import (
|
||||
BATTERY_FLEET_DUE_WITHOUT_SENSOR,
|
||||
BATTERY_FLEET_EXCLUDED,
|
||||
BATTERY_FLEET_INCLUDED,
|
||||
BATTERY_FLEET_OBJECT_FLAG,
|
||||
BATTERY_FLEET_REMOVED_PARTS,
|
||||
BATTERY_FLEET_TASK_FLAG,
|
||||
BATTERY_FLEET_TRACK_SELF_CHARGING,
|
||||
CONF_OBJECT,
|
||||
@@ -35,13 +37,17 @@ def _export_documents(doc_store: Any, object_id: str) -> list[dict[str, Any]]:
|
||||
file metadata pointing at a missing blob — the storage-hygiene repair issue
|
||||
catches those as dangling. Web-links round-trip fully. ``task_ids`` are
|
||||
carried too (as the OLD task ids); the importer remaps them onto the fresh
|
||||
task ids so a doc's task links survive a backup/restore.
|
||||
task ids so a doc's task links survive a backup/restore. The doc's own
|
||||
``id`` rides along for the same reason: history entries (completion
|
||||
photos) and spare parts (``doc_id``) point at documents by id, and the
|
||||
importer mints fresh ids — without the old one it could not remap them.
|
||||
"""
|
||||
out: list[dict[str, Any]] = []
|
||||
for d in doc_store.for_object(object_id):
|
||||
if d.get("kind") == "weblink":
|
||||
out.append(
|
||||
{
|
||||
"id": d.get("id"),
|
||||
"kind": "weblink",
|
||||
"url": d.get("url"),
|
||||
"title": d.get("title"),
|
||||
@@ -53,6 +59,7 @@ def _export_documents(doc_store: Any, object_id: str) -> list[dict[str, Any]]:
|
||||
else:
|
||||
out.append(
|
||||
{
|
||||
"id": d.get("id"),
|
||||
"kind": "file",
|
||||
"hash": d.get("hash"),
|
||||
"title": d.get("title"),
|
||||
@@ -133,6 +140,9 @@ def _build_export_object(
|
||||
"priority": tdata.get("priority", "normal"),
|
||||
"labels": tdata.get("labels") or [],
|
||||
"earliest_completion_days": tdata.get("earliest_completion_days"),
|
||||
# #170: reference number — a restore keeps "8.3" on the booklets
|
||||
# already printed; a colliding import is renumbered on setup.
|
||||
"ref_no": tdata.get("ref_no"),
|
||||
"on_complete_action": tdata.get("on_complete_action"),
|
||||
"quick_complete_defaults": tdata.get("quick_complete_defaults"),
|
||||
"assignee_pool": tdata.get("assignee_pool") or [],
|
||||
@@ -142,6 +152,8 @@ def _build_export_object(
|
||||
"required_completion_fields": tdata.get("required_completion_fields"),
|
||||
"rotation_strategy": tdata.get("rotation_strategy"),
|
||||
"reading_unit": tdata.get("reading_unit"),
|
||||
# #161 phase 2: reading slots (history carries the per-slot values).
|
||||
"readings": tdata.get("readings"),
|
||||
# Task phases (#139): defs + cycle are static config; the cursor is
|
||||
# Store-merged by merged_tasks, so a restore resumes mid-cycle
|
||||
# instead of silently restarting at step one.
|
||||
@@ -210,6 +222,10 @@ def _build_export_object(
|
||||
# restore — with every task still archived (reason "object") and
|
||||
# object/unarchive refusing because the object "isn't archived".
|
||||
"archived_at": obj_data.get("archived_at"),
|
||||
# #170: the object's reference number + its task counter (the
|
||||
# high-water mark, so numbers are not reused after a restore).
|
||||
"ref_no": obj_data.get("ref_no"),
|
||||
"next_task_ref": obj_data.get("next_task_ref"),
|
||||
}
|
||||
# Battery fleet identity — only emitted for the fleet object so a plain
|
||||
# object's export stays byte-identical to earlier versions. The importer
|
||||
@@ -219,6 +235,9 @@ def _build_export_object(
|
||||
export_obj[BATTERY_FLEET_EXCLUDED] = list(obj_data.get(BATTERY_FLEET_EXCLUDED) or [])
|
||||
export_obj[BATTERY_FLEET_INCLUDED] = list(obj_data.get(BATTERY_FLEET_INCLUDED) or [])
|
||||
export_obj[BATTERY_FLEET_TRACK_SELF_CHARGING] = bool(obj_data.get(BATTERY_FLEET_TRACK_SELF_CHARGING))
|
||||
# D#162: on unless explicitly switched off (absent = on).
|
||||
export_obj[BATTERY_FLEET_DUE_WITHOUT_SENSOR] = obj_data.get(BATTERY_FLEET_DUE_WITHOUT_SENSOR) is not False
|
||||
export_obj[BATTERY_FLEET_REMOVED_PARTS] = list(obj_data.get(BATTERY_FLEET_REMOVED_PARTS) or [])
|
||||
|
||||
return {
|
||||
"entry_id": entry.entry_id,
|
||||
@@ -322,7 +341,7 @@ def export_maintenance_data(
|
||||
# Global settings the export deliberately leaves behind: HA user ids are
|
||||
# instance-bound (and the panel-access allowlist is security-relevant), and
|
||||
# the adopted-task stash is transient re-adopt state.
|
||||
_NON_PORTABLE_SETTINGS = ("admin_panel_user_ids", "adopted_task_notes", "shopping_list_entity")
|
||||
_NON_PORTABLE_SETTINGS = ("admin_panel_user_ids", "adopted_task_notes", "shopping_list_entity", "member_display")
|
||||
|
||||
|
||||
def build_settings_export(hass: HomeAssistant) -> dict[str, Any]:
|
||||
|
||||
Reference in New Issue
Block a user