HomeHome AutomationIKEA TRADFRI light bulbs in NodeRED

IKEA TRADFRI light bulbs in NodeRED

Using IKEA light bulbs in NodeRED never been so easy!

I have been missing a short write up to how to use the IKEA light bulbs in NodeRED, so it’s time to share some knowledge. I actually had to go and visit my local IKEA again to get the colour light bulb (LED1624G9) as I only had the ones that support dimming (LED1622G12). While I was there I picked up a smart socket with a Zigbee remote, so expect the write up soon.

Adding IKEA light bulbs in NodeRED (Zigbee2MQTT)

I actually run into a hitch when adding the lights, I’m not entirely sure what caused it but I was not able to control my colour light bulb. In all honesty, I’m not sure what fixed it either, but after 3-5 successful power-off cycles on both Zigbee2MQTT & IKEA light bulb side, I was able to make the devices to talk to each other again.

To reset the light bulb, you have to flip it on and off 6 times (start with ON position) fairly quickly – see this video. Then wait for a brief flash, which will confirm that the procedure has been done correctly. Before you can add the bulb, power it off, then on again. Your Zigbee USB stick should be able to see it.

Once you have paired all IKEA bulbs (you can see this if you start Zigbee2MQTT in terminal:

cd /opt/zigbee2mqtt
npm start

you should edit the configuration.yaml file and name the new devices to something you will remember. It’s a good practice (since the IKEA bulbs look-alike) to use a permanent pen to mark the bulbs too! You can learn more about flashing the CC2531 and adding more devices in the corresponding links.

Let’s talk NodeRED

Both IKEA light bulbs are controllable in NodeRED. I have the E27 600lm colour bulb (LED1624G9) and dimmable E27 1000lm 2700k (LED1622G12). There is an added benefit of actually having a couple of Zigbee lights in your house as they expand the mesh network.

Getting the IKEA light bulb status

To control the bulbs, you will need to know the assigned name of the bulb (also your Zigbee default topic) and the command structure. Every now and then the device will post an update to the topic (zigbee2mqtt\bulbname) which will look like this:

{"state":"ON",
"linkquality":34,
"brightness":254,
"color_mode":1,
"color":{"x":0.699,"y":0.301}}

You can force the update by sending the payload:

 {   "state": "" } 

to zigbee2mqtt/bulbname/get. Note that the colour is received in X,Y values. You can read more about conversion here.

Setting IKEA light bulbs in NodeRED

To set the bulb to your desired settings, you will need to use this topic structure: zigbee2mqtt/bulbname/set. Then pass one or more arguments from this JSON file:

 {"state": "ON", // Or "OFF", "TOGGLE"
  "brightness": 255,
  "color_temp": 155,
  "transition": 3,
  "alert": "select",               // values (select,none,lselect) blink
  "color": {"x": 0.123,            // XY color 
            "y": 0.123}                
  "color": { "r": 46,              // RGB Colour
             "g": 102,
             "b": 193} 
  "color":  {"hex": "#547CFF"}     // HEX color  
  "color":  {"hue": 360,           // Hue and/or saturation color
             "saturation": 100} 
 }

Despite the colour being provided as XY 1931 colour space, we can set the colours with RGB or HEX. Only pick one of the “color” setters in the payload above.

Let’s create an interactive picker that we can use to set IKEA light bulbs in NodeRED to different colours. The nodeRED dashboard comes with colour picker, so this won’t be very hard. All I need is a slider to control the brightness and I can pass the values over.

First, I have to store the colour values in a flow variable. Each time the bulb updates, I want to make sure I have this value at my disposal as changing the brightness without this causes errors.

var color = msg.payload.color;
 flow.set("ikeabulbc1_color", color);
 return msg;

Then I’m ready to deploy a slider linked to the following function node:

var x = msg.payload;
 var color = flow.get("ikeabulbc1_color");
 msg.payload = {"brightness": x,
     "color" : color
 }
 return msg;

To change the colour, all I need is a colour value in HEX to be passed over to my function node:

var x = msg.payload;
 msg.payload = {"color": {"hex":"#"+x}}
 return msg;

A payload formatted like this will send the colour value to IKEA light bulb. Set this up for each bulb you own and you are all set.

Buy USB Zigbee Stick CC2531

Buy it using these links to support NotEnoughTech.

Conclusion

Thanks to Zigbee2MQTT you can mix and match your IKEA light bulbs in NodeRED with different ways of driving it. It’s simple and the set up above only takes a couple of minutes to establish. Let me know if you have any questions 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

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!

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

Smart Home

Is Sonoff NSPanel the future we all wanted?

0
First look at Sonoff NSPanel - a touch screen display for your light switch! Is this the future of automation?

Getting started with Sonoff ZIGBEE 3.0 USB DONGLE PLUS

0
Testing Sonoff ZIGBEE 3.0 USB DONGLE PLUS against CC2531 and zzh (electrolama) - is it the best upgrade to your Zigbee network?

Can touch this: M5Stack Core2

0
M5Stack Core2 brings touch interface to the table, new UIFlow options which make programming super easy

Aqara Roller Shade Driver E1 & Zigbee2MQTT

0
Taking Aqara E1 apart, adding it to Zigbee2MQTT and NodeRED. This time with sunset/sunrise and temp controls

Testing Imou Ranger 2C 2MP & 4MP

0
Imou Ranger 2C comes in 2 flavours 1080P and 2K so let's compare them side by side and see which one is for you