Hello everyone, I’m reaching out for some guidance on controlling my RGBW LEDs using Modbus with Home Assistant. I’ve set up my LEDs with a DMX controller connected to a WAGO PLC, which interfaces with my Raspberry Pi running HA. Here’s a quick overview of my setup:
PLC Modbus
modbus:
- name: Wago
type: tcp
host: 10.0.0.100
port: 502
switch:
Modbus Switches___
******************************
platform: modbus
scan_interval: 1
coils:
# * LED Relays *
- name: mb_wz_led_relay
hub: Wago
slave: 1
coil: 12405
sensor:
- platform: modbus
scan_interval: 1
registers:* LED RGBW Values *
- name: mb_wz_led_r_value
hub: Wago
slave: 1
register: 13398
register_type: holding
data_type: uint - name: mb_wz_led_g_value
hub: Wago
slave: 1
register: 13399
register_type: holding
data_type: uint - name: mb_wz_led_b_value
hub: Wago
slave: 1
register: 13400
register_type: holding
data_type: uint - name: mb_wz_led_w_value
hub: Wago
slave: 1
register: 13401
register_type: holding
data_type: uint
light:
- name: mb_wz_led_r_value
- platform: template
lights:
###_WOHNZIMMER AMBIENTE###
light_wz_led:
friendly_name: “Wohnzimmer Ambiente LED”
level_template: “{{ states.sensor.mb_wz_led_w_value.state|int }}”
value_template: “{{ is_state(‘switch.mb_wz_led_relay’, ‘on’) }}”
color_template: “({{ states.sensor.mb_wz_led_r_value.state|int }}, {{ states.sensor.mb_wz_led_g_value.state|int }}, {{ states.mb_wz_led_b_value.state.state|int }})”
turn_on:
- service: switch.turn_on
entity_id: switch.mb_wz_led_relay
turn_off:
- service: switch.turn_off
entity_id: switch.mb_wz_led_relay
set_level:
- service: modbus.write_register
data_template:
hub: Wago
unit: 1
address: 13401
value: “{{ brightness }}”
set_color:
- service: modbus.write_register
data_template:
hub: Wago
unit: 1
address: 13398
value: “{{ h }}”
#here I need the red value instead of the h
- service: modbus.write_register
data_template:
hub: Wago
unit: 1
address: 13399
value: “{{ s }}”
#here I need the green value instead of the s
- service: modbus.write_register
data_template:
hub: Wago
unit: 1
address: 13400
value: “{{ s }}”
#here I need the blue value instead of the s
So far, I’ve managed to switch the LEDs on and off, but I’m struggling to control the colors correctly. The main issue is that the template light uses HSB (hue, saturation, brightness) values, while I need to send RGB values to the Modbus registers. I found a script to convert HSB to RGB, but I’m not sure how to integrate it into my configuration. Any advice or suggestions would be greatly appreciated! Thanks in advance for your help!