initial commit of mqtt client

This commit is contained in:
Linkis112 2025-09-11 13:54:49 +02:00
parent 337fb76e30
commit cc3a21b0d1

View file

@ -7,9 +7,10 @@ def on_connect(client, userdata, flags, reason_code, properties):
print(f"Connected with result code {reason_code}") print(f"Connected with result code {reason_code}")
# Subscribing in on_connect() means that if we lose the connection and # Subscribing in on_connect() means that if we lose the connection and
# reconnect then subscriptions will be renewed. # reconnect then subscriptions will be renewed.
client.subscribe("$SYS/#") #client.subscribe("$SYS/#")
client.subscribe('test/hallo') client.subscribe('test/topic')
client.subscribe('homeassistant/status') client.subscribe('homeassistant/status')
publish.single('test/topic', 'Hello, MQTT!', hostname='192.168.188.30', auth={'username': 'mqtt', 'password': 'mqtt'})
# The callback for when a PUBLISH message is received from the server. # The callback for when a PUBLISH message is received from the server.