removed publishes in unescafrejhkjogitrj

Signed-off-by: Ebbe Baß <ebbe@ping-mee.de>
master
Ebbe Baß 2022-07-01 22:28:36 +02:00
parent aa27df6f57
commit 481b3c7194
1 changed files with 6 additions and 7 deletions

13
main.py
View File

@ -168,6 +168,7 @@ if __name__ == '__main__':
mode = 0
power = "True"
threading.Thread(target=lambda: app.run(host='0.0.0.0', port=80)).start()
mqttBroker ="homeassistant.ping-mee.local"
@ -177,6 +178,9 @@ if __name__ == '__main__':
client.connect(mqttBroker)
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):
print(f"Message received [{msg.topic}]: {msg.payload}")
if str(msg.topic) == "server-rack-led-1/power":
@ -203,22 +207,17 @@ if __name__ == '__main__':
try:
while True:
if power == "True":
client.publish("server-rack-led-1/power","True")
if mode == 0:
client.publish("server-rack-led-1/mode","0")
rainbowCycle(strip)
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)))
time.sleep(1)
else:
client.publish("server-rack-led-1/power","False")
setColor(strip, Color(0,0,0))
time.sleep(1)
except KeyboardInterrupt:
client.disconnect()
setColor(strip, Color(0,0,0))