This is the last (for now) IKEA TRADFRI gadgets I’m going to add to NodeRED and integrate with other systems. IKEA TRADFRI Wireless dimmer in NodeRED can be used in the same way as with IKEA TRADFRI system, except the list of compatible actions and supported devices are unlimited.

IKEA TRADFRI Wireless dimmer in NodeRED

Wireless Dimmer

IKEA TRADFRI Wireless dimmer in NodeRED pairs with CC2531 USB Zigbee stick without any issues. Unscrew the cover, press it 4 times in quick succession to factory reset, move it close to the CC2531.

If this is your first Zigbee device, you will need to flash the CC2531 stick first. You can follow this tutorial. Once you have the stick flashed, you will be able to take advantage of the library in NodeRED using MQTT.

Wireless dimmer

Apart from 1|0 options on the button, I can assign the following functions to IKEA TRADFRI Wireless dimmer in NodeRED:

ON

OFF

Brightness UP

Brightness DOWN

To achieve the brightness increase, I can simply press and hold the button to increment the values. My flow also allows me to set a custom step value to turn up|down brightness quicker.

Unlike my previous article about Aqara Button in NodeRED, I have 2 buttons for my disposal, so I don’t have to make the button smart. If you want to know how to toggle lights & change the brightness with a single button – I suggest you check that article out. For the most part, I will simply borrow the idea from that tutorial.

Wireless dimmer in NodeRED

IKEA TRADFRI Wireless dimmer in NodeRED issues 5 different msg.payload.click objects that I extract with an MQTT in node with zigbee2mqtt/ikea_dimmer_name topic:

on off brightness_up brightness_down brightness_stop

ON|OFF

Issuing messages on ON|OFF is very simple, simply use a change and split node to change the message to the required payload. Since I have used a split node to separate the messages, I will continue with a very simple function node to set the correct payload back to my IKEA Color Bulb via MQTT: zigbee2mqtt/ikeabulbc1/set .

Function Node: ON|OFF //ON msg.payload = { "state":"ON"}; return msg; //OFF msg.payload = { "state":"OFF"}; return msg;

Dimmer

Dimmers are a little more complicated as I need NodeRED to iterate the value of the brightness for the duration of the button press. To achieve this I have to get the initial value first, that process and format depend on the light you use. In this tutorial, I will show you how to do this with IKEA lightbulb. I have a full write-up about the use of IKEA TRADFRI lightbulbs in NodeRED.

In settings, I define the increment (30) which is responsible for how quick the brightness changes will happen (higher the number the quicker the change).

Control the Loop

On actions: brightness_up & brightness_down I’m enabling the loop. I can do so by setting the press flow variable to true | false . This will determine if the brightness loop can perform another iteration.

The brightness_stop message is issued when the button had been released, this is the signal for the loop to stop iterating ( false ).

Brightness Loop

I both actions brightness UP|DOWN are pretty much the same with the exception of maths (+ vs -) and the edge values (I have to keep the brightness values within 0-255 range).

To slow down the iterations, I have added the 500ms delay, you can change this value and experiment with brightness step to create the best experience. Be aware that Zigbee isn’t very responsive and can hang up if you decrease the delay.

Function Node: Brightness UP var step = flow.get("Step"); var brightness = flow.get("IKEA_bulb1_brightness"); if(brightness > 0){ brightness = brightness + step; flow.set("IKEA_bulb1_brightness", brightness); } if(brightness >= 255){ brightness = 254; flow.set('press', false); flow.set("IKEA_bulb1_brightness", brightness); } msg.payload = {"state":"ON", "brightness":brightness}; return msg;

Function Node: Brightness DOWN var step = flow.get("Step"); var brightness = flow.get("IKEA_bulb1_brightness"); if(brightness <= 255){ brightness = brightness - step; flow.set("IKEA_bulb1_brightness", brightness); } if(brightness <= 0){ brightness = 1; flow.set('press', false); flow.set("IKEA_bulb1_brightness", brightness); } msg.payload = {"state":"ON", "brightness":brightness}; return msg;

I'm only changing the brightness value, so I don't have to submit other parameters to my IKEA Tradfri Color bulb. The payload for these actions is:

msg.payload = {"state":"ON", "brightness":brightness};

Conclusion

As you can see, IKEA TRADFRI Wireless Dimmer in NodeRED is just as capable as in IKEA ecosystem. You can use this button to interact with anything that is connected to NodeRED: Yeelight bulbs, Zemismart spotlights, even use it to control motorised blinds or volume. All this, without the need for IKEA TRADFRI hub!

Andrew Russell sent me a compressed version of this project - and you can take a look at this GitHub to get it.

What do you think guys? What would you use IKEA TRADFRI Wireless Dimmer in NodeRED for? Let me know in this Reddit thread.