Basic working DMX server
This commit is contained in:
commit
ec9a186b16
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
settings.ini
|
9
README.md
Normal file
9
README.md
Normal file
@ -0,0 +1,9 @@
|
||||
# AquaDMX
|
||||
|
||||
A custom DMX server that integrates with Home Assistant.
|
||||
|
||||
## Setup
|
||||
|
||||
```sh
|
||||
pip install -r requirements.txt
|
||||
```
|
40
aquadmx.py
Normal file
40
aquadmx.py
Normal file
@ -0,0 +1,40 @@
|
||||
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 = 'https://{}/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
|
2
requirements.txt
Normal file
2
requirements.txt
Normal file
@ -0,0 +1,2 @@
|
||||
homeassistant_api
|
||||
stupidartnet
|
Loading…
x
Reference in New Issue
Block a user