Very useful script. I was able to use this as a starting point for implementing tally light updates over MQTT using the same infrastructure.
There are a few bugs to watch out for. Updating MQTT can cause the UI to freeze for a second while the MQTT process updates in the foreground, and because the updates are triggered by a 5 second periodic timer there is a slight delay before the message gets sent out.