Is there a way to remap the channels of an RGB bulb? I have a “MagicHome” light that works perfectly with HA except for the colors being rotated from what HA calls them, e.g. selecting Red turns it Blue. Another complication with this light is the White channel is also actually driving UV LEDS so renaming that would also be nice.
I don’t think HA has support for mapping a UV channel, so I don’t think you can do that.
Yes you can use a “Light Template Helper”, specifically the helper has two sections:
The HS color template which reads the color from the real light and displays it in the template.
The Actions on set HS color which can be used to translate user selected colors into a different color.
In order to use it you need to understand HS color space:
So if you wanted to map:
- Red → Green
- Green → Blue
- Blue → Red
That would be a 120 degree rotation in HS color space.
Hence your Actions on set HS color would be:
action: light.turn_on
target:
entity_id:
- light.living_room
data:
hs_color: "{{ [(hs[0] + 120.0) % 360.0, hs[1]] }}"
You have to use a light_on since I don’t think there is any other way to set the color and you need to use the modulus (360) since values can’t exceed 360 degrees.
For HS color template you can do:
{{ [
(state_attr('light.living_room', 'hs_color')[0] + 240.0 )% 360.0,
state_attr('light.living_room', 'hs_color')[1]
] }}
Since you are working with modulo math adding 240 is the same as subtracting 120 - i.e. when you are reading the color back you need to rotate in the opposite direction.