Debug: Add logging to publish_orion to trace POST vs PATCH
- Print entity ID before POST - Print 409 Conflict message explicitly - This will help understand why entities are not being created
This commit is contained in:
@@ -515,6 +515,8 @@ def publish_orion(sid: str, sensor: dict) -> bool:
|
||||
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()
|
||||
@@ -527,6 +529,8 @@ 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)")
|
||||
# 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
|
||||
|
||||
Reference in New Issue
Block a user