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

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

DIY Smart Washing Machine – for about 15 bucks!

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

Sonoff Zigbee Bridge – review

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

Smart Home

Remotes aren’t done with us yet: SwitchBot Remote

0
If you hate having 20 remotes hidden in your sofa, or your parents despise talking to Alexa to turn the lights on - SwitchBot Universal Remote is here to deal with all this!

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?