Node-Red Tradfri Dimmer turn on Other lights with variable

Hi,

Last week I bought a IKEA Tradfri Hub with a bulb and one of those little simple dimmers This one

In the back of my mind I had the idea to use one of these lights with dimmer to also control my 2 Yeelights near my bed. The IKEA lamp would be on my desk and I would dim all 3 at the same time. After I found out that the Tradfri dimmer does not show up as an individual component I decided to do it a different way. Read the status of the IKEA Tradfri bulb (controlled with the dimmer) and adjust the brightness of my 2 yeelights depening on the output of the Tradfri Bulb.

I started messing around with node-red for the first time yesterday and was able to create the following flow:

As you can see I first gather the brightness level of the Tradfri bulb

var newMsg = { brightness: msg.data.new_state.attributes.brightness };
return newMsg;

Then I use a switchnode to then take these values and split the across to different % brightness level.

What I would like ideally is to be able to use the brightness attribute as a variable and input it in a service node. Since right now I have 10 different service nodes for each 10% brightness.

So is it possible to make the red part the brightness attribute?

Sorry if it’s a mess. I’m very new to Node-RED.

Thanks!

1 Like