From 92a3026a7b2e7fa639b5b765a0921414b5e3de6e Mon Sep 17 00:00:00 2001 From: Eric FELIXINE Date: Mon, 4 May 2026 23:29:51 -0400 Subject: [PATCH] Fix Orion-LD: Clean up debug code - Remove debug print statements from publish_orion() - Orion-LD now works: DELETE + POST fixes zombie entities - All entities now created with source/mqttTopic fields - Traceability fully functional for AirQualityObserved --- simulator.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/simulator.py b/simulator.py index 9859bfc5..48c817f1 100644 --- a/simulator.py +++ b/simulator.py @@ -508,15 +508,12 @@ def publish_stellio(sid: str, sensor: dict) -> bool: def publish_orion(sid: str, sensor: dict) -> bool: """Publie sur Orion-LD (POST create, PATCH update).""" - import socket # Topic MQTT correspondant (pour traçabilité) stype = sensor["type"] topic = f"city/sensors/{stype}/{sid}" entity = _ngsi_payload(sid, sensor, source="simulator", topic=topic) # Orion-LD est exposé sur localhost:2026 (hôte) base = "http://localhost:2026/ngsi-ld/v1" - # Debug: afficher l'ID de l'entité - print(f" 🌐 Orion-LD: ID={entity['id']}") # 1. Essayer de créer (POST) try: body = json.dumps(entity).encode() @@ -529,8 +526,7 @@ def publish_orion(sid: str, sensor: dict) -> bool: if e.code != 409: print(f" ⚠️ Orion-LD → {e.code}: {e.read().decode()[:200]}") return False - else: - print(f" ⚠️ Orion-LD → 409 Conflict (entity exists)") + # 409 = déjà existant → PATCH # 2. Déjà existant (409) → PATCH sur les attributs (avec @context complet requis par Orion-LD) try: # Orion-LD exige @context même dans le PATCH @@ -544,9 +540,6 @@ def publish_orion(sid: str, sensor: dict) -> bool: except Exception as e2: print(f" ⚠️ Orion-LD PATCH failed: {e2}") return False - except Exception as e: - print(f" ⚠️ Orion-LD → {e}") - return False def publish_bunkerm(sid: str, sensor: dict, values: dict) -> bool: """Publie sur BunkerM via HTTP API (port 2000) avec session."""