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

Tuya SDK for beginners: Intro to Tuya Cloud API

0
Working with Tuya Cloud API. A guide to Cloud automation for beginners, get started with REST!

NEST your old thermostat under $5

0
Nest-ing up your older thermostat under $5

Sonoff Zigbee Bridge – review

0
Sonoff line up will soon include Sonoff Zigbee Bridge and more Zigbee sensors - here is the first look

Nora – Google Assistant in NodeRED

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

DIY Smart Washing Machine – for about 15 bucks!

0
Learn how to add washing machine notifications to your Google Home on the cheap

Smart Home

I damaged the cheapest Smart Socket with power metering for you

0
Sonoff S60 has an exeptional price for a smart socket with a power meter - I decided to check it out and see how flashable it is

The end of Tasmota? Sonoff SwitchMan M5 Matter

0
These are one of the least expensive Matter devices to automate your lights. Will Sonoff SwitchMan M5 Matter put an end to Tasmota?

Meros TRV to the rescue?

0
I got my hands on another TRV - this time from Meross. I heard good things about the brand so I wanted to see if Meross TRV would be good to manage smart heating.

Aqara brings Thread sensors but…

0
Aqara brings new Thread sensors to their ecosystem. First sensors to support Matter this way are Aqara Motion and Light Sensor P2 and Aqara Contact Sensor P2

Multi-lights for your ceiling from Aqara

0
This is the biggest light I held in my hands so far. It's ZigBee and it comes from Aqara - meet Aqara Ceiling Light T1M