Hi I am trying to configure a Mysensors RGB light to home assistant via MQTT Light.
How can l confire Home Assistant MQTT Light RGB template to send the RGB values as a 6 char hex string?
Any help / guidance would be greatly appreciated!
Hi I am trying to configure a Mysensors RGB light to home assistant via MQTT Light.
How can l confire Home Assistant MQTT Light RGB template to send the RGB values as a 6 char hex string?
Any help / guidance would be greatly appreciated!
I haven’t tested this but it might help you on the way. You can test it in the template editor in the dev tools in home assistant. You have to get the rgb value as a three value tuple for this to work.
{{ "{0:02x}{1:02x}{2:02x}".format(r, g, b) }}
PS. If you use the mysensors component you don’t have to worry about this. The component and platforms take care of it for you.
Thank you for suggestion
I tried this but it seems that MQTT light ignores this template value irrespective of what valid template code is entered
It always returns RGB as a string seperated by ,
Not sure if l should report this as a bug?
Kind regards
I think you need to use the mqtt template light platform.
It has a command_on_template
config requirement with variables for eg red, green and blue.
So I think you could do something like this:
{{ "{0:02x}{1:02x}{2:02x}".format(red, green, blue) }}
You probably need to check that the other light controls work with that template though, ie on/off and brightness.