Skip to content

Instantly share code, notes, and snippets.

mport paho.mqtt.client as mqtt
import time
import subprocess
def on_connect(client, userdata, flags, rc):
print("Connected with result code " + str(rc))
# Subscribing in on_connect() means that if we lose the connection and
# reconnect then subscriptions will be renewed.
client.subscribe([("homeassistant/piDisplay/switch/set", 1), ("homeassistant/piDisplay/brightness/set", 1)])