Stop stale-telemetry handling from overriding an active battery floor lock
This commit is contained in:
@@ -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,6 +893,17 @@ 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.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:
|
if self.stale_action_state is None:
|
||||||
self.pre_stale_state = self.last_commanded
|
self.pre_stale_state = self.last_commanded
|
||||||
self.stale_action_state = self.profile.safe_state
|
self.stale_action_state = self.profile.safe_state
|
||||||
@@ -956,6 +974,17 @@ 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.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:
|
if self.stale_action_state is None:
|
||||||
self.pre_stale_state = self.last_commanded
|
self.pre_stale_state = self.last_commanded
|
||||||
self.stale_action_state = self.profile.safe_state
|
self.stale_action_state = self.profile.safe_state
|
||||||
|
|||||||
Reference in New Issue
Block a user