Stop stale-telemetry handling from overriding an active battery floor lock

This commit is contained in:
justin committed 2026-08-24 10:41:32 -07:00
1 parent f05ebceefc
commit 3007c1caa1
1 file changed
+49 -20
+49 -20
View File
@@ -543,6 +543,13 @@ class Engine:
self.stale_action_state = None self.stale_action_state = None
self.pre_stale_state = None self.pre_stale_state = None
if self.floor_latched:
self.report(
"battery floor is still active, not restoring pre-outage state",
force=True,
)
return
if previous is None or previous == applied: if previous is None or previous == applied:
return return
@@ -886,16 +893,27 @@ class Engine:
if self.profile.on_stale == "stop": if self.profile.on_stale == "stop":
raise RuntimeError("stopping: MQTT session disconnected") raise RuntimeError("stopping: MQTT session disconnected")
if self.profile.on_stale == "safe_state": if self.profile.on_stale == "safe_state":
if self.stale_action_state is None: if self.floor_latched:
self.pre_stale_state = self.last_commanded floor_state = self.profile.battery_floor.desired_state()
self.stale_action_state = self.profile.safe_state await self.apply(
await self.apply( session,
session, floor_state,
self.profile.safe_state, "battery floor holding through a lost connection",
"connection to Anker lost", now,
now, force=True,
cause="stale", cause="floor",
) )
else:
if self.stale_action_state is None:
self.pre_stale_state = self.last_commanded
self.stale_action_state = self.profile.safe_state
await self.apply(
session,
self.profile.safe_state,
"connection to Anker lost",
now,
cause="stale",
)
if not self.stale_notified: if not self.stale_notified:
self.stale_notified = True self.stale_notified = True
@@ -956,16 +974,27 @@ class Engine:
if self.profile.on_stale == "stop": if self.profile.on_stale == "stop":
raise RuntimeError("stopping: telemetry went stale") raise RuntimeError("stopping: telemetry went stale")
if self.profile.on_stale == "safe_state": if self.profile.on_stale == "safe_state":
if self.stale_action_state is None: if self.floor_latched:
self.pre_stale_state = self.last_commanded floor_state = self.profile.battery_floor.desired_state()
self.stale_action_state = self.profile.safe_state await self.apply(
await self.apply( session,
session, floor_state,
self.profile.safe_state, "battery floor holding through stale telemetry",
"telemetry went stale", now,
now, force=True,
cause="stale", cause="floor",
) )
else:
if self.stale_action_state is None:
self.pre_stale_state = self.last_commanded
self.stale_action_state = self.profile.safe_state
await self.apply(
session,
self.profile.safe_state,
"telemetry went stale",
now,
cause="stale",
)
return return
if self.stale_reported: if self.stale_reported: