updated apps

This commit is contained in:
2026-07-14 23:57:03 -04:00
parent 6cc7212cef
commit 010e828e9c
797 changed files with 45153 additions and 4246 deletions
@@ -15,8 +15,6 @@ from ..const import (
CONF_OBJECT,
CONF_TASKS,
DEFAULT_WARNING_DAYS,
DOMAIN,
GLOBAL_UNIQUE_ID,
MAX_CHECKLIST_ITEM_LENGTH,
MAX_CHECKLIST_ITEMS,
)
@@ -69,12 +67,14 @@ def _csv_safe(val: str) -> str:
return val
def export_objects_csv(hass: HomeAssistant) -> str:
"""Export all maintenance objects and tasks as CSV.
def export_objects_csv(hass: HomeAssistant, entry_ids: set[str] | None = None) -> str:
"""Export maintenance objects and tasks as CSV (all, or a selection).
Each row represents one task, with the parent object info repeated.
"""
entries = [entry for entry in hass.config_entries.async_entries(DOMAIN) if entry.unique_id != GLOBAL_UNIQUE_ID]
from ..export import object_entries
entries = object_entries(hass, entry_ids)
output = io.StringIO()
writer = csv.DictWriter(output, fieldnames=_COLUMNS, extrasaction="ignore")
@@ -101,9 +101,9 @@ def export_objects_csv(hass: HomeAssistant) -> str:
"object_manufacturer": _csv_safe(obj_data.get("manufacturer", "")),
"object_model": _csv_safe(obj_data.get("model", "")),
"object_serial_number": _csv_safe(obj_data.get("serial_number", "")),
"object_area_id": obj_data.get("area_id", ""),
"object_installation_date": obj_data.get("installation_date", ""),
"object_warranty_expiry": obj_data.get("warranty_expiry", ""),
"object_area_id": _csv_safe(obj_data.get("area_id", "")),
"object_installation_date": _csv_safe(obj_data.get("installation_date", "")),
"object_warranty_expiry": _csv_safe(obj_data.get("warranty_expiry", "")),
"task_name": _csv_safe(tdata.get("name", "")),
"task_type": tdata.get("type", "custom"),
"enabled": tdata.get("enabled", True),
@@ -113,7 +113,7 @@ def export_objects_csv(hass: HomeAssistant) -> str:
"due_date": sched["due_date"] or "",
"interval_anchor": sched["interval_anchor"],
"schedule_time": tdata.get("schedule_time", ""),
"reading_unit": tdata.get("reading_unit", ""),
"reading_unit": _csv_safe(tdata.get("reading_unit", "")),
"warning_days": tdata.get("warning_days", DEFAULT_WARNING_DAYS),
"last_performed": tdata.get("last_performed", ""),
"notes": _csv_safe(tdata.get("notes", "")),
@@ -150,15 +150,18 @@ _OBJECT_RECORD_COLUMNS = [
]
def export_object_records_csv(hass: HomeAssistant) -> str:
def export_object_records_csv(hass: HomeAssistant, entry_ids: set[str] | None = None) -> str:
"""Export one row per maintenance object (the objects-table download, #67).
Unlike ``export_objects_csv`` (one row per task, object fields repeated),
this emits exactly one row per object — including objects that have no
tasks, which the per-task export skips entirely — and carries the full
asset field set used by the objects table.
asset field set used by the objects table. ``entry_ids`` narrows to a
selection (None = all).
"""
entries = [entry for entry in hass.config_entries.async_entries(DOMAIN) if entry.unique_id != GLOBAL_UNIQUE_ID]
from ..export import object_entries
entries = object_entries(hass, entry_ids)
output = io.StringIO()
writer = csv.DictWriter(output, fieldnames=_OBJECT_RECORD_COLUMNS, extrasaction="ignore")
@@ -176,9 +179,9 @@ def export_object_records_csv(hass: HomeAssistant) -> str:
"object_manufacturer": _csv_safe(obj_data.get("manufacturer") or ""),
"object_model": _csv_safe(obj_data.get("model") or ""),
"object_serial_number": _csv_safe(obj_data.get("serial_number") or ""),
"object_area_id": obj_data.get("area_id") or "",
"object_installation_date": obj_data.get("installation_date") or "",
"object_warranty_expiry": obj_data.get("warranty_expiry") or "",
"object_area_id": _csv_safe(obj_data.get("area_id") or ""),
"object_installation_date": _csv_safe(obj_data.get("installation_date") or ""),
"object_warranty_expiry": _csv_safe(obj_data.get("warranty_expiry") or ""),
"object_documentation_url": _csv_safe(obj_data.get("documentation_url") or ""),
"object_notes": _csv_safe(obj_data.get("notes") or ""),
"task_count": len(tasks_data),
@@ -224,6 +227,10 @@ def import_objects_csv(
"area_id": (row.get("object_area_id") or "").strip() or None,
"installation_date": (row.get("object_installation_date") or "").strip() or None,
"warranty_expiry": (row.get("object_warranty_expiry") or "").strip() or None,
# In the object-CSV export columns but never read back on
# import until now (round-trip gap, audit 2026-07-11).
"documentation_url": (row.get("object_documentation_url") or "").strip() or None,
"notes": (row.get("object_notes") or "").strip() or None,
"task_ids": [],
},
"tasks": {},