Files
Smartwave/shared/payloads.py
T
Ninluc 2dd664c4b4
Build, push image, and notify Watchtower / build-image (push) Successful in 1m39s
Build, push image, and notify Watchtower / notify (push) Successful in 1m43s
UART & Sensors
2026-07-23 15:50:43 +02:00

23 lines
576 B
Python

try:
import ujson as json
except ImportError:
import json
def as_json(data):
"""Convert a dictionary to a JSON string."""
try:
return json.dumps(data)
except Exception as e:
print("[Payloads] Error converting to JSON:", e)
return "{}" # Return an empty JSON object on error
def mqtt_hello(id_microwave):
return as_json({
"id_microwave": id_microwave
})
def mqtt_hello_ack(id_orchestrator, id_microwave):
return as_json({
"id_microwave": id_microwave,
"id_orchestrator": id_orchestrator
})