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)
|
entity = _ngsi_payload(sid, sensor, source="simulator", topic=topic)
|
||||||
# Orion-LD est exposé sur localhost:2026 (hôte)
|
# Orion-LD est exposé sur localhost:2026 (hôte)
|
||||||
base = "http://localhost:2026/ngsi-ld/v1"
|
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)
|
# 1. Essayer de créer (POST)
|
||||||
try:
|
try:
|
||||||
body = json.dumps(entity).encode()
|
body = json.dumps(entity).encode()
|
||||||
@@ -527,6 +529,8 @@ def publish_orion(sid: str, sensor: dict) -> bool:
|
|||||||
if e.code != 409:
|
if e.code != 409:
|
||||||
print(f" ⚠️ Orion-LD → {e.code}: {e.read().decode()[:200]}")
|
print(f" ⚠️ Orion-LD → {e.code}: {e.read().decode()[:200]}")
|
||||||
return False
|
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)
|
# 2. Déjà existant (409) → PATCH sur les attributs (avec @context complet requis par Orion-LD)
|
||||||
try:
|
try:
|
||||||
# Orion-LD exige @context même dans le PATCH
|
# Orion-LD exige @context même dans le PATCH
|
||||||
|
|||||||
Reference in New Issue
Block a user