removed publishes in unescafrejhkjogitrj
Signed-off-by: Ebbe Baß <ebbe@ping-mee.de>master
parent
aa27df6f57
commit
481b3c7194
13
main.py
13
main.py
|
@ -168,6 +168,7 @@ if __name__ == '__main__':
|
||||||
mode = 0
|
mode = 0
|
||||||
power = "True"
|
power = "True"
|
||||||
|
|
||||||
|
|
||||||
threading.Thread(target=lambda: app.run(host='0.0.0.0', port=80)).start()
|
threading.Thread(target=lambda: app.run(host='0.0.0.0', port=80)).start()
|
||||||
|
|
||||||
mqttBroker ="homeassistant.ping-mee.local"
|
mqttBroker ="homeassistant.ping-mee.local"
|
||||||
|
@ -177,6 +178,9 @@ if __name__ == '__main__':
|
||||||
client.connect(mqttBroker)
|
client.connect(mqttBroker)
|
||||||
client.on_connect = mqtt_on_connect
|
client.on_connect = mqtt_on_connect
|
||||||
|
|
||||||
|
client.publish("server-rack-led-1/power","True")
|
||||||
|
client.publish("server-rack-led-1/mode","0")
|
||||||
|
|
||||||
def mqtt_on_message(client, userdata, msg):
|
def mqtt_on_message(client, userdata, msg):
|
||||||
print(f"Message received [{msg.topic}]: {msg.payload}")
|
print(f"Message received [{msg.topic}]: {msg.payload}")
|
||||||
if str(msg.topic) == "server-rack-led-1/power":
|
if str(msg.topic) == "server-rack-led-1/power":
|
||||||
|
@ -203,22 +207,17 @@ if __name__ == '__main__':
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
if power == "True":
|
if power == "True":
|
||||||
client.publish("server-rack-led-1/power","True")
|
|
||||||
|
|
||||||
if mode == 0:
|
if mode == 0:
|
||||||
client.publish("server-rack-led-1/mode","0")
|
|
||||||
rainbowCycle(strip)
|
rainbowCycle(strip)
|
||||||
|
|
||||||
elif mode == 1:
|
elif mode == 1:
|
||||||
client.publish("server-rack-led-1/mode","1")
|
|
||||||
client.publish("server-rack-led-1/r",str(r))
|
|
||||||
client.publish("server-rack-led-1/g",str(g))
|
|
||||||
client.publish("server-rack-led-1/b",str(b))
|
|
||||||
setColor(strip, Color(int(r), int(g), int(b)))
|
setColor(strip, Color(int(r), int(g), int(b)))
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
else:
|
else:
|
||||||
client.publish("server-rack-led-1/power","False")
|
client.publish("server-rack-led-1/power","False")
|
||||||
setColor(strip, Color(0,0,0))
|
setColor(strip, Color(0,0,0))
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
client.disconnect()
|
client.disconnect()
|
||||||
setColor(strip, Color(0,0,0))
|
setColor(strip, Color(0,0,0))
|
||||||
|
|
Loading…
Reference in New Issue