Implement metadata capture
This commit is contained in:
@@ -49,6 +49,7 @@ def on_connect(client, userdata, flags, rc):
|
||||
print(f"Brain connected to MQTT Broker with result code {rc}")
|
||||
client.subscribe("nodes/+/checkin")
|
||||
client.subscribe("nodes/+/status")
|
||||
client.subscribe("nodes/+/metadata")
|
||||
|
||||
def on_message(client, userdata, msg):
|
||||
if MAIN_LOOP:
|
||||
@@ -109,6 +110,20 @@ async def handle_message(msg):
|
||||
if node_id in ACTIVE_NODES_CACHE:
|
||||
ACTIVE_NODES_CACHE[node_id].update(data)
|
||||
|
||||
elif event_type == "metadata":
|
||||
# Handle call start/end metadata events
|
||||
print(f"Metadata received from {node_id}: {payload.get('event')}")
|
||||
|
||||
doc_data = {
|
||||
"node_id": node_id,
|
||||
"received_at": timestamp,
|
||||
"event_type": payload.get("event"),
|
||||
"node_timestamp": payload.get("timestamp"),
|
||||
**payload.get("metadata", {})
|
||||
}
|
||||
|
||||
await async_firestore(db.collection("metadata").add, doc_data)
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error processing MQTT message from {node_id}: {e}")
|
||||
traceback.print_exc()
|
||||
|
||||
Reference in New Issue
Block a user