Control iKea Tradfri with Venus GX Large Image (Node-Red)

xsilvergs

Forum Member
Updated: 17-12-22
While sat in the van the other week we were using a cheap Lidl fan heater which has a very insensitive thermostat so we're too hot and then too cold! I thought this is a great opportunity to get the Ruuvi tag to control the fan heater so I set about some internet searching...

A few days ago I received a CC_2531 Zigbee sniffer, yesterday I received a iKea Tradfri Smart Socket (my first iKea product). Although there are alternatives to the Tradfri most of them require an internet connection to operate where as the Tradfri works over Zigbee WiFi on its own local network.

This is the cc_2531 I purchased (sold as:- Wireless CC2531 Sniffer Bare Board Protocol Analyzer Module USB Interface Dongle).

I used a spare RPi as they have the GPIO pins for easy connection to flash the CC_2531 and used the following guide Video Tutorial the biggest problem was that WiringPi has been deprecated from the Pi build so I had to search the web and install it manually.

With the CC_2531 flashed I installed Venus OS Large Image and enabled Node-Red. Install from the Palette Manager these tthree nodes: 'node-red-dashboard', 'node-red-contrib-throttle' and 'node-red-contrib-zigbee2mqtt'.

Download zigbee2mqtt from Here , unzip the download, rename it (remove '-master') and place it as per the image on your Venus GX.
Screenshot at 2022-12-13 16-15-55.png

I find to simplest way to move file is using Filezilla.

In the GX Remote Console under 'Services' enable MQTT.

Then following parts of This Guide I worked through the following

In a Terminal type the following after setting a password in the Remote Console:-
ssh root@<ip of my GX device>
cd /data/home/zigbee2mqtt
npm ci
cd /data/home/zigbee2mqtt/data
nano configuration.yaml
cd /data/home/zigbee2mqtt
npm start

I do find that manually starting npm can take two attempts and it needs to be started after every boot.

To have npm run at each boot, which appears to start the cc_2531, I added two more files. (This bit is work in progress. I believe that files in the /data folder don't change when there is a software update but I will only know this when I do an update).
In /data create a file called rcS.local. The file should contain something similar to this depending on your zigbee2mqtt directory location. Set rc.local permissions to 775:-

In Terminal type the following:-

cd /data
nano rcS.local

Copy and paste the code block below into nano

ctrl x
y
chmod 775 /data/rcS.local

Code:
#!/bin/bash
nohup /data/home/start_npm &
exit

In Terminal type the following:-

cd /data/home
nano start_npm

Copy and paste the code block below into nano

ctrl x
y
chmod 775 /data/home/start_npm

Code:
#!/bin/sh
exec 2>&1
cd /data/home/zigbee2mqtt
exec npm start

This should run the 'npm start' command to start the zigbee2mqtt when your Pi or GX starts.

I thinks that's all the installation work.

The Node-Red flow looks like this
Screenshot at 2022-12-13 17-03-02.png

Import code below into your Node-Red flow and Deploy it. Press the reset pin in the Tradfri Smart Socket for 10 seconds and select YOUR device in the nodes and Deploy it again. Hopefully you can turn the Smart Socket ON and OFF from your vans local network or via the VRM app remotely.

Sorry if there are any mistakes in this, if it doesn't work or you get stuck I'll try and help.

Code:
[
    {
        "id": "75c64f88.cfdf8",
        "type": "tab",
        "label": "test Tradfri",
        "disabled": false,
        "info": ""
    },
    {
        "id": "4cf980d2dc54e8b1",
        "type": "inject",
        "z": "75c64f88.cfdf8",
        "name": "Status",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "device",
        "payloadType": "str",
        "x": 90,
        "y": 100,
        "wires": [
            [
                "73d2ad663e2a4067"
            ]
        ]
    },
    {
        "id": "156924abea23326f",
        "type": "inject",
        "z": "75c64f88.cfdf8",
        "name": "",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "ON",
        "payloadType": "str",
        "x": 90,
        "y": 320,
        "wires": [
            [
                "274c19d71b8081a6"
            ]
        ]
    },
    {
        "id": "59c53a42c0037c5f",
        "type": "debug",
        "z": "75c64f88.cfdf8",
        "name": "debug 5",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 720,
        "y": 100,
        "wires": []
    },
    {
        "id": "a6cdbab04eff6556",
        "type": "inject",
        "z": "75c64f88.cfdf8",
        "name": "",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "OFF",
        "payloadType": "str",
        "x": 90,
        "y": 280,
        "wires": [
            [
                "274c19d71b8081a6"
            ]
        ]
    },
    {
        "id": "e0d5f51f633f77b2",
        "type": "debug",
        "z": "75c64f88.cfdf8",
        "name": "debug 6",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 720,
        "y": 200,
        "wires": []
    },
    {
        "id": "9e5982b313c9fa52",
        "type": "debug",
        "z": "75c64f88.cfdf8",
        "name": "debug 7",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 660,
        "y": 460,
        "wires": []
    },
    {
        "id": "57669f8eabf6d38f",
        "type": "zigbee2mqtt-out",
        "z": "75c64f88.cfdf8",
        "name": "",
        "server": "17070e263202e31e",
        "friendly_name": "0xf4b3b1fffe8c2b6f (E1603/E1702/E1708)",
        "device_id": "0xf4b3b1fffe8c2b6f",
        "command": "state",
        "commandType": "z2m_cmd",
        "payload": "payload",
        "payloadType": "msg",
        "optionsValue": "",
        "optionsType": "nothing",
        "x": 640,
        "y": 280,
        "wires": []
    },
    {
        "id": "394910cde8cea805",
        "type": "zigbee2mqtt-bridge",
        "z": "75c64f88.cfdf8",
        "name": "",
        "server": "17070e263202e31e",
        "topic": null,
        "x": 130,
        "y": 460,
        "wires": [
            [
                "1f5d5fc38efc0e37"
            ]
        ]
    },
    {
        "id": "7c1ea673616fabd8",
        "type": "zigbee2mqtt-in",
        "z": "75c64f88.cfdf8",
        "name": "",
        "server": "17070e263202e31e",
        "friendly_name": "0xf4b3b1fffe8c2b6f (E1603/E1702/E1708)",
        "device_id": "0xf4b3b1fffe8c2b6f",
        "state": "0",
        "outputAtStartup": true,
        "filterChanges": false,
        "enableMultiple": false,
        "x": 180,
        "y": 200,
        "wires": [
            [
                "03d361f5c14fe594"
            ]
        ]
    },
    {
        "id": "73d2ad663e2a4067",
        "type": "zigbee2mqtt-get",
        "z": "75c64f88.cfdf8",
        "name": "",
        "server": "17070e263202e31e",
        "friendly_name": "0xf4b3b1fffe8c2b6f (E1603/E1702/E1708)",
        "device_id": "0xf4b3b1fffe8c2b6f",
        "state": "0",
        "enableMultiple": false,
        "x": 420,
        "y": 100,
        "wires": [
            [
                "59c53a42c0037c5f"
            ]
        ]
    },
    {
        "id": "03d361f5c14fe594",
        "type": "throttle",
        "z": "75c64f88.cfdf8",
        "name": "",
        "throttleType": "time",
        "timeLimit": "2",
        "timeLimitType": "seconds",
        "countLimit": 0,
        "blockSize": 0,
        "locked": false,
        "x": 490,
        "y": 200,
        "wires": [
            [
                "e0d5f51f633f77b2"
            ]
        ]
    },
    {
        "id": "1f5d5fc38efc0e37",
        "type": "throttle",
        "z": "75c64f88.cfdf8",
        "name": "",
        "throttleType": "time",
        "timeLimit": "2",
        "timeLimitType": "seconds",
        "countLimit": 0,
        "blockSize": 0,
        "locked": false,
        "x": 410,
        "y": 460,
        "wires": [
            [
                "9e5982b313c9fa52"
            ]
        ]
    },
    {
        "id": "274c19d71b8081a6",
        "type": "ui_switch",
        "z": "75c64f88.cfdf8",
        "name": "",
        "label": "switch",
        "tooltip": "",
        "group": "c83ac4fc4b7daa51",
        "order": 0,
        "width": 0,
        "height": 0,
        "passthru": true,
        "decouple": "false",
        "topic": "",
        "style": "",
        "onvalue": "ON",
        "onvalueType": "str",
        "onicon": "",
        "oncolor": "",
        "offvalue": "OFF",
        "offvalueType": "str",
        "officon": "",
        "offcolor": "",
        "x": 270,
        "y": 280,
        "wires": [
            [
                "57669f8eabf6d38f"
            ]
        ]
    },
    {
        "id": "17070e263202e31e",
        "type": "zigbee2mqtt-server",
        "name": "",
        "host": "localhost",
        "mqtt_port": "1883",
        "mqtt_username": "",
        "mqtt_password": "",
        "mqtt_qos": "1",
        "tls": "47c99f2f.8b1c1",
        "usetls": false,
        "base_topic": "zigbee2mqtt"
    },
    {
        "id": "c83ac4fc4b7daa51",
        "type": "ui_group",
        "name": "Default",
        "tab": "d4df21c4c061eafa",
        "order": 1,
        "disp": true,
        "width": "6",
        "collapse": false
    },
    {
        "id": "47c99f2f.8b1c1",
        "type": "tls-config",
        "name": "TLS Gbridge",
        "cert": "",
        "key": "",
        "ca": "",
        "certname": "",
        "keyname": "",
        "caname": "",
        "servername": "mqtt.gbridge.io",
        "verifyservercert": true
    },
    {
        "id": "d4df21c4c061eafa",
        "type": "ui_tab",
        "name": "Home",
        "icon": "dashboard",
        "disabled": false,
        "hidden": false
    }
]
 
Last edited:

wildebus

Forum Member
Interesting. I put a 400W Oil rad in the motorhome today and was going to use an Alexa controlled socket to remotely turn on and off (got an Alexa setup in the motorhome). But I did think about using a relay-controlled socket to automate it based on temp sensor data, which would be a better plan (I have sockets that are controlled via the Cerbo Relay 2, but those are currently outside sockets only)

To use the Smart plug above, do you need to use the GPIO connection on the Pi, or will Node Red recognise it if it is on the same Intranet subnet?
 

xsilvergs

Forum Member
The gpio pins are used to re-flash the cc_2531 board only. This would probably be the most frightening bit of the whole project.

Node-Red on your Cerbo communicates with the Smart Socket over zigbee WiFi via the cc_2531. I was surprised that the the Venus OS had the drivers for the cc_2531 but it works.
 

wildebus

Forum Member
The gpio pins are used to re-flash the cc_2531 board only. This would probably be the most frightening bit of the whole project.

Node-Red on your Cerbo communicates with the Smart Socket over zigbee WiFi via the cc_2531. I was surprised that the the Venus OS had the drivers for the cc_2531 but it works.
Are these the same sockets? - https://amzn.to/3hu6Rn3


PS. Possible aside. I have 2 (maybe 3?) different types of Smart Sockets and I found if I have one of them (maybe the Tapo brand I think?), then the other one cannot be accessed. This is with Alexa control, but there could be a conflict of drivers between socket types using other interfaces?
I don't know if it is relevant to using the Node Red/Venus stuff if expanding the setup but just mentioning it in case unexpected quirks arise.
 

xsilvergs

Forum Member
Are these the same sockets? - https://amzn.to/3hu6Rn3


PS. Possible aside. I have 2 (maybe 3?) different types of Smart Sockets and I found if I have one of them (maybe the Tapo brand I think?), then the other one cannot be accessed. This is with Alexa control, but there could be a conflict of drivers between socket types using other interfaces?
I don't know if it is relevant to using the Node Red/Venus stuff if expanding the setup but just mentioning it in case unexpected quirks arise.
This is the Smart Socket I bought Ikea Smart Socket. The ones in your link are zigbee so may work but I have no experience with them.

This is the cc_2531 I purchased.

As for multiple devices I can't comment as this is the first I have bought having always built my own in the past. I may purchase more in the future but there must be a limit to the number that can be fitted in a motorhome.
 
Last edited:

wildebus

Forum Member
Looks good. What is the bit sticking out? (not the USB plug end I meant)

FWIW, I usually use Lego bricks to make cases. Actually surprisingly effective and efficient :)
 

Users who viewed this discussion (Total:0)

Top