viri-leds-dmx-sacn/main.py

129 lines
3.2 KiB
Python
Raw Normal View History

2023-08-07 11:39:15 +00:00
#!/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 mqtt_queue import MQTTQueue
from lights.wled import WLED
from lights.ignition_wal_l710 import IgnitionWALL710
from lights.varytec_hero_wash_zoom_712 import VarytecHeroWashZoom712
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s %(name)20s [%(levelname)-8s] %(message)s',
)
LOG = logging.getLogger('main')
def main():
parser = ArgumentParser()
2023-08-07 12:45:01 +00:00
# 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)',
)
2023-08-07 11:39:15 +00:00
# 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')
2023-08-07 12:46:22 +00:00
parser.add_argument(
'--mqtt-topic',
default='/voc/alert',
help='mqtt topic to listen on, default /voc/alert',
)
2023-08-07 11:39:15 +00:00
# sACN
sacn = parser.add_mutually_exclusive_group(required=True)
2023-08-07 12:46:22 +00:00
sacn.add_argument(
'--sacn-multicast', action='store_true', help='use sACN multicast'
)
sacn.add_argument('--sacn-target', help='send sACN unicast to specified address')
2023-08-07 11:39:15 +00:00
# Lights
2023-08-07 12:46:22 +00:00
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'
)
2023-08-07 11:39:15 +00:00
args = parser.parse_args()
LOG.info('Welcome to Voc2DMX')
LOG.debug(args)
queue = Queue()
lights = []
2023-08-07 12:45:30 +00:00
for addr in args.ignition_wal_l710 or []:
2023-08-07 11:39:15 +00:00
lights.append(IgnitionWALL710(addr))
2023-08-07 12:45:30 +00:00
for addr in args.varytec_wash_zoom_712 or []:
lights.append(VarytecHeroWashZoom712(addr))
for addr in args.wled or []:
2023-08-07 11:39:15 +00:00
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()