Read lights from config file
This commit is contained in:
parent
b2862d3761
commit
71499e4e96
17
aquadmx.py
17
aquadmx.py
@ -17,16 +17,31 @@ def dmx_callback(data):
|
|||||||
transition=0,
|
transition=0,
|
||||||
rgb_color=[data[5], data[6], data[7]])
|
rgb_color=[data[5], data[6], data[7]])
|
||||||
|
|
||||||
# Home Assistant
|
def configList(key):
|
||||||
|
return [i.strip(' ') for i in config['Lights'][key].split(',')]
|
||||||
|
|
||||||
|
def configOptionalList(config, key):
|
||||||
|
if 'dimmer' in config:
|
||||||
|
return configList('dimmer')
|
||||||
|
else:
|
||||||
|
return []
|
||||||
|
|
||||||
|
# Configs
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
config.sections()
|
config.sections()
|
||||||
programPath = os.path.dirname(os.path.realpath(__file__))
|
programPath = os.path.dirname(os.path.realpath(__file__))
|
||||||
config.read('{}/settings.ini'.format(programPath))
|
config.read('{}/settings.ini'.format(programPath))
|
||||||
|
|
||||||
|
# Home Assistant
|
||||||
URL = '{}/api'.format(config['HomeAssistant']['url'])
|
URL = '{}/api'.format(config['HomeAssistant']['url'])
|
||||||
TOKEN = config['HomeAssistant']['token']
|
TOKEN = config['HomeAssistant']['token']
|
||||||
client = Client(URL, TOKEN)
|
client = Client(URL, TOKEN)
|
||||||
light = client.get_domain('light')
|
light = client.get_domain('light')
|
||||||
|
|
||||||
|
# Lights
|
||||||
|
configOptionalList(config['Lights'], 'dimmer')
|
||||||
|
configOptionalList(config['Lights'], 'rgb')
|
||||||
|
|
||||||
# DMX
|
# DMX
|
||||||
universe = 1
|
universe = 1
|
||||||
server = StupidArtnetServer()
|
server = StupidArtnetServer()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user