Time to cook: 120min
Difficulty: +++++
In the previous recipe we explained how to connect an IKEA smart bulb. This recipe builds further on this concept and add’s an IKEA TRADFRI remote control. With this remote, IKEA allows you to control their smart light Bubs, such as turning them on/off, changing the color and adapt the brightness. In total the remote hosts 11 different functions. With a price of 15€ and the fact it runs on a cell coin battery, it brings a lot of possibilities within our connected home.
This recipe demonstrates how you can use the IKEA TRADFRI remote to control anything in your home using the open system-of-systems architecture. We will use Node-RED to wire up things.
Ingredients
IKEA Tradfri Remote Control
Zigbee USB stick (model CC2531)
Prerequisites
Execute the recipe ‘Building a Smart HUB’
Execute the recipe ‘Installing Node-RED’
Installing MQTT
Tools
The Building Plan
Pairing The IKEA TRADFRI Remote Controller
Like the IKEA smart light bulb, the TRADFRI remote controller uses Zigbee to comunicate. First, setup the zigbee2Mqtt environment as explained in the previous receipe. When done, we need to pair the TRADFRI remote controller, so we can receive an MQTT payload topic for each of the functions behind the remote control.
To pair a zigbee device, make sure that the permit_join: true is set in your configuration.yaml file. Otherwise the new devices cannot join the network!
nano /opt/zigbee2mqtt/data/configuration.yaml
Set PermitJoin : true (this puts the Controller in Join mode)
save
Note: To follow the commissioning process, you can view the Node-RED log on the Raspberry-Pi. The output would look similar to the one below.
Once you see something similar to below in the log your device is paired.
zigbee2mqtt:info 2019-11-09T12:19:56: Successfully interviewed ‘0x00158d0001dc126a’, device has successfully been paired
Creating a Node-RED flow
Now we can wire everything up by creating a Node-RED flow to upload the device state from the different buttons on the TRADFRI Remote Control. The Node-RED flow listens on the MQTT topics to trigger on the state changes of each of the buttons.
Login to your Node-RED environment on your Smart HUB
The Flow looks as follows and can be imported from the code below in Node-RED.
The Flow subscribes to the MQTT topics from the zigbee2MQTT component, interpretes the data and forwards it to a debug node.
The MQTT input node listens to the zigbee2mqtt/# Topic. The ‘#’ represents a wildcard. This means that the MQTT node outputs all messages from MQTT Topics that start with zigbee2mqtt.
The messages are then parsed using an Edit switch node. This node parses all messages from our IKEA TRADFRI Remote Control. There are in total 11 different messages which we can distinguish.
toggle
arrow_richt_click
arrow_left_click
brightness_up_click
brightness_down_click
brightness_up_hold
brightness_up_release
brightness_down _hold
brightness_down _release
arrow_right_release
arrow_left_release
The output for the toggle message looks as follows:
A right click results in the following message:
Test The Flow:
Import the flow above.
Configure the MQTT in node to point to your local Mosquitto MQTT broker
Deploy the flow
What’s Next?
Use your imagination and think of how you can use the TRADFRI Remote Control to actuate anything in your home. With the above solution, you are not limited anymore to the IKEA IoT ecosystem but now you can use the TRADFRI Remote Control for anything you want to control. For example your SONOS speakers, Blinds, television set, you name it.
Comments