Pleemans
Published © Apache-2.0

Using the IKEA TRADFRI Control for Your Project

The IKEA TRADFRI is a 15€ remote control capable of delivering 13 different functions. What if you could use this within your own project?

AdvancedFull instructions provided2 hours558
Using the IKEA TRADFRI Control for Your Project

Things used in this project

Hardware components

Raspberry Pi 3 Model B
Raspberry Pi 3 Model B
×1
Flash Memory Card, SD Card
Flash Memory Card, SD Card
×1
5V 2.5A Switching Power Supply
Digilent 5V 2.5A Switching Power Supply
×1
Zigbee CC2531 USB stick
×1

Software apps and online services

AllThingsTalk Maker
AllThingsTalk Maker
Node-RED
Node-RED

Story

Read more

Code

Node Red Flow

JavaScript
Import the code into Node-Red
[
    {
        "id": "b2e96dac.1b9b1",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": ""
    },
    {
        "id": "8a00a9c1.ad6ef8",
        "type": "mqtt in",
        "z": "b2e96dac.1b9b1",
        "name": "",
        "topic": "zigbee2mqtt/0xec1bbdfffea7f15c/#",
        "qos": "0",
        "datatype": "json",
        "broker": "c3f84e99.0ea82",
        "x": 180,
        "y": 380,
        "wires": [
            [
                "c11dbd4.868c24",
                "9a7a83d1.231d7"
            ]
        ]
    },
    {
        "id": "c11dbd4.868c24",
        "type": "debug",
        "z": "b2e96dac.1b9b1",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "x": 450,
        "y": 340,
        "wires": []
    },
    {
        "id": "9a7a83d1.231d7",
        "type": "switch",
        "z": "b2e96dac.1b9b1",
        "name": "Action",
        "property": "payload.action",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "toggle",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "arrow_right_click",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "arrow_left_click",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "brightness_up_click",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "brightness_down_click",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "brightness_up_hold",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "brightness_up_release",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "brightness_down_hold",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "brightness_down_release",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "arrow_right_release",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "arrow_left_release",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 11,
        "x": 350,
        "y": 560,
        "wires": [
            [
                "728268b7.26db68"
            ],
            [
                "2cb00233.6adb8e"
            ],
            [
                "ecf7eecc.06cce"
            ],
            [
                "aa9c58ab.67c338"
            ],
            [
                "f1a71d2d.510ea"
            ],
            [],
            [],
            [],
            [],
            [],
            []
        ]
    },
    {
        "id": "728268b7.26db68",
        "type": "function",
        "z": "b2e96dac.1b9b1",
        "name": "Toggle",
        "func": "var current = flow.get(\"currentState\");\nmsg.topic = \"device/YpI5gR5UAGcQv5GaSuCdmWwp/asset/toggle/state\";\nif(current === \"ON\"){\n    state = \"OFF\";\n    flow.set(\"currentState\", state);\n    msg.payload = {\n        \"value\": state\n    };\n    return msg;\n}\nif(current === \"OFF\" || undefined){\n    state = \"ON\";\n    flow.set(\"currentState\", state);\n    msg.payload = {\n        \"value\": state\n    };\n    return msg;\n}\n\n\n",
        "outputs": 1,
        "noerr": 0,
        "x": 570,
        "y": 420,
        "wires": [
            [
                "93a16597.ef9968"
            ]
        ]
    },
    {
        "id": "c85aabb6.f1e158",
        "type": "inject",
        "z": "b2e96dac.1b9b1",
        "name": "Initialize",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "x": 120,
        "y": 300,
        "wires": [
            [
                "8cfc2204.41e22"
            ]
        ]
    },
    {
        "id": "8cfc2204.41e22",
        "type": "function",
        "z": "b2e96dac.1b9b1",
        "name": "",
        "func": "flow.set(\"currentState\", \"OFF\");\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 280,
        "y": 300,
        "wires": [
            []
        ]
    },
    {
        "id": "2cb00233.6adb8e",
        "type": "function",
        "z": "b2e96dac.1b9b1",
        "name": "arrow_right_click",
        "func": "msg.topic = \"device/YpI5gR5UAGcQv5GaSuCdmWwp/asset/arrow/state\";\nmsg.payload = { \"value\": \"right\"};\nreturn msg;\n\n\n\n",
        "outputs": 1,
        "noerr": 0,
        "x": 610,
        "y": 460,
        "wires": [
            [
                "93a16597.ef9968"
            ]
        ]
    },
    {
        "id": "93a16597.ef9968",
        "type": "mqtt out",
        "z": "b2e96dac.1b9b1",
        "name": "ATTALK Maker",
        "topic": "",
        "qos": "0",
        "retain": "",
        "broker": "73e773f1.06714c",
        "x": 940,
        "y": 460,
        "wires": []
    },
    {
        "id": "ecf7eecc.06cce",
        "type": "function",
        "z": "b2e96dac.1b9b1",
        "name": "arrow_left_click",
        "func": "msg.topic = \"device/YpI5gR5UAGcQv5GaSuCdmWwp/asset/arrow/state\";\nmsg.payload = { \"value\": \"left\"};\nreturn msg;\n\n\n\n",
        "outputs": 1,
        "noerr": 0,
        "x": 580,
        "y": 500,
        "wires": [
            [
                "93a16597.ef9968"
            ]
        ]
    },
    {
        "id": "aa9c58ab.67c338",
        "type": "function",
        "z": "b2e96dac.1b9b1",
        "name": "brightness_up_click",
        "func": "msg.topic = \"device/YpI5gR5UAGcQv5GaSuCdmWwp/asset/brightness/state\";\nmsg.payload = { \"value\": \"up\"};\nreturn msg;\n\n\n\n",
        "outputs": 1,
        "noerr": 0,
        "x": 600,
        "y": 540,
        "wires": [
            [
                "93a16597.ef9968"
            ]
        ]
    },
    {
        "id": "f1a71d2d.510ea",
        "type": "function",
        "z": "b2e96dac.1b9b1",
        "name": "brightness_down_click",
        "func": "msg.topic = \"device/YpI5gR5UAGcQv5GaSuCdmWwp/asset/brightness/state\";\nmsg.payload = { \"value\": \"down\"};\nreturn msg;\n\n\n\n",
        "outputs": 1,
        "noerr": 0,
        "x": 600,
        "y": 580,
        "wires": [
            [
                "93a16597.ef9968"
            ]
        ]
    },
    {
        "id": "c3f84e99.0ea82",
        "type": "mqtt-broker",
        "z": "",
        "name": "",
        "broker": "localhost",
        "port": "1883",
        "clientid": "",
        "usetls": false,
        "compatmode": false,
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "willTopic": "",
        "willQos": "0",
        "willPayload": ""
    },
    {
        "id": "73e773f1.06714c",
        "type": "mqtt-broker",
        "z": "",
        "name": "AllThingsTalk Maker",
        "broker": "api.allthingstalk.io",
        "port": "1883",
        "clientid": "",
        "usetls": false,
        "compatmode": false,
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "willTopic": "",
        "willQos": "0",
        "willPayload": ""
    }
]

Credits

Pleemans

Pleemans

6 projects • 19 followers
IoT enthusiast and Founder of AllThingsTalk, an open IoT platform for makers and developers

Comments

Add projectSign up / Login