#!/usr/bin/env python3 import logging from argparse import ArgumentParser from queue import Queue from sys import exit from time import sleep from dmx_queue import DMXQueue from lights.ignition_wal_l710 import IgnitionWALL710 from lights.varytec_hero_wash_zoom_712 import VarytecHeroWashZoom712 from lights.wled import WLED from mqtt_queue import MQTTQueue logging.basicConfig( level=logging.DEBUG, format='%(asctime)s %(name)20s [%(levelname)-8s] %(message)s', ) LOG = logging.getLogger('main') def main(): parser = ArgumentParser() # rainbow is output if we have no effects parser.add_argument( '--rainbow-intensity', type=int, default=50, help='intensity of the rainbow colours in percent ("value" in HSV)', ) parser.add_argument( '--rainbow-brightness', type=int, default=150, help='brightness of the rainbow colour (dmx value of dimmer)', ) parser.add_argument( '--rainbow-speed', type=int, default=10, help='speed of rainbow colour change (ms per degree hue)', ) # MQTT parser.add_argument('--mqtt-host', required=True) parser.add_argument('--mqtt-port', type=int, default=1883) parser.add_argument('--mqtt-user') parser.add_argument('--mqtt-pass', '--mqtt-password') parser.add_argument( '--mqtt-topic', default='/voc/alert', help='mqtt topic to listen on, default /voc/alert', ) # sACN sacn = parser.add_mutually_exclusive_group(required=True) sacn.add_argument( '--sacn-multicast', action='store_true', help='use sACN multicast' ) sacn.add_argument('--sacn-target', help='send sACN unicast to specified address') # Lights parser.add_argument( '--ignition-wal-l710', nargs='+', type=int, help='dmx start addresses of Ignition WAL-L710', ) parser.add_argument( '--varytec-wash-zoom-712', nargs='+', type=int, help='dmx start addresses of Varytec Hero Wash 712 Z', ) parser.add_argument( '--wled', nargs='+', type=int, help='dmx start addresses of WLED receivers' ) args = parser.parse_args() LOG.info('Welcome to Voc2DMX') LOG.debug(args) queue = Queue() lights = [] for addr in args.ignition_wal_l710 or []: lights.append(IgnitionWALL710(addr)) for addr in args.varytec_wash_zoom_712 or []: lights.append(VarytecHeroWashZoom712(addr)) for addr in args.wled or []: lights.append(WLED(addr)) if not lights: LOG.error('No lights configured, please add atleast one fixture') exit(1) LOG.info('') LOG.info('Configured lights:') for light in lights: LOG.info(light) LOG.info('') LOG.info('Initializing worker queues ...') mqttq = MQTTQueue(args, queue) dmxq = DMXQueue(args, queue, lights) mqttq.start() dmxq.start() LOG.info('initialization done, now running. Press Ctrl-C to stop') try: while True: sleep(1) except KeyboardInterrupt: LOG.warning('Got interrupt, stopping queues ...') mqttq.stop() dmxq.stop() LOG.info('Bye!') if __name__ == '__main__': main()