Copying RGB values between lights in Home Assistant

I’m a geek, you’re a geek, we’re all geeks.

And geeks automatize everything, including lights in their lounges.

Today we explore a way to copy RGB settings between two entities in Home Assistant


More articles about home automation are available here.

A while ago we retrofitted a dollar store RGBW led into a Home Assistant remote control module. More recently we installed a series of RGB LED strips to the lounge’s bar, not far from said light pod; and the best way to control this newly added Tasmota device is to have it follow the main one.

Home Assistant has groups which pushes a command to multiple entities, which is great when the server is the source of a light change, but what we are wanting to achieve here is having one light reacts to changes on the other light; the source of a change would be one smart lightbulb device.

For this to happen, Home Assistant automation needs to be implemented on all states, we’re talking brightness, on/off state and RGB – which are different properties of a smart light. The on/off is rather straightforward. For brightness and RGB, a similar solution could be implemented. Today we look at RGB.

How it works

There are multiple ways to approach this matter, but what seems simplest functional solution is to create an automation based on a state change.

The state that worked with our Tasmota entities was rgb_color. It exists an RGBW one – and the remote-control unit has the white channel, but RGB strips without white won’t benefit from the extra information.

The action we want to execute is counterintuitive at best: light.turn_on
The secret is to push parameters to our target entities, based on the master entity.

here’s what the whole thing could look like when using the YAML editor :

alias: BarColor-sync
description: sync barlight RGB to loungeremotecontroller
trigger:
- platform: state
entity_id:
- light.loungeremote
attribute: rgb_color
condition: []
action:
- service: light.turn_on
data:
rgb_color: "{{ state_attr('light.loungeremote', 'rgb_color') }}"
target:
entity_id: light.barlights
mode: single

Voilà. It ain’t anything more complex than that.

Related Articles:

Retrofitting RGBW led light into Remote Control Central (wereallgeeks)
Home Assistant projects (wereallgeeks)
Tasmota projects (wereallgeeks)

Geek talks