You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
683 B
Python
34 lines
683 B
Python
from pixelblaze import *
|
|
import paho.mqtt.client as mqtt
|
|
|
|
MQTT_HOST='192.168.1.1'
|
|
MQTT_PORT=1883
|
|
TOPIC = 'lcnc/job/progress'
|
|
|
|
PB_HOST = '192.168.0.161'
|
|
pb = Pixelblaze(PB_HOST)
|
|
|
|
def on_connect(client, userdata, flags, rc):
|
|
print('MQTT Connected')
|
|
|
|
try:
|
|
client.subscribe(TOPIC)
|
|
except: pass
|
|
|
|
# The callback for when a PUBLISH message is received from the server.
|
|
def on_message(client, userdata, msg):
|
|
p = float(msg.payload.decode('utf-8'))
|
|
pb.setVars({
|
|
'progress': p
|
|
})
|
|
|
|
client = mqtt.Client()
|
|
client.on_connect = on_connect
|
|
client.on_message = on_message
|
|
|
|
client.connect_async(MQTT_HOST, MQTT_PORT, 60)
|
|
|
|
client.loop_start()
|
|
|
|
while True: pass
|