added decode

Signed-off-by: Ebbe Baß <ebbe.bass>
main
Ebbe Baß 2024-02-17 03:56:32 +01:00
parent 77e5bb8213
commit af4a49f149
1 changed files with 7 additions and 7 deletions

View File

@ -63,30 +63,30 @@ def update_led_strip(rgb_values, pixel, strip):
print("Updated pixel "+str(pixel)+" with "+str(rgb_values))
def on_message(mqttc, obj, msg):
print(msg.payload)
rgb_values = msg.payload.decode()
if msg.topic == "tube-"+wlan_mac_address+"/p1":
for pixel in range(LEDS_PER_PIXEL):
update_led_strip(msg.payload, pixel, strip)
update_led_strip(rgb_values, pixel, strip)
elif msg.topic == "tube-"+wlan_mac_address+"/p2":
for pixel in range(LEDS_PER_PIXEL, LEDS_PER_PIXEL*2):
update_led_strip(msg.payload, pixel, strip)
update_led_strip(rgb_values, pixel, strip)
elif msg.topic == "tube-"+wlan_mac_address+"/p3":
for pixel in range(LEDS_PER_PIXEL*2, LEDS_PER_PIXEL*3):
update_led_strip(msg.payload, pixel, strip)
update_led_strip(rgb_values, pixel, strip)
elif msg.topic == "tube-"+wlan_mac_address+"/p4":
for pixel in range(LEDS_PER_PIXEL*3, LEDS_PER_PIXEL*4):
update_led_strip(msg.payload, pixel, strip)
update_led_strip(rgb_values, pixel, strip)
elif msg.topic == "tube-"+wlan_mac_address+"/p5":
for pixel in range(LEDS_PER_PIXEL*4, LEDS_PER_PIXEL*5):
update_led_strip(msg.payload, pixel, strip)
update_led_strip(rgb_values, pixel, strip)
elif msg.topic == "tube-"+wlan_mac_address+"/p6":
for pixel in range(LEDS_PER_PIXEL*5, LEDS_PER_PIXEL*6):
update_led_strip(msg.payload, pixel, strip)
update_led_strip(rgb_values, pixel, strip)
if __name__ == "__main__":
# Connect to Wi-Fi