add start and stop mqtt loop

This commit is contained in:
robert 2024-02-01 07:31:15 +00:00
parent 2ab134d58a
commit a12cec5377

View File

@ -57,8 +57,10 @@ def subscribe(client: mqtt_client, topic):
def on_message(client, userdata, msg): def on_message(client, userdata, msg):
print(f"Received `{msg.payload.decode()}` from `{msg.topic}` topic") print(f"Received `{msg.payload.decode()}` from `{msg.topic}` topic")
client.loop_start()
client.subscribe(topic) client.subscribe(topic)
client.on_message = on_message client.on_message = on_message
client.loop_stop()
def monitor(charge_point_power): def monitor(charge_point_power):
try: try: