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
This commit is contained in:
@@ -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."""
|
||||
|
||||
Reference in New Issue
Block a user