viri-leds-dmx-sacn/main.py

81 lines
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
2023-08-07 18:05:20 +00:00
from conf import load_and_validate_config
2023-08-07 11:39:15 +00:00
from dmx_queue import DMXQueue
from lights.ignition_wal_l710 import IgnitionWALL710
from lights.stairville_par_56 import StairvillePar56
2023-08-07 11:39:15 +00:00
from lights.varytec_hero_wash_zoom_712 import VarytecHeroWashZoom712
2023-08-07 12:48:18 +00:00
from lights.wled import WLED
from mqtt_queue import MQTTQueue
2023-08-07 11:39:15 +00:00
logging.basicConfig(
2023-08-07 13:06:38 +00:00
level=logging.INFO,
2023-08-07 11:39:15 +00:00
format='%(asctime)s %(name)20s [%(levelname)-8s] %(message)s',
)
LOG = logging.getLogger('main')
2023-08-07 12:48:18 +00:00
def main():
2023-08-07 11:39:15 +00:00
parser = ArgumentParser()
2023-08-07 12:46:22 +00:00
parser.add_argument(
2023-08-07 18:05:20 +00:00
'--config',
default='config.toml',
2023-08-07 12:46:22 +00:00
)
2023-08-07 11:39:15 +00:00
args = parser.parse_args()
2023-08-07 18:05:20 +00:00
config = load_and_validate_config(args.config)
2023-08-07 11:39:15 +00:00
LOG.info('Welcome to Voc2DMX')
queue = Queue()
lights = []
for addr in config.lights.get('ignition_wal_l710', []):
2023-08-07 11:39:15 +00:00
lights.append(IgnitionWALL710(addr))
for addr in config.lights.get('stairville_par_56', []):
lights.append(StairvillePar56(addr))
for addr in config.lights.get('varytec_hero_wash_712_zoom', []):
2023-08-07 12:45:30 +00:00
lights.append(VarytecHeroWashZoom712(addr))
for addr in config.lights.get('wled_multi_rgb', []):
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 ...')
2023-08-07 18:05:20 +00:00
mqttq = MQTTQueue(config, queue)
dmxq = DMXQueue(config, queue, lights)
2023-08-07 11:39:15 +00:00
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!')
2023-08-07 12:48:18 +00:00
2023-08-07 11:39:15 +00:00
if __name__ == '__main__':
main()