Hello,
I have twoo rgb strips over KNX. These strips have a different address per color. The knx implementation of RGB only seems to support RGB lights that have one address for all the colors.
Now i’m trying to fix this with a template and some scripts but the lack of documentation on anything keeps getting in the way.
The problem now is getting the value from the color selector card and parsing it from the template to the script.
the template in configuration.yaml
light:
- platform: template
lights:
rgb_lights:
color_template: "({{states('light.red') | int}}, {{states('light.green') | int}}, {{states('light.blue') | int}})"
turn_on:
service: script.rgb_light_on #works
turn_off:
service: script.rgb_light_off #works
set_color:
service: script.set_rgb_color #gives error
data:
rgb_value: "255, 11, 150" #want this to be a variable
r_address: "6/1/1"
g_address: "6/1/2"
b_address: "6/1/3"
The script in scripts.yaml
rgb_light_on:
sequence:
- service: light.turn_on
data:
entity_id: light.red, light.green, light.blue
mode: single
rgb_light_off:
sequence:
- service: light.turn_off
data:
entity_id: light.red, light.green, light.blue
mode: single
set_rgb_color:
sequence:
- service: knx.send
data:
address: "{{ r_address }}" #works
payload: "{{ rgb_value|regex_findall_index('\\d+\"',0)|int }}" #gives error. I tried index 1, same result
type: "1byte_unsigned"
- service: knx.send
data:
address: "{{ g_address }}" #works
# "payload": rgb_value|regex_findall_index("\d+",1)|int
payload: 10 #works but want this as a parameter
type: "1byte_unsigned"
- service: knx.send
data:
address: "{{ b_address }}" #works
# "payload": rgb_value|regex_findall_index("\d+",2)|int
payload: 200 #works but want this as a parameter
type: "1byte_unsigned"
The address parameters work fine (after an update, waisted 2 hours on that). The rgb_value gives the following error: “Error rendering data template: IndexError: list index out of range”
So i’m guessing that the regex does not have any matches or something, I don’t know.
There is something I want to fix before this and that is getting the actual RGB values from the light card. So right now these values are hard coded. What I want to know now is how do I get the RGB color from the light card when I select a color in the color wheel.
I hope that someone can help me with this.
Thanks!