Update state_manager.py

This commit is contained in:
DJObleezy 2025-03-26 10:32:43 -07:00 committed by GitHub
parent 7b7f386a2d
commit b9993a12f1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -93,7 +93,7 @@ class StateManager:
arrow_history[key] = [ arrow_history[key] = [
{"time": entry.get("t", ""), {"time": entry.get("t", ""),
"value": entry.get("v", 0), "value": entry.get("v", 0),
"arrow": ""} # Default empty arrow "arrow": entry.get("a", "")} # Use saved arrow value
for entry in values for entry in values
] ]
@ -146,9 +146,9 @@ class StateManager:
if isinstance(values, list) and values: if isinstance(values, list) and values:
# Only store recent history (last 2 hours) # Only store recent history (last 2 hours)
recent_values = values[-120:] if len(values) > 120 else values recent_values = values[-120:] if len(values) > 120 else values
# Use shorter field names and remove unnecessary fields # Use shorter field names and preserve arrow directions
compact_arrow_history[key] = [ compact_arrow_history[key] = [
{"t": entry["time"], "v": entry["value"]} {"t": entry["time"], "v": entry["value"], "a": entry["arrow"]}
for entry in recent_values for entry in recent_values
] ]