The TRADFRI plug is a simple way to switch existing consumers such as lamps via your smart home system via Zigbee
The consumer can be switched on and off. At the same time, the socket also acts as a signal amplifier (repeater) for all other Zigbee devices.
How to integrate the TRADFRI plug into your Node Red instance is described in the following article.
I know the following hints are always a bit annoying and seem unnecessary. But unfortunately, many people who knew it "better" from carelessness lost their eyes, fingers or other things or hurt themselves. In comparison, a loss of data is almost not worth mentioning, but even these can be really annoying. Therefore, please take five minutes to read the safety instructions. Even the coolest project is worth no injury or other annoyance. https://www.nerdiy.de/en/sicherheitshinweise/
The links to online shops listed here are so-called affiliate links. If you click on such an affiliate link and shop via this link, Nerdiy.de receives a commission from the online shop or provider concerned. The price doesn't change for you. If you do your purchases via these links, you will support Nerdiy.de in being able to offer further useful projects in the future. 🙂
Before you start this article, you should have prepared a Raspberry Pi so that it can be reached via the network and controlled via SSH. Of course, zigbee2mqtt and Node Red should also be installed and configured.
- RaspberryPi – Setup for nerdiys!
- RaspberryPi – The first configuration!
- RaspberryPi – Control the RaspberryPi via SSH
- NodeRed – Installation von NodeRed auf dem RaspberryPi
- Zigbee – Installing zigbee2mqtt on the Raspberry Pi
- Zigbee – register devices, sensors and actuators with zigbee2mqtt
In the following lists you will find all the parts you need to implement this article.
Enable Zigbee2mqtt Dashboard
In my opinion, the easiest way to add new devices to your Zigbee network is to use the zigbee2mqtt dashboard. In case you haven’t activated this yet, you will find helpful hints in the article Zigbee – Administration of Zigbee2mqtt via the dashboard.
Register sensor to zigbee2mqtt
Before you can control the IKEA TRADFRI outlet using Node Red, you must first integrate it into your Zigbee network.
How to integrate devices into your own Zigbee network is described in more detail in the article Zigbee – register devices or sensors and actuators with zigbee2mqtt. The following two steps summarize this briefly.
Um den TRADFRI Stecker in den Pairing-Modus zu bringen müsst Ihr die Batterie einlegen und mit einem länglichen Gegenstand (z.B. aufgebogene Büroklammer) den Taster in dem kleinen Loch
- für 10 Sekunden gedrückt halten
Die LED auf der Vorderseite der Steckdose sollte dann blinken und die Steckdose sich kurz darauf mit Eurem Zigbee Netzwerk verbinden.
Den Status des Verbindungsvorgang könnt Ihr im Log von zigbee2mqtt verfolgen.
Log in to the NodeRed configuration interface
Before you can edit your NodeRed configuration you must - if activated - first log in to the NodeRed configuration interface.
Import node code
The dashboard node should already be installed and configured so that you can also control your Zigbee device via the NodeRed dashboard or display the values. You can find information about this in the following article.
After that, all you have to do is import the NodeCode linked below into your NodeRed environment. Information on how to import NodeRed code can be found in the article Node Red – import and export node code .
As always, you can find the NodeRed code in the Nerdiy Git repository under the following link:
Of course you still have to adapt the code to your socket. In order for this to work correctly, you still have to enter the IEEE address or the “friendly name” in the Node Red code.
To do this, open the properties of the marked node and enter your IEEE address in the marked area under “Payload…”. How to find out the IEEE address of your Zigbee device is described in the article Zigbee – register devices or sensors and actuators with zigbee2mqtt.
In order for the update function to work via the Node Red Dashboard, you must also enter the address here in the marked area.
In addition, the address must still be in this…
… and enter the marked area here.
If you would like to be automatically notified in the event that the socket has not been seen in the Zigbee network for a certain time, you can edit the corresponding message here.
In the following category I have also listed other Zigbee devices which can be controlled or read with the Node Red code offered there.
More articles on the topic
I have summarized other articles on the subject of Zigbee and zigbee2mqtt in the following category. There you will also find articles on various Zigbee devices and how they can be controlled from Node Red.
Have fun with the project
I hope everything worked as described. If not or you have any other questions or suggestions, please let me know in the comments. Also, ideas for new projects are always welcome. 🙂
P.S. Many of these projects - especially the hardware projects - cost a lot of time and money. Of course I do this because I enjoy it, but if you appreciate it that I share these information with you, I would be happy about a small donation to the coffee box. 🙂