IKEA Styrbar template for Node Red via ZHA event

Hi everyone,

I started my journey with HA a couple of months ago and I quickly realized that the lack of knowledge won’t help me create powerful automations in HA, so I turned to Node Red integration. All went well until I realized that most of the tutorials for Zigbee devices are for Zigbee2MQTT and not ZHA, what I’m using.

I have some Zigbee switches (mostly IKEA) and for one of them I couldn’t find any templates (I’m still not good in this, but perfect in copying :smiley:).

Using TheDevFreak’s template for the Tradfri 5 button remote I managed to create a template for my IKEA Styrbar 4 button remote (IKEA E2001/E2002). Since I already got so much from the community, I thought I will share this. This might be something very basic, but hopefully this will help someone. :slight_smile:

Feel free to use and you have any improvement ideas, please let me know.

[
    {
        "id": "d99fc1c010ef331d",
        "type": "tab",
        "label": "Styrbar 4 Button Template",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "b84d8651a1485cf6",
        "type": "server-events",
        "z": "d99fc1c010ef331d",
        "name": "ZHA Events",
        "server": "7a584545.cad7dc",
        "version": 1,
        "event_type": "zha_event",
        "exposeToHomeAssistant": false,
        "haConfig": [
            {
                "property": "name",
                "value": ""
            },
            {
                "property": "icon",
                "value": ""
            }
        ],
        "waitForRunning": true,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "eventData"
            },
            {
                "property": "topic",
                "propertyType": "msg",
                "value": "$outputData(\"eventData\").event_type",
                "valueType": "jsonata"
            },
            {
                "property": "event_type",
                "propertyType": "msg",
                "value": "$outputData(\"eventData\").event_type",
                "valueType": "jsonata"
            }
        ],
        "x": 290,
        "y": 280,
        "wires": [
            [
                "a82463f170c39487"
            ]
        ]
    },
    {
        "id": "a82463f170c39487",
        "type": "switch",
        "z": "d99fc1c010ef331d",
        "name": "Device IEEE",
        "property": "payload.event.device_ieee",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 530,
        "y": 280,
        "wires": [
            [
                "08f71f2acebb71b9"
            ]
        ],
        "outputLabels": [
            "Styrbar 4 Button Remote"
        ]
    },
    {
        "id": "08f71f2acebb71b9",
        "type": "switch",
        "z": "d99fc1c010ef331d",
        "name": "Styrbar 4 button",
        "property": "payload.event.command",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "on",
                "vt": "str"
            },
            {
                "t": "jsonata_exp",
                "v": "msg.payload.event.command = \"press\" and msg.payload.event.args[0] = 256",
                "vt": "jsonata"
            },
            {
                "t": "jsonata_exp",
                "v": "msg.payload.event.command = \"press\" and msg.payload.event.args[0] = 257",
                "vt": "jsonata"
            },
            {
                "t": "eq",
                "v": "off",
                "vt": "str"
            },
            {
                "t": "jsonata_exp",
                "v": "msg.payload.event.command = \"move_with_on_off\" and msg.payload.event.args[0] = 0",
                "vt": "jsonata"
            },
            {
                "t": "jsonata_exp",
                "v": "msg.payload.event.command = \"move\" and msg.payload.event.args[0] = 1",
                "vt": "jsonata"
            },
            {
                "t": "eq",
                "v": "stop",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "release",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 8,
        "x": 810,
        "y": 280,
        "wires": [
            [],
            [],
            [],
            [],
            [],
            [],
            [],
            []
        ],
        "outputLabels": [
            "On",
            "Right",
            "Left",
            "Off",
            "UpHoldStart",
            "DownHoldStart",
            "StopHoldingUpDown",
            "ReleaseLeftRight"
        ]
    },
    {
        "id": "0933f59a4941e452",
        "type": "comment",
        "z": "d99fc1c010ef331d",
        "name": "Insert device IEEE here",
        "info": "",
        "x": 530,
        "y": 220,
        "wires": []
    },
    {
        "id": "efe74c423d3f779b",
        "type": "comment",
        "z": "d99fc1c010ef331d",
        "name": "Ensure server dropdown is correct",
        "info": "",
        "x": 210,
        "y": 220,
        "wires": []
    },
    {
        "id": "7a584545.cad7dc",
        "type": "server",
        "name": "Home Assistant",
        "version": 2,
        "addon": true,
        "rejectUnauthorizedCerts": true,
        "ha_boolean": "y|yes|true|on|home|open",
        "connectionDelay": true,
        "cacheJson": true,
        "heartbeat": false,
        "heartbeatInterval": 30
    }
]
9 Likes

Very helpful, thank you!

Indeed, quite helpful. Thanks for sharing, mate.

Would it be possible to add right and left long press actions?

@solaced, long press press for up/down is implemented on outputs 5/6 respectively.

Long press for left/right is tricky because the devices sends 5 commands when holding, including 2 “release” commands:

  • release
  • on
  • press
  • hold
  • release

Nice to know that there is such an option :wink: I just bought a lamp + a remote control and now there are more capabilities to control HA, is great…
Can you share flows ?
I would appreciate :bulb:: :blush::pray: