Breina / ha-artnet-led

DMX lighting Integration for Home Assistant. Using the HA Color Mode update and Pyartnet library to control lights in multiple DMX universes over ethernet with the Art-Net protocol.
MIT License
124 stars 10 forks source link

Feature request: Control multiple Artnet interfaces #33

Closed Wim-N closed 1 year ago

Wim-N commented 1 year ago

We would like to connect multiple Artnet interface to a single HA.

It could look like this:

- platform: artnet_led1
  host: IP1                              # IP of Art-Net Node number 1
......
- platform: artnet_led2
  host: IP2                              # IP of Art-Net Node number 1

We now use 1 ArtNet interface that works very well (ShowTec Net-2/3Pocket) but we would like to use it for different rooms. Combining the DMX of all the rooms is not possible because of overlapping addresses (we use the merge function of the ShowTec). So we would like to use multiple ArtNet interfaces controlled from the same HA computer.

Breina commented 1 year ago

Not at my computer right now, so can't test myself. What error are you seeing when defining multiple artnet_led platforms with a different IP? Pretty sure this should be possible already.

Wim-N commented 1 year ago

Have not tried it yet because I have only 1 Artnet interface at the moment. I'll get another interface and see what happens. Thanks!

Wim-N commented 1 year ago

I have tried it. This is what I have done. Used 2 separate ArtNET interfaces with different IP addresses in the same network. In HA I've copied the section about DMX and changed the IP address and the name of the lights associated with the DMX channels so the names are all unique. Let's call the first ArtNET controller 'A' and the second 'B'. This is what happened. When I start HA and use 'A' it all works fine. I can control the lights and it all works. When I try to control lights on 'B' that does not work. And something hangs in HA. I cannot use the editor anymore and HA restart and reboot also does not work so I had to power-cycle the Raspberry Pi4 that I use to run HA. After starting HA and I use 'B' it all works fine, but when I use 'A' then it gives the same problem as described before. So you can define multiple instances of the DMX integration but when you use them both something crashes and HA becomes unstable. It looks like it that internally HA can not make a full difference between both DMX instances. Or did I had to change more than only the IP address and the name of the lights associated with the DMX channels??

Breina commented 1 year ago

Sorry to hear that it's not working, I understand it's specially annoying having to power cycle it!

I've re-tested it to make sure, and it really should just work. To make sure, that there's no dumb mistakes, can you please copy your configuration over here, so that I can match your setup for testing here?

It's possible that the entity registry is messed up from previous experiments. So here's a procedure to do a clean install of the integration;

  1. First remove this integration through HACS
  2. Comment or remove the YAML config
  3. Restart
  4. Delete all light antities of artnet_led
  5. Install this integration and re-introduce the config
  6. Restart
Wim-N commented 1 year ago

Ok, thanks. I'll try this.

Wim-N commented 1 year ago

I think the best test would be to use a fresh install of HA on a USB stick and start from that. Do you have a config example for using 2 ArtNET interfaces with each 1 or 2 DMX addresses being used. So I can check with that configuration.

Breina commented 1 year ago

Yeah I run a Dockerfile to just start a new instance from scratch every time for development. Here's an example with two ArtNet nodes:

light:
  - platform: artnet_led
    host: 192.168.1.15
    max_fps: 43
    refresh_every: 0
    node_type: artnet-controller
    universes:
      0:
        send_partial_universe: True
        output_correction: quadratic
        devices:
          - channel: 13
            name: Test light
            type: color_temp
            transition: 1
            channel_size: 16bit
#            min_temp: 2500K
#            max_temp: 6500K
          - channel: 1
            name: snack_bar_sign
            type: rgb
            channel_setup:
              - d
              - 1
              - 125
              - R
              - G
              - B
            output_correction: linear
            channel_size: 8bit
  - platform: artnet_led
    host: 192.168.1.35
    max_fps: 43
    refresh_every: 0
    universes:
      0:
        send_partial_universe: True
        output_correction: quadratic
        devices:
          - channel: 13
            name: Test light2
            type: color_temp
            transition: 1
            channel_size: 16bit
          - channel: 1
            name: snack_bar_sign2
            type: rgb
            channel_setup: dRGB
            output_correction: linear
            channel_size: 8bit
Wim-N commented 1 year ago

Ok, thanks. This helps a lot!! On the second instance (192.168.1.35) you dit not specify the _node_type: artnet-controller_ is this on purpose?

Breina commented 1 year ago

No that doesn't really matter. It just defaults to artnet-direct if you don't specify it.

Wim-N commented 1 year ago

I've done some testing. Removed the old version and the entities. Then loaded te new version and installed the configuration. There are 2 ArtNET interfaces each controlling a six channel dimmer pack.

light:
- platform: artnet_led
  host: 10.86.189.125                   # IP of Art-Net Node
  max_fps: 25                           # Max 40 per second
  refresh_every: 0                      # Resend values if no fades are running every x seconds, 0 disables automatic refresh
  node_type: artnet-controller          # 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
      output_correction: quadratic      # optional: output correction for the whole universe, will be used as default if nothing is set for the channel
      devices:
        # Dimmer
        # Let op dat een 16bit channel;_size 2 DMX adressen gebruikt!!!!
        - channel: 1                    # first channel of dmx dimmer
          name: DMX_1                   # name
          type: dimmer                  # type
          transition: 1                 # default duration of fades in sec. Will be overridden by Transition sent from HA
          output_correction: quadratic  # optional: quadratic, cubic or quadruple. Apply different dimming curves to the output. Default is None which means linear dimming
          channel_size: 8bit            # width of the channel sent to DMX device, default "8bit", "16bit", "24bit" and "32bit" available.
        - channel: 2
          name: DMX_2
          type: dimmer
          transition: 1
          channel_size: 8bit
          output_correction: quadratic
        - channel: 3
          name: DMX_3
          type: dimmer
          transition: 1
          channel_size: 8bit
          output_correction: quadratic
        - channel: 4
          name: DMX_4
          type: dimmer
          transition: 1
          channel_size: 8bit
          output_correction: quadratic
        - channel: 5
          name: DMX_5
          type: dimmer
          transition: 1
          channel_size: 8bit
          output_correction: quadratic
        - channel: 6
          name: DMX_6
          type: dimmer
          transition: 1
          channel_size: 8bit
          output_correction: quadratic
- platform: artnet_led
  host: 10.86.189.129                   # IP of Art-Net Node
  max_fps: 25                           # Max 40 per second
  refresh_every: 0                      # Resend values if no fades are running every x seconds, 0 disables automatic refresh
  node_type: artnet-controller          # 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
      output_correction: quadratic      # optional: output correction for the whole universe, will be used as default if nothing is set for the channel
      devices:
        # Dimmer
        # Let op dat een 16bit channel;_size 2 DMX adressen gebruikt!!!!
        - channel: 1                    # first channel of dmx dimmer
          name: 4_DMX_1                 # name
          type: dimmer                  # type
          transition: 1                 # default duration of fades in sec. Will be overridden by Transition sent from HA
          output_correction: quadratic  # optional: quadratic, cubic or quadruple. Apply different dimming curves to the output. Default is None which means linear dimming
          channel_size: 8bit            # width of the channel sent to DMX device, default "8bit", "16bit", "24bit" and "32bit" available.
        - channel: 2
          name: 4_DMX_2
          type: dimmer
          transition: 1
          output_correction: quadratic  
          channel_size: 8bit
        - channel: 3
          name: 4_DMX_3
          type: dimmer
          transition: 1
          output_correction: quadratic  
          channel_size: 8bit
        - channel: 4
          name: 4_DMX_4
          type: dimmer
          transition: 1
          output_correction: quadratic  
          channel_size: 8bit
        - channel: 5
          name: 4_DMX_5
          type: dimmer
          transition: 1
          output_correction: quadratic  
          channel_size: 8bit
        - channel: 6
          name: 4_DMX_6
          type: dimmer
          transition: 1
          output_correction: quadratic  
          channel_size: 8bit

Restarting takes a lot of time an I found this in the logs:

File "/usr/local/lib/python3.10/site-packages/pyartnet/base/universe.py", line 95, in add_channel
    raise OverlappingChannelError(f'New channel {channel_name} is overlapping with channel {_n:s}!')
pyartnet.errors.OverlappingChannelError: New channel 4_DMX_1 is overlapping with channel DMX_1!

I hope this is enough information for you to investigate this further, thanks!

Breina commented 1 year ago

Ah like that! That's very useful!

Hold my beer, I'll fix.

Breina commented 1 year ago

In terms of DMX, having different lights on the same channel on the same universe on the same network, is treated as being the same light.

When using node_type: artnet-controller, it's not possible to have this configuration. It's generally best if you would move different lights, to a different channel or universe. As such:

light:
  - platform: artnet_led
    host: 0.0.0.0                         # host is still mandatory, but ignored
    max_fps: 25
    refresh_every: 0
    node_type: artnet-controller
    universes:
      1:
        send_partial_universe: True
        output_correction: quadratic
        devices:
          - channel: 1
            name: DMX_1
            type: dimmer
            transition: 1
          - channel: 2
            name: DMX_2
            type: dimmer
            transition: 1
          - channel: 3
            name: DMX_3
            type: dimmer
            transition: 1
          - channel: 4
            name: DMX_4
            type: dimmer
            transition: 1
          - channel: 5
            name: DMX_5
            type: dimmer
            transition: 1
          - channel: 6
            name: DMX_6
            type: dimmer
            transition: 1
      2:
        send_partial_universe: True
        output_correction: quadratic
        devices:
          - channel: 1
            name: 4_DMX_1
            type: dimmer
            transition: 1
          - channel: 2
            name: 4_DMX_2
            type: dimmer
            transition: 1
          - channel: 3
            name: 4_DMX_3
            type: dimmer
            transition: 1
          - channel: 4
            name: 4_DMX_4
            type: dimmer
            transition: 1
          - channel: 5
            name: 4_DMX_5
            type: dimmer
            transition: 1
          - channel: 6
            name: 4_DMX_6
            type: dimmer
            transition: 1

If there is no other way, you can also use node_type: artnet-direct, but that also means that DMX can't update the state in Home Assistant.

Wim-N commented 1 year ago

A few remarks: If I use Artnet-Controller and restart HA it takes a lot of time for the clean-up phase to finish. HACS is being busy waiting for the artnet_led integration. Is this normal?

We have multiple rooms. Each room has a six channel dimmer pack (channel 1-6) and a simple control panel with 6 faders and a master. We use the ShowTec Net-2/3 pocket which also has an input with a merge function (set for HTP). With this setup we can control the lights in each room using the manual controller with the faders or we can use HA to control the lights. We now would like to controle multiple rooms with only one HA. That's why we use the same channel in the same universe. But the DMX outputs from the ArtNET interfaces are not connected so each has its own DMX 'network'. So I should use a different universe for each ArtNET controller and then I can use the same channel? So the combination universe+channel should be unique.

Breina commented 1 year ago

If I use Artnet-Controller and restart HA it takes a lot of time for the clean-up phase to finish. HACS is being busy waiting for the artnet_led integration. Is this normal?

Yeah sorry about that. Still have to figure out the threading situation in HA. It's on my TODO.

So I should use a different universe for each ArtNET controller and then I can use the same channel? So the combination universe+channel should be unique.

Yes, exactly. That would be the cleanest solution at least. :)

Wim-N commented 1 year ago

Ok, thanks. I'll try that (will take some day's)

Wim-N commented 1 year ago

Installed the second ArtNET interface and checked it. With a short check it seems to work on both interfaces. But something has changed. When I was only using 1 ArtNET interface it was continuously updated by HA (you can see the ethernet port being busy and a DMX light was on at the interface). But now using 2 separate interfaces it will only send commands to the interface when a change to a DMX channel is made. A few seconds after that change communication stops and starts again when making a change again. Is this by design to reduce the used bandwidth?

Breina commented 1 year ago

Glad to hear!

In the latest verison, if refresh_every is set to 0, if will only update when something changes. If it's set to any value larger than 0, it will continuously update. There shouldn't be any difference between its behavior when using 1 universe vs using multiple.

Can you send me your most recent config again, so I can verify?

Wim-N commented 1 year ago

This is the current configuration for the DMX light part:

light:
# room 3 via DMX
- platform: artnet_led
  host: 10.86.189.129                   # IP of Art-Net Node
  max_fps: 25                           # Max 40 per second
  refresh_every: 0                      # Resend values if no fades are running every x seconds, 0 disables automatic refresh
  node_type: artnet-controller          # Which protocol to use (artnet-controller / artnet-direct)
  universes:                            # Support for multiple universes
    3:                                  # Nr of Universe (see configuration of your Art-Net Node)
      send_partial_universe: True       # Only send the universe which contains data
      output_correction: quadratic      # optional: output correction for the whole universe, will be used as default if nothing is set for the channel
      devices:
        # Dimmer
        - channel: 1                    # first channel of dmx dimmer
          name: 3_DMX_1                 # name
          type: dimmer                  # type
          transition: 1                 # default duration of fades in sec. Will be overridden by Transition sent from HA
          output_correction: quadratic  # optional: quadratic, cubic or quadruple. Apply different dimming curves to the output. Default is None which means linear dimming
          channel_size: 8bit            # width of the channel sent to DMX device, default "8bit", "16bit", "24bit" and "32bit" available.
        - channel: 2
          name: 3_DMX_2
          type: dimmer
          transition: 1
          output_correction: quadratic  
          channel_size: 8bit
        - channel: 3
          name: 3_DMX_3
          type: dimmer
          transition: 1
          output_correction: quadratic  
          channel_size: 8bit
        - channel: 4
          name: 3_DMX_4
          type: dimmer
          transition: 1
          output_correction: quadratic  
          channel_size: 8bit
        - channel: 5
          name: 3_DMX_5
          type: dimmer
          transition: 1
          output_correction: quadratic  
          channel_size: 8bit
        - channel: 6
          name: 3_DMX_6
          type: dimmer
          transition: 1
          output_correction: quadratic  
          channel_size: 8bit

# zaal 5 via DMX
- platform: artnet_led
  host: 10.86.189.125                   # IP of Art-Net Node
  max_fps: 25                           # Max 40 per second
  refresh_every: 0                      # Resend values if no fades are running every x seconds, 0 disables automatic refresh
  node_type: artnet-controller          # Which protocol to use
  universes:                            # Support for multiple universes
    5:                                  # Nr of Universe (see configuration of your Art-Net Node)
      send_partial_universe: True       # Only send the universe which contains data
      output_correction: quadratic      # optional: output correction for the whole universe, will be used as default if nothing is set for the channel
      devices:
        # Dimmer
        - channel: 1                    # first channel of dmx dimmer
          name: 5_DMX_1                   # name
          type: dimmer                  # type
          transition: 1                 # default duration of fades in sec. Will be overridden by Transition sent from HA
          output_correction: quadratic  # optional: quadratic, cubic or quadruple. Apply different dimming curves to the output. Default is None which means linear dimming
          channel_size: 8bit            # width of the channel sent to DMX device, default "8bit", "16bit", "24bit" and "32bit" available.
        - channel: 2
          name: 5_DMX_2
          type: dimmer
          transition: 1
          channel_size: 8bit
          output_correction: quadratic
        - channel: 3
          name: 5_DMX_3
          type: dimmer
          transition: 1
          channel_size: 8bit
          output_correction: quadratic
        - channel: 4
          name: 5_DMX_4
          type: dimmer
          transition: 1
          channel_size: 8bit
          output_correction: quadratic
        - channel: 5
          name: 5_DMX_5
          type: dimmer
          transition: 1
          channel_size: 8bit
          output_correction: quadratic
        - channel: 6
          name: 5_DMX_6
          type: dimmer
          transition: 1
          channel_size: 8bit
          output_correction: quadratic
Breina commented 1 year ago

I tried to reproduce, but it does seem to do its thing. If you set refresh_every: 1, I'm seeing 1 update per second. When it's 0, it only updates on change. Not sure what you're seeing different?

Wim-N commented 1 year ago

It sends the update and it looks like it that it keeps on sending for a second or so. So no problem. Do you have any idea of how many ArtNET interfaces can be used with one HA. Would 6 work? I do not expect a lot of traffic, do not want to run a light show or disco lights ;-)

Breina commented 1 year ago

Yes, that's because of transition: 1. If you omit that or set it to 0, then it's only going to be 1 update. 6 ArtNet nodes won't be a problem at all. :)

Wim-N commented 1 year ago

Ok, clear. Thanks!