Use DMX in Rocrail (in combination with HA)


I have all my lights in my modelrailroad room connected with DMX.
I can control it from within Home Assistant, and since shortly, also from within Rocrail at the same time !
(A BIG thank you to Rob Versluis, to update the DMX module within Rocrail to the newest standards)
As DMX controller, I use a RPI Zero 2W with OLA installed on it, but in theory it should work with every DMX controller that can get it’s data via Ethernet.

1. Install OLA
You need a Raspberry Pi with a “Raspberry Pi OS Lite” installed on it.
Follow the tutorial on https://www.openlighting.otrg/ola/tutorials/ola-on-raspberry-pi/ to install OLA.
After installation, you can further configure OLA via a webbrowser. Point it to http://rpi_ip_address:9090
Make sure you have at least a DMX controller connected (via USB) and configure it with the correct .conf file. (Disable all other DMX controllers in their corresponding .conf file)
Connect a DMX lighting to this DMX controller, and try to control it with OLA. (setup at a universe)
If everything works fine, you can go to the next step.

2. Control it from within Home Assistant
Install “ArtNet LED Lighting for DMX” via HACS.
Checkout https://github.com/Breina/ha-artnet-led for instructions and download.
Insert a definition for a least one DMX light, inside your /homeassistant/configuration.yaml
(Check out the github page for configuration syntax)
I have all my lights in my modelrailroad room connected with DMX.

light:
  - platform: artnet_led
    host: 192.168.123.84                  # IP of Art-Net Node
    max_fps: 15                                # Max 40 per second
    refresh_every: 0                          # Resend values if no fades are running every x seconds, 0 disables automatic refresh
    node_type: artnet-direct              # Which protocol to use
    universes:                                    # Support for multiple universes
      1:                                               # Nr of Universe (see configuration of your Art-Net Node)
        send_partial_universe: True    # Only send the universe which   contains data
        devices:
             - channel: 1
                name: main_spot_1
                type: rgb
             - channel: 4
                name: main_spot_2
                type: rgb

After a reboot of Home Assistant, you will have 2 new light-entities, named main_spot_1 and main_spot_2.
You can control them as every regular light (color/intensity/on/off) and use them in automations.

3. Control it from within Rocrail
Startup Rocrail, and add a (new) controller op type “DmxArtNet”.
as hostname, enter the IP address of your DMX controller (in our case, the IP of the RPI Zero 2W).
As Broadcast, type in the same IP address, but replace the last digit with 255.
Universe is the universe number that you defined in OLA.

Next, add an output / accessory to your track-plan, right-click on it, and select “properties.
On the “Interface” tab, make sure you select “artnode” as the interface ID.
Address should be the same as the DMX address you gave to your DMX lighting fixture.

On the “Color” tab, there are a few things you also need to set.
The red/green/blue number, needs to correspond to your DMX color channel.
If you have and RGBW fixture, you also can set the “white 1” address, and if you have an RGBWW
fixture, you can even set the “white 2” address. (if not used, leave these channel values to 0)

For some extra examples, take a look at https://wiki.rocrail.net/doku.php?id=dmx:artnet-en#dmx_example
If you are looking for weather and/or daylight simulation information, take a look at https://wiki.rocrail.net/doku.php?id=weather-en&s[]=weather

4. Control priority between Rocrail and Home Assistant
You can control the DMX lighting with both Rocrail and Home Assistant simultanuously !
There are 2 ways to do this: LTP (Latest takes precedence) or HTP (Highest takes precedence).
You can set this in OLA, via the webinterface, in the defined universe, with the “Merge Mode” Dropdown.

LTP means that the latest action is always the highest priority.
– If you set your lights to a certain value with HA, and change these values later on in Rocrail, then the Rocrail values are shown. (This works the other way around also of course)

HTP means that the highest value, is always the highest priority.
– If you set your lights to “off” within HA, and you start your day/light simulation, you will see your Rocrail light values reflected. If you set your lights to “bright” in HA,
and you start your day/light simulation in Rocrail, your lights will still stay on at the brightest value (from HA)
– If your day/light simulation goes from completely dark to some bright values, and you set your HA light values to somewhere not completely dark,
it means that your lights will not go out completely, but will use the HA values as the lowest light values. Everything above this lowest value, will be taken from Rocrail.

As you see, both LTP and HTP does have their (dis)advantages … If you think logically, you can accomplish a lot with both features … Choose wisely 🙂

This entry was posted in Blog, Home Assistant, Railroading. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *