Home Home Automation IKEA 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 in style with crypto-currency

Smart Ideas with

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

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

ESP8266 WIFI lights under $5

0
Your Sonoff device can't do this!

Free wireless doorbell (Amazon Dash button hack)

0
The most terrifying situation I can imagine* is missing a parcel

New Amazon Dash Buttons

0
You can teach new buttons old tricks!

ESP8266 ceiling light – demo

0
Testing the ESP8266 as a WIFI light controller

Try Tasker and Raspberry Pi for your home automation needs!

0
Raspberry Pi can help you with your Tasker profiles

Smart Home

How to make Sonoff ZB Mini and ZigBee2MQTT work together

0
It's time to make Sonoff ZB Mini and ZigBee2MQTT work together!

Sonoff ZBMINI is in town!

0
ITEAD released a new product - Sonoff ZB Mini - a smarter twin brother of Sonoff Mini!

Testing 9 external antennas with CC2531 ZigBee coordinator

0
I have tested the range and the link quality of 9 external antennas with CC2531!

I have infinite buttons thanks to Aqara Opple

0
Gaming on Switch meets IoT - can you play games on Aqara Opple? Apparently you can! This and more uses of the connected wall switch

Smart lights won’t save you money

0
It's pretty clear how much power a smart light draws when turned on, but have you ever wonder how much do you pay to have it connected 24/7?