Commit d54a7c5
committed
fix(backup): unwrap WS send_command envelope in _ws_send
Root cause of every WS-backed auto-backup capture silently skipping:
``ws_client.send_command(...)`` returns the HA standard envelope
``{"success": True, "result": <inner>}``, not the bare ``<inner>``.
``_ws_send`` was returning that envelope, but every fetch handler
downstream did ``items = await _ws_send(...)`` followed by
``isinstance(items, list)`` — which is always False for the
``{"success": ..., "result": [...]}`` dict, so the handler returned
None, ``maybe_snapshot`` skipped silently, and the e2e log filled with
``Auto-backup: fetch returned None for <domain>:<id>`` lines.
Affected every fetch handler that hits a ``<type>/list`` style WS
endpoint: label, category, group, zone, area_or_floor, integration,
storage-backed helpers (input_boolean / input_text / input_number /
input_select / input_datetime / input_button / counter / timer /
schedule), and dashboard_resource. Automation / script / scene were
unaffected because they go through typed client helpers
(``get_automation_config`` etc.) that already unwrap.
Calendar and todo fetch handlers use ``execute_script`` which returns
a nested dict; they then do ``result.get("response", ...)``. Unwrapping
the envelope here is still correct for them — the inner ``result`` is
the ``execute_script`` response dict that already has the ``response``
key. No call-site behavior change needed.
Restore handlers that use ``_ws_send`` (dashboard, dashboard_resource,
label, category, zone, area_or_floor, integration, helpers) treat
the return as opaque (it's just embedded in ``ha_manage_backup``'s
``data.result``). Unwrapping affects what shows up there but doesn't
break anything — the inner result is more informative than the
envelope anyway.
Also demote the ``fetch returned None`` log from INFO back to DEBUG
now that the root cause is fixed (it was a one-iteration diagnostic).1 parent 7c56b60 commit d54a7c5
1 file changed
Lines changed: 13 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
278 | 278 | | |
279 | 279 | | |
280 | 280 | | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
| 281 | + | |
286 | 282 | | |
287 | 283 | | |
288 | 284 | | |
| |||
601 | 597 | | |
602 | 598 | | |
603 | 599 | | |
604 | | - | |
| 600 | + | |
605 | 601 | | |
606 | 602 | | |
607 | 603 | | |
| |||
614 | 610 | | |
615 | 611 | | |
616 | 612 | | |
617 | | - | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
618 | 624 | | |
619 | 625 | | |
620 | 626 | | |
| |||
0 commit comments