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

This commit is contained in:
Justin Oro
2026-08-24 10:41:32 -07:00
parent f05ebceefc
commit 3007c1caa1
+29
View File
@@ -543,6 +543,13 @@ class Engine:
self.stale_action_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:
return
@@ -886,6 +893,17 @@ class Engine:
if self.profile.on_stale == "stop":
raise RuntimeError("stopping: MQTT session disconnected")
if self.profile.on_stale == "safe_state":
if self.floor_latched:
floor_state = self.profile.battery_floor.desired_state()
await self.apply(
session,
floor_state,
"battery floor holding through a lost connection",
now,
force=True,
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
@@ -956,6 +974,17 @@ class Engine:
if self.profile.on_stale == "stop":
raise RuntimeError("stopping: telemetry went stale")
if self.profile.on_stale == "safe_state":
if self.floor_latched:
floor_state = self.profile.battery_floor.desired_state()
await self.apply(
session,
floor_state,
"battery floor holding through stale telemetry",
now,
force=True,
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