HomeHome AutomationIKEA TRADFRI Wireless dimmer in NodeRED

IKEA TRADFRI Wireless dimmer in NodeRED

Control anything you want with IKEA Wireless Dimmer in NodeRED

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.

Buy USB Zigbee Stick CC2531

Buy it using these links to support NotEnoughTech.

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.

Project Download

Download project files here. Bear in mind that Patreon supporters have early access to project files and videos.

PayPal

Nothing says "Thank you" better than keeping my coffee jar topped up!

Patreon

Support me on Patreon and get an early access to tutorial files and videos.

image/svg+xml

Bitcoin (BTC)

Use this QR to keep me caffeinated with BTC: 1FwFqqh71mUTENcRe9q4s9AWFgoc8BA9ZU

Smart Ideas with

Automate your space in with these ecosystems and integrate it with other automation services

client-image
client-image
client-image
client-image
client-image
client-image
client-image
client-image
client-image

Learn NodeRED

NodeRED for beginners: 1. Why do you need a NodeRED server?

0
To server or not to server? That's a very silly question!

Best Automation Projects

Nora – Google Assistant in NodeRED

0
Integrate Google Assistant with NodeRED thanks to Nora - NodeRED home automation

NEST your old thermostat under $5

0
Nest-ing up your older thermostat under $5

Sonoff R3 DIY mode & why it sucks

0
Long awaited Sonoff R3 DIY mode is even worse than I expected.

Things they don’t tell you about IKEA Trådfri

0
There are things you should know about IKEA Tradfri before you make your purchase

Flashing ESP with Tasmotizer is a dream come true

0
How to flash Tasmota on ESP devices with new Tasmotizer tool

Smart Home

The quietest roller shade driver I used!

0
Aqara Roller Shade Driver E1 is ZigBee 3.0 wireless and the quietest controller for blinds, rollers and verticals.

M5Stack UnitV2 update brings WiFi

0
M5Stack UnitV2 finally gets much needed WiFi update and I will show you how to make the settings stick

Flashing Tasmota on Sonoff POWR3

0
How to flash tasmota on Sonoff POWR3 and set it up correctly

Amped to 25 – Sonoff POWR3

0
It's bigger, better and comes with massive 25A current limit - for all your present needs - meet Sonoff POWR3

SwitchBot made an IP Camera

0
SwitchBot Indoor Cam is small and inexpensive 1080p camera with smart assistant support and 2 way communications