Signed-off-by: Ebbe Baß <ebbe.bass>
main
Ebbe Baß 2024-02-16 00:12:10 +01:00
parent e48a43710e
commit 8fd0ee3ec9
1 changed files with 12 additions and 11 deletions

View File

@ -119,17 +119,18 @@ def start_mqtt_publishers():
# Gets whatever the last Art-Net packet we received is # Gets whatever the last Art-Net packet we received is
artNetPacket = artNet.readPacket() artNetPacket = artNet.readPacket()
# Make sure we actually *have* a packet # Make sure we actually *have* a packet
#Checks to see if the current packet is for the specified DMX Universe if artNetPacket is not None and artNetPacket.data is not None:
dmxPacket = artNetPacket.data #Checks to see if the current packet is for the specified DMX Universe
for i in range(512): dmxPacket = artNetPacket.data
try: for i in range(512):
# Create MQTT topic based on the universe and channel try:
topic = f"{str(artNetPacket.universe)}/{str(i)}" # Create MQTT topic based on the universe and channel
topic = f"{str(artNetPacket.universe)}/{str(i)}"
# Publish the DMX value to the MQTT topic
mqtt_client.publish(topic, str(dmxPacket[i-1])) # Publish the DMX value to the MQTT topic
except KeyboardInterrupt: mqtt_client.publish(topic, str(dmxPacket[i-1]))
break except KeyboardInterrupt:
break
time.sleep(0.01) time.sleep(0.01)
except Exception as e: except Exception as e:
print(e) print(e)