41 lines
1.2 KiB
Python
41 lines
1.2 KiB
Python
import configparser
|
|
import time
|
|
import os
|
|
|
|
from stupidArtnet import StupidArtnetServer
|
|
|
|
from homeassistant_api import Processing, Client
|
|
from homeassistant_api.processing import process_json
|
|
|
|
def dmx_callback(data):
|
|
light.turn_on(entity_id='light.christian_s_bedroom_left_desk_lamp',
|
|
brightness=data[0],
|
|
transition=0,
|
|
rgb_color=[data[1], data[2], data[3]])
|
|
light.turn_on(entity_id='light.christian_s_bedroom_lamp_right',
|
|
brightness=data[4],
|
|
transition=0,
|
|
rgb_color=[data[5], data[6], data[7]])
|
|
|
|
# Home Assistant
|
|
config = configparser.ConfigParser()
|
|
config.sections()
|
|
programPath = os.path.dirname(os.path.realpath(__file__))
|
|
config.read('{}/settings.ini'.format(programPath))
|
|
URL = '{}/api'.format(config['HomeAssistant']['url'])
|
|
TOKEN = config['HomeAssistant']['token']
|
|
client = Client(URL, TOKEN)
|
|
light = client.get_domain('light')
|
|
|
|
# DMX
|
|
universe = 1
|
|
server = StupidArtnetServer()
|
|
u1_listener = server.register_listener(universe,
|
|
callback_function=dmx_callback)
|
|
|
|
# Start server
|
|
print('AquaDMX is listening')
|
|
while True:
|
|
time.sleep(1)
|
|
pass
|