readd location_item attrs

This commit is contained in:
2026-06-12 07:23:43 -04:00
parent 6b5a1ea6ba
commit 466fe1493c
2 changed files with 24 additions and 7 deletions
BIN
View File
Binary file not shown.
@@ -1,6 +1,5 @@
import asyncio
import psutil
import datetime
import math
import random
import traceback
@@ -212,6 +211,16 @@ class SimulationService:
if isinstance(data, dict)
else getattr(data, "address", None)
)
item_type = (
data.get("type")
if isinstance(data, dict)
else getattr(data, "type", None)
)
instruction = (
data.get("instruction")
if isinstance(data, dict)
else getattr(data, "instruction", None)
)
try:
delay = self.parse_delay_seconds(delay)
except ValueError as e:
@@ -259,16 +268,24 @@ class SimulationService:
"status": "queued",
"start": new_time.isoformat(),
"address": address,
"instruction": instruction,
"type": item_type,
}
resp = {
"command_status": "OK",
"command_class": "simulation_control",
"command": "add",
"message": f"Location {loc_id} added to the queue",
"data": {
"simulation": self.get_simulation_status(),
"location_item": location_item,
},
"data":
{
"simulation":
{
"data":
{
loc_id: location_item,
}
}
}
}
self.add_item(loc_id, location_item)
await self.enqueue_next_simulation_item()
@@ -566,8 +583,8 @@ class SimulationService:
def get_uptime(self) -> float:
boot_time_timestamp = psutil.boot_time()
boot_time = datetime.datetime.fromtimestamp(boot_time_timestamp)
uptime = datetime.datetime.now() - boot_time
boot_time = datetime.fromtimestamp(boot_time_timestamp)
uptime = datetime.now() - boot_time
return uptime
def get_status(self) -> dict: