I have lights controlled by DMX module and DMX to Modbus TCP gateway.
Is there way to control this light from HA? I cannot find Modbus light or Modbus switch to light conversion.
It is possible to use Template Light and Modbus service write_register?
Because that’s not the way modbus works.
Modbus works based on registers (input & holding) and coils.
You need to know what the light is using to be controlled. Or more specifically, since the light is DMX and you have a DMX<->Modbus converter, you need to know how the DMX converter works, preferably a modbus map of what registers/coils are available and how they map to the DMX devices on the bus.
It probably looks something like this or this.
If you provide the manufacturer and model number of the DMX<->modbus converter someone might do the hard work for you and find the appropriate commands you would need to use.
I know how it works. Today I have PLC and everything work fine. I have map of holding registers and I know which register is responsible for.
Modbus TCP -> DMX gateway support FC16.
I just ask if is possible to control this holding registers as lights with brightness from HA?
That’s why I consider to use Light Template with service write_register.
In that case, yes.
Also, my bad for assuming that this part had not already been worked out.
In this case,
The built in Modbus support in HA allows for reading in arbitrary coils and registers from modbus points using the Modbus Sensor and modbus binary_sensor.
It also allows for writing booleans out using the modbus switch component. As for writing out arbitrary registers, there’s no built in component, but if you look at the modbus hub page, at the bottom, you’ll see there’s the write_register service. You can use this to write out registers.
After you get those configured so you can control the light and get it’s status from a collection of sensors, boolean_sensors, and service calls, take a look at the template light component. This allows all functions of a “light” to be driven from switches, service calls, and sensors.
It’s a good bit more work than having one built in, but its definitely possible to set up.
Thanks for help.
It works fine.
I have only problem in refresh light state after change.
What problem is it?
Does it not work at all? Does it work, but is slow to update?
Is this the boolean state that isn’t working, or the brightness status?
Can you read this state from the respective sensor or boolean_sensor, and it’s just not making it into the template light properly?
Now it is ok
Just light switch didn’t refresh state immediately after switch.
I added call service to force read sensor connected to light state.
sensor:
platform: modbus
registers:
- name: light1
slave: 1
register: 1
light:
- platform: template
lights:
theater_lights:
friendly_name: "dmx light"
level_template: "{{ states.sensor.light1.state|int }}"
value_template: "{{ states.sensor.light1.state|int > 0 }}"
turn_on:
- service: modbus.write_register
data_template:
unit: 1
address: 1
value: "{{ brightness }}"
- service: homeassistant.update_entity
data_template:
entity_id: sensor.light1
turn_off:
- service: modbus.write_register
data_template:
unit: 1
address: 1
value: 0
- service: homeassistant.update_entity
data_template:
entity_id: sensor.light1
set_level:
- service: modbus.write_register
data_template:
unit: 1
address: 1
value: "{{ brightness }}"
- service: homeassistant.update_entity
data_template:
entity_id: sensor.light1