SAFETY-34: re-assert latched alarms, because a Core restart keeps the add-on
A Core-only restart wipes persistent_notification and does NOT restart the add-on (measured on TEST-23: the add-on's SAFETY-31 card was gone 4 min after `docker restart test23-ha`, add-on StartedAt unchanged). The latched SAFETY-31 and SAFETY-42 cards were re-raised only on add-on start, so they stayed gone. They are now re-asserted every REANNOUNCE_S = 300 s while tripped (same notification_id, so it replaces). test_watchdog part 6 and test_delivery part 8b grade it with the same process across the "restart"; red on the old code. The docstrings that said the add-on restarts with HA are corrected. Record: goodwe docs/DECISIONS.md, SAFETY-34 D4. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LyR88rXETvwhTgx6yHE39p
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
fe132515fe
commit
6028e21298
@@ -1195,8 +1195,8 @@ async def _restart():
|
||||
c1 = _ctrl(h1, store=shared)
|
||||
await _drive(c1)
|
||||
# A NEW process, a NEW HomeAssistant object (so the in-memory notification
|
||||
# is gone with it), the SAME durable file. That is what a Home Assistant
|
||||
# restart is from this add-on's point of view: the add-on goes with it.
|
||||
# is gone with it), the SAME durable file: an ADD-ON restart. A Core-only
|
||||
# restart keeps the process; graded in part 8b (SAFETY-34).
|
||||
h2 = _DeliveryHass(b_soc=50.0)
|
||||
c2 = _ctrl(h2, store=shared)
|
||||
await c2.check_not_delivering()
|
||||
@@ -1250,6 +1250,40 @@ check("the operator's START press is the only way out, and it clears the "
|
||||
and _rs.data.get(unit_key("inverter-b", "delivery_reason")) == ""
|
||||
and _r2._delivery_announced == set())
|
||||
|
||||
print()
|
||||
print("8b. SAFETY-34: a Core-only restart - same add-on process, HA's memory wiped")
|
||||
import app.main as _main_mod # noqa: E402
|
||||
|
||||
|
||||
async def _core_restart():
|
||||
shared = _MemStore()
|
||||
c = _ctrl(_DeliveryHass(b_soc=50.0), store=shared)
|
||||
await _drive(c)
|
||||
return c
|
||||
|
||||
|
||||
_c = asyncio.run(_core_restart())
|
||||
_real_mono, _clock = _main_mod._mono, [_main_mod._mono()]
|
||||
_main_mod._mono = lambda: _clock[0]
|
||||
try:
|
||||
_c.hass = _DeliveryHass(b_soc=50.0)
|
||||
asyncio.run(_c.check_not_delivering())
|
||||
_early = [x for x in _c.hass.calls
|
||||
if "not_delivering" in str(x[2].get("notification_id", ""))]
|
||||
_clock[0] += _main_mod.REANNOUNCE_S
|
||||
asyncio.run(_c.check_not_delivering())
|
||||
_late = [x for x in _c.hass.calls
|
||||
if "not_delivering" in str(x[2].get("notification_id", ""))]
|
||||
finally:
|
||||
_main_mod._mono = _real_mono
|
||||
check("SAFETY-34: the latch tripped in this process",
|
||||
_c.inverters[1].delivery_wd.tripped)
|
||||
check("SAFETY-34: inside REANNOUNCE_S the same process does not re-raise",
|
||||
len(_early) == 0)
|
||||
check("SAFETY-34: after REANNOUNCE_S the SAME process re-asserts the card, "
|
||||
"because a Core-only restart wiped it and did not restart the add-on",
|
||||
len(_late) == 1 and "inverter_b" in _late[0][2]["notification_id"])
|
||||
|
||||
|
||||
print()
|
||||
if fails:
|
||||
|
||||
Reference in New Issue
Block a user