docs/dev: sync backend rework, MQTT, and devcontainer hygiene
README: add Versioning (unified SemVer, pre-releases, build metadata); emphasize UTC handling and streaming endpoint; add Dev Container notes (UI-only Remote Containers, npm ci, idempotent aliases) TECH-CHANGELOG: backend rework notes (serialization camelCase, UTC normalization, streaming metadata); add component build metadata template (image tags/SHAs) Copilot instructions: integrate maintenance guardrails; reinforce UTC and camelCase conventions; document MQTT topics and scheduler retained payload behavior Devcontainer: map Remote Containers to UI; remove in-container install; switch to npm ci; make aliases idempotent
This commit is contained in:
@@ -26,6 +26,17 @@ engine = create_engine(DB_URL)
|
||||
Session = sessionmaker(bind=engine)
|
||||
|
||||
|
||||
def on_connect(client, userdata, flags, reasonCode, properties):
|
||||
"""Callback for when client connects or reconnects (API v2)."""
|
||||
try:
|
||||
# Subscribe on every (re)connect so we don't miss heartbeats after broker restarts
|
||||
client.subscribe("infoscreen/discovery")
|
||||
client.subscribe("infoscreen/+/heartbeat")
|
||||
logging.info(f"MQTT connected (reasonCode: {reasonCode}); (re)subscribed to discovery and heartbeats")
|
||||
except Exception as e:
|
||||
logging.error(f"Subscribe failed on connect: {e}")
|
||||
|
||||
|
||||
def on_message(client, userdata, msg):
|
||||
topic = msg.topic
|
||||
logging.debug(f"Empfangene Nachricht auf Topic: {topic}")
|
||||
@@ -87,14 +98,14 @@ def on_message(client, userdata, msg):
|
||||
|
||||
|
||||
def main():
|
||||
mqtt_client = mqtt.Client(protocol=mqtt.MQTTv311, callback_api_version=2)
|
||||
mqtt_client = mqtt.Client(protocol=mqtt.MQTTv311, callback_api_version=mqtt.CallbackAPIVersion.VERSION2)
|
||||
mqtt_client.on_message = on_message
|
||||
mqtt_client.on_connect = on_connect
|
||||
# Set an exponential reconnect delay to survive broker restarts
|
||||
mqtt_client.reconnect_delay_set(min_delay=1, max_delay=60)
|
||||
mqtt_client.connect("mqtt", 1883)
|
||||
mqtt_client.subscribe("infoscreen/discovery")
|
||||
mqtt_client.subscribe("infoscreen/+/heartbeat")
|
||||
|
||||
logging.info(
|
||||
"Listener gestartet und abonniert auf infoscreen/discovery und infoscreen/+/heartbeat")
|
||||
logging.info("Listener gestartet; warte auf MQTT-Verbindung und Nachrichten")
|
||||
mqtt_client.loop_forever()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user