Files
infoscreen/simclient/simclient.py

25 lines
585 B
Python

# simclient/simclient.py
import time
import paho.mqtt.client as mqtt
def on_message(client, userdata, msg):
print(f"Empfangen: {msg.topic} {msg.payload.decode()}")
def main():
client = mqtt.Client()
client.on_message = on_message
# Im Docker-Netzwerk: Hostname des MQTT-Brokers ist "mqtt"
client.connect("mqtt", 1883)
client.subscribe("infoscreen/+/now")
while True:
# Heartbeat senden
client.publish("infoscreen/client1/heartbeat", "alive")
client.loop(timeout=1.0)
time.sleep(5)
if __name__ == "__main__":
main()