|
@@ -10,7 +10,7 @@ import logging
|
|
|
import ssl
|
|
import ssl
|
|
|
import threading
|
|
import threading
|
|
|
import time
|
|
import time
|
|
|
-from datetime import datetime
|
|
|
|
|
|
|
+from datetime import datetime, timezone
|
|
|
from typing import Any
|
|
from typing import Any
|
|
|
|
|
|
|
|
import paho.mqtt.client as mqtt
|
|
import paho.mqtt.client as mqtt
|
|
@@ -211,7 +211,7 @@ class MQTTRelayService:
|
|
|
"""Publish BamBuddy status (online/offline)."""
|
|
"""Publish BamBuddy status (online/offline)."""
|
|
|
self._publish(
|
|
self._publish(
|
|
|
f"{self.topic_prefix}/status",
|
|
f"{self.topic_prefix}/status",
|
|
|
- {"status": status, "timestamp": datetime.utcnow().isoformat()},
|
|
|
|
|
|
|
+ {"status": status, "timestamp": datetime.now(timezone.utc).isoformat()},
|
|
|
retain=True,
|
|
retain=True,
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -257,7 +257,7 @@ class MQTTRelayService:
|
|
|
"printer_id": printer_id,
|
|
"printer_id": printer_id,
|
|
|
"printer_name": printer_name,
|
|
"printer_name": printer_name,
|
|
|
"printer_serial": printer_serial,
|
|
"printer_serial": printer_serial,
|
|
|
- "timestamp": datetime.utcnow().isoformat(),
|
|
|
|
|
|
|
+ "timestamp": datetime.now(timezone.utc).isoformat(),
|
|
|
"connected": state.connected,
|
|
"connected": state.connected,
|
|
|
"state": state.state,
|
|
"state": state.state,
|
|
|
"progress": state.progress,
|
|
"progress": state.progress,
|
|
@@ -294,7 +294,7 @@ class MQTTRelayService:
|
|
|
"printer_id": printer_id,
|
|
"printer_id": printer_id,
|
|
|
"printer_name": printer_name,
|
|
"printer_name": printer_name,
|
|
|
"printer_serial": printer_serial,
|
|
"printer_serial": printer_serial,
|
|
|
- "timestamp": datetime.utcnow().isoformat(),
|
|
|
|
|
|
|
+ "timestamp": datetime.now(timezone.utc).isoformat(),
|
|
|
},
|
|
},
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -309,7 +309,7 @@ class MQTTRelayService:
|
|
|
"printer_id": printer_id,
|
|
"printer_id": printer_id,
|
|
|
"printer_name": printer_name,
|
|
"printer_name": printer_name,
|
|
|
"printer_serial": printer_serial,
|
|
"printer_serial": printer_serial,
|
|
|
- "timestamp": datetime.utcnow().isoformat(),
|
|
|
|
|
|
|
+ "timestamp": datetime.now(timezone.utc).isoformat(),
|
|
|
},
|
|
},
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -333,7 +333,7 @@ class MQTTRelayService:
|
|
|
"printer_serial": printer_serial,
|
|
"printer_serial": printer_serial,
|
|
|
"filename": filename,
|
|
"filename": filename,
|
|
|
"subtask_name": subtask_name,
|
|
"subtask_name": subtask_name,
|
|
|
- "timestamp": datetime.utcnow().isoformat(),
|
|
|
|
|
|
|
+ "timestamp": datetime.now(timezone.utc).isoformat(),
|
|
|
},
|
|
},
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -365,7 +365,7 @@ class MQTTRelayService:
|
|
|
"filename": filename,
|
|
"filename": filename,
|
|
|
"subtask_name": subtask_name,
|
|
"subtask_name": subtask_name,
|
|
|
"status": status,
|
|
"status": status,
|
|
|
- "timestamp": datetime.utcnow().isoformat(),
|
|
|
|
|
|
|
+ "timestamp": datetime.now(timezone.utc).isoformat(),
|
|
|
},
|
|
},
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -387,7 +387,7 @@ class MQTTRelayService:
|
|
|
"printer_name": printer_name,
|
|
"printer_name": printer_name,
|
|
|
"printer_serial": printer_serial,
|
|
"printer_serial": printer_serial,
|
|
|
"ams_units": ams_data,
|
|
"ams_units": ams_data,
|
|
|
- "timestamp": datetime.utcnow().isoformat(),
|
|
|
|
|
|
|
+ "timestamp": datetime.now(timezone.utc).isoformat(),
|
|
|
},
|
|
},
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -409,7 +409,7 @@ class MQTTRelayService:
|
|
|
"printer_name": printer_name,
|
|
"printer_name": printer_name,
|
|
|
"printer_serial": printer_serial,
|
|
"printer_serial": printer_serial,
|
|
|
"errors": errors,
|
|
"errors": errors,
|
|
|
- "timestamp": datetime.utcnow().isoformat(),
|
|
|
|
|
|
|
+ "timestamp": datetime.now(timezone.utc).isoformat(),
|
|
|
},
|
|
},
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -435,7 +435,7 @@ class MQTTRelayService:
|
|
|
"filename": filename,
|
|
"filename": filename,
|
|
|
"printer_id": printer_id,
|
|
"printer_id": printer_id,
|
|
|
"printer_name": printer_name,
|
|
"printer_name": printer_name,
|
|
|
- "timestamp": datetime.utcnow().isoformat(),
|
|
|
|
|
|
|
+ "timestamp": datetime.now(timezone.utc).isoformat(),
|
|
|
},
|
|
},
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -459,7 +459,7 @@ class MQTTRelayService:
|
|
|
"printer_id": printer_id,
|
|
"printer_id": printer_id,
|
|
|
"printer_name": printer_name,
|
|
"printer_name": printer_name,
|
|
|
"printer_serial": printer_serial,
|
|
"printer_serial": printer_serial,
|
|
|
- "timestamp": datetime.utcnow().isoformat(),
|
|
|
|
|
|
|
+ "timestamp": datetime.now(timezone.utc).isoformat(),
|
|
|
},
|
|
},
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -489,7 +489,7 @@ class MQTTRelayService:
|
|
|
"printer_id": printer_id,
|
|
"printer_id": printer_id,
|
|
|
"printer_name": printer_name,
|
|
"printer_name": printer_name,
|
|
|
"status": status,
|
|
"status": status,
|
|
|
- "timestamp": datetime.utcnow().isoformat(),
|
|
|
|
|
|
|
+ "timestamp": datetime.now(timezone.utc).isoformat(),
|
|
|
},
|
|
},
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -517,7 +517,7 @@ class MQTTRelayService:
|
|
|
"maintenance_type": maintenance_type,
|
|
"maintenance_type": maintenance_type,
|
|
|
"current_value": current_value,
|
|
"current_value": current_value,
|
|
|
"threshold": threshold,
|
|
"threshold": threshold,
|
|
|
- "timestamp": datetime.utcnow().isoformat(),
|
|
|
|
|
|
|
+ "timestamp": datetime.now(timezone.utc).isoformat(),
|
|
|
},
|
|
},
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -537,7 +537,7 @@ class MQTTRelayService:
|
|
|
"printer_id": printer_id,
|
|
"printer_id": printer_id,
|
|
|
"printer_name": printer_name,
|
|
"printer_name": printer_name,
|
|
|
"maintenance_type": maintenance_type,
|
|
"maintenance_type": maintenance_type,
|
|
|
- "timestamp": datetime.utcnow().isoformat(),
|
|
|
|
|
|
|
+ "timestamp": datetime.now(timezone.utc).isoformat(),
|
|
|
},
|
|
},
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -557,7 +557,7 @@ class MQTTRelayService:
|
|
|
"printer_id": printer_id,
|
|
"printer_id": printer_id,
|
|
|
"printer_name": printer_name,
|
|
"printer_name": printer_name,
|
|
|
"maintenance_type": maintenance_type,
|
|
"maintenance_type": maintenance_type,
|
|
|
- "timestamp": datetime.utcnow().isoformat(),
|
|
|
|
|
|
|
+ "timestamp": datetime.now(timezone.utc).isoformat(),
|
|
|
},
|
|
},
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -583,7 +583,7 @@ class MQTTRelayService:
|
|
|
"print_name": print_name,
|
|
"print_name": print_name,
|
|
|
"printer_name": printer_name,
|
|
"printer_name": printer_name,
|
|
|
"status": status,
|
|
"status": status,
|
|
|
- "timestamp": datetime.utcnow().isoformat(),
|
|
|
|
|
|
|
+ "timestamp": datetime.now(timezone.utc).isoformat(),
|
|
|
},
|
|
},
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -603,7 +603,7 @@ class MQTTRelayService:
|
|
|
"archive_id": archive_id,
|
|
"archive_id": archive_id,
|
|
|
"print_name": print_name,
|
|
"print_name": print_name,
|
|
|
"status": status,
|
|
"status": status,
|
|
|
- "timestamp": datetime.utcnow().isoformat(),
|
|
|
|
|
|
|
+ "timestamp": datetime.now(timezone.utc).isoformat(),
|
|
|
},
|
|
},
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -629,7 +629,7 @@ class MQTTRelayService:
|
|
|
"spool_name": spool_name,
|
|
"spool_name": spool_name,
|
|
|
"remaining_weight": remaining_weight,
|
|
"remaining_weight": remaining_weight,
|
|
|
"remaining_percent": remaining_percent,
|
|
"remaining_percent": remaining_percent,
|
|
|
- "timestamp": datetime.utcnow().isoformat(),
|
|
|
|
|
|
|
+ "timestamp": datetime.now(timezone.utc).isoformat(),
|
|
|
},
|
|
},
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -659,7 +659,7 @@ class MQTTRelayService:
|
|
|
"state": state,
|
|
"state": state,
|
|
|
"printer_id": printer_id,
|
|
"printer_id": printer_id,
|
|
|
"printer_name": printer_name,
|
|
"printer_name": printer_name,
|
|
|
- "timestamp": datetime.utcnow().isoformat(),
|
|
|
|
|
|
|
+ "timestamp": datetime.now(timezone.utc).isoformat(),
|
|
|
},
|
|
},
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -683,7 +683,7 @@ class MQTTRelayService:
|
|
|
"power_watts": power,
|
|
"power_watts": power,
|
|
|
"energy_today_kwh": energy_today,
|
|
"energy_today_kwh": energy_today,
|
|
|
"energy_total_kwh": energy_total,
|
|
"energy_total_kwh": energy_total,
|
|
|
- "timestamp": datetime.utcnow().isoformat(),
|
|
|
|
|
|
|
+ "timestamp": datetime.now(timezone.utc).isoformat(),
|
|
|
},
|
|
},
|
|
|
)
|
|
)
|
|
|
|
|
|