Compare commits

...

1 Commits

Author SHA1 Message Date
Logan Cusano
81dccc89fc Implement metadata capture 2025-12-29 19:02:20 -05:00

View File

@@ -49,6 +49,7 @@ def on_connect(client, userdata, flags, rc):
print(f"Brain connected to MQTT Broker with result code {rc}") print(f"Brain connected to MQTT Broker with result code {rc}")
client.subscribe("nodes/+/checkin") client.subscribe("nodes/+/checkin")
client.subscribe("nodes/+/status") client.subscribe("nodes/+/status")
client.subscribe("nodes/+/metadata")
def on_message(client, userdata, msg): def on_message(client, userdata, msg):
if MAIN_LOOP: if MAIN_LOOP:
@@ -109,6 +110,20 @@ async def handle_message(msg):
if node_id in ACTIVE_NODES_CACHE: if node_id in ACTIVE_NODES_CACHE:
ACTIVE_NODES_CACHE[node_id].update(data) 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: except Exception as e:
print(f"Error processing MQTT message from {node_id}: {e}") print(f"Error processing MQTT message from {node_id}: {e}")
traceback.print_exc() traceback.print_exc()