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

Nora – Google Assistant in NodeRED

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

Sonoff Zigbee Bridge – review

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

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

We’ve seen this before: SwitchBot K10+ PRO

0
This is an odd one. Building on the success of SwitchBot K10+ they released SwitchBot K10+ PRO - but is the experience actually better?

Is this the smart panel we have waited for?

0
ITEAD has released a new smart panel: Sonoff NSPanel Pro 120 - have they learned the lesson from the terrible launch of the original Pro? Let's see what's new.

Aqara FP1E detects motionless humans

0
This isn't exactly a new device, it's an interaction of the original Aqara presence sensor. Aqara FP1E brings Matter, ZigBee and new triggers to your smart home

SwitchBot S10: cleaning re-imagined!

0
SwitchBot S10 promises unattended vacuuming and mopping so you can focus on things you love and care for. Does it deliver?

Sonoff for households and gardens

0
ITEAD released two ZigBee devices to manage water in your household and gardens. Now you can monitor the flow and dispense water with Sonoff SWV and prevent water damage using the Sonoff Water Leak sensor with a twist.