Closed abzman closed 6 years ago
Wrote a workaround that works and only generates error messages in home assistant when scheme/effect is changed. See rgb_value_template below, which is set up for RGB. Swap the indices around for GRB or whatever support.
Explanation in case some poor soul runs across this:
(value_json.Color[0:2] | int(int, 16)) | string
takes the first two characters of the color value in hex formatted like "RRGGBBWW", treats it like an int, passes it through python's int() function with a second parameter being the base of the input resulting in the decimal value of "RR", converts it back to a string, and finally concatenates it together with commas and the G and B values into the format home assistant expects the RGB value to be published in, a string like "100,150,255" (note there are no parentheses, cannot be a tuple like (R,G,B).)
name: Elab Arch South
effect_list:
- 2
- 3
state_topic: "stat/i3/inside/elab/accent/arch-south/RESULT"
command_topic: "cmnd/i3/inside/elab/accent/arch-south/POWER"
brightness_state_topic: "stat/i3/inside/elab/accent/arch-south/RESULT"
brightness_command_topic: "cmnd/i3/inside/elab/accent/arch-south/Dimmer"
brightness_scale: 100
rgb_command_template: "{{ '%02x%02x%02x00' | format(red, green, blue)}}"
rgb_state_topic: "stat/i3/inside/elab/accent/arch-south/RESULT"
rgb_command_topic: "cmnd/i3/inside/elab/accent/arch-south/Color"
effect_command_topic: "cmnd/i3/inside/elab/accent/arch-south/Scheme"
effect_state_topic: "stat/i3/inside/elab/accent/arch-south/RESULT"
state_value_template: >
{% if "POWER" in value_json %}
{{ value_json.POWER }}
{% endif %}
brightness_value_template: >
{% if "Dimmer" in value_json %}
{{ value_json.Dimmer }}
{% endif %}
effect_value_template: >
{% if "Scheme" in value_json %}
{{ value_json.Scheme }}
{% endif %}
rgb_value_template: >
{% if "Color" in value_json %}
{{ (value_json.Color[0:2] | int(int, 16)) | string + ',' + (value_json.Color[2:4] | int(int, 16)) | string + ',' + (value_json.Color[4:6] | int(int, 16)) | string }}
{% endif %}
payload_on: "ON"
payload_off: "OFF"
on_command_type: "brightness"
needed for tasmota rgb lights