Setup: Make Docker Compose, Scheduler, and Simclient fully operational
This commit is contained in:
24
simclient/simclient.py
Normal file
24
simclient/simclient.py
Normal file
@@ -0,0 +1,24 @@
|
||||
# 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()
|
||||
Reference in New Issue
Block a user