Jarolift shutter integration via MQTT/Node-RED

Others (MiLight, Hue, Toon etc...)

Moderator: leecollings

Post Reply
krisha
Posts: 11
Joined: Monday 21 August 2017 16:43
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Jarolift shutter integration via MQTT/Node-RED

Post by krisha »

I created a small Node-RED flow to integrate my Jarolift shutters via MQTT. The ESP code is modified to also support individual positions.

Not sure if there are so many people using Jarolift shutters...

Requirements:
  • ESP with CC1101
  • attached Node-RED flow
In general you connect the CC1101 to the ESP and flash it with Jarolift_MQTT.

After that the ESP opens an access point for 180 seconds. Configure your wifi and reconnect through the local network. Set MQTT server and Jarolift mastercode (maybe you find it here or ask someone). Also set a serial number similiar to your original remote (sniffed on Arduino console).

For each shutter press up+down together and 8x stop on the remote control. Within 5 seconds press "learn" on the Web-UI. Measure the time between open and closed in milliseconds and save it as well. In domoticz create a dummy switch for each shutter and change the type to "blinds percentage", note the domoticz idx.

Add the attached flow to Node-Red and modify the table in function "shutter id <-> domoticz idx" with your values. Maybe also set your mqtt server ;)

That's it :)

If more details are needed, let me know. I also created a dummy blind switch with some LUA code for grouping the shutters.

Code: Select all

[
    {
        "id": "8e1aef14.aaf7f",
        "type": "tab",
        "label": "Jarolift",
        "disabled": false,
        "info": ""
    },
    {
        "id": "e5520d3e.e38cc",
        "type": "mqtt in",
        "z": "8e1aef14.aaf7f",
        "name": "",
        "topic": "domoticz/out",
        "qos": "2",
        "broker": "c6f4c5a6.743d78",
        "x": 190,
        "y": 240,
        "wires": [
            [
                "1d3ea11f.e1a7bf"
            ]
        ]
    },
    {
        "id": "1d3ea11f.e1a7bf",
        "type": "json",
        "z": "8e1aef14.aaf7f",
        "name": "",
        "property": "payload",
        "action": "",
        "pretty": false,
        "x": 350,
        "y": 240,
        "wires": [
            [
                "a066702d.ada4f"
            ]
        ]
    },
    {
        "id": "ba1cca37.180778",
        "type": "function",
        "z": "8e1aef14.aaf7f",
        "name": "shutter id <-> domoticz idx",
        "func": "var idx_jarolift_table = [\n    //[ domoticz idx, shutter ],   // syntax\n    [391, 0],   // guest 2\n    [392, 1],	//sleeping room\n];\n\n// block loopback messages from domoticz\nvar last_message_from_jarolift = flow.get('message_from_jarolift') || [16];\n\nif ( msg.src == 'jarolift' ) {\n    var matches = msg.topic.match( /stat\\/jarolift\\/shutter\\/(\\d+)/ );\n    if ( matches.length == 2 ) {\n        var jarolift_id = parseInt( matches[1] );\n\n        for ( var i = 0; i < idx_jarolift_table.length; i++ ) {\n            if ( idx_jarolift_table[i][1] == jarolift_id ) {\n                var val = parseInt(msg.payload);\n\n                msg = {\n                    payload:\n                    {\n                        nvalue: 2,\n                        svalue: \"\" + val,\n                        command: \"udevice\",\n                        /*command: \"switchlight\",\n                        switchcmd:\"Set Level\",\n                        level: val,*/\n                        idx: idx_jarolift_table[i][0],\n                    }\n                }\n                \n                last_message_from_jarolift[jarolift_id] = true;\n                flow.set('message_from_jarolift', last_message_from_jarolift);\n                \n                return [msg, null, null];\n            }\n        }\n        \n        // jarolift not found in table\n        msg.jarolift_id = jarolift_id;\n        return [null, null, msg];\n    }\n}\n\nif ( msg.src == 'domoticz' ) {\n    for ( var i = 0; i < idx_jarolift_table.length; i++ ) {\n        if ( idx_jarolift_table[i][0] == parseInt(msg.payload.idx) ) {\n            //msg._org = msg.payload;\n            \n            var jarolift_id = idx_jarolift_table[i][1];\n            \n            //dismiss loopback messages from domoticz\n            if ( last_message_from_jarolift[jarolift_id] ) {\n                last_message_from_jarolift[jarolift_id] = false;\n                flow.set('message_from_jarolift', last_message_from_jarolift);\n                return [null, null, null];\n            }\n            \n            switch ( parseInt( msg.payload.nvalue ) ) {\n                case 0:\n                    // open clicked or 0%\n                    msg.payload = \"UP\";\n                    break;\n                case 1:\n                    // close clicked or 100%\n                    msg.payload = \"DOWN\";\n                    break;\n                case 2:\n                    // custom percentage position\n                    msg.payload = \"POS\" + msg.payload.svalue1;\n                    break;\n            }\n\n            msg.topic = \"cmd/jarolift/shutter/\" + idx_jarolift_table[i][1];\n            return [null, msg, null ];\n        }\n    }\n}\n\n// dismiss\nreturn [null, null, null];",
        "outputs": 3,
        "noerr": 0,
        "x": 780,
        "y": 260,
        "wires": [
            [
                "158534b2.714f1b",
                "f74b8747.b31d48"
            ],
            [
                "7199c1d6.dbab8",
                "44086a88.17d814"
            ],
            [
                "a2ddbea2.cf207"
            ]
        ]
    },
    {
        "id": "a066702d.ada4f",
        "type": "function",
        "z": "8e1aef14.aaf7f",
        "name": "add src",
        "func": "msg.src = 'domoticz';\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 520,
        "y": 240,
        "wires": [
            [
                "ba1cca37.180778"
            ]
        ]
    },
    {
        "id": "ddb8ae6.05acf5",
        "type": "function",
        "z": "8e1aef14.aaf7f",
        "name": "add src",
        "func": "msg.src = 'jarolift';\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 480,
        "y": 360,
        "wires": [
            [
                "ba1cca37.180778"
            ]
        ]
    },
    {
        "id": "a981abb8.66b038",
        "type": "mqtt in",
        "z": "8e1aef14.aaf7f",
        "name": "",
        "topic": "stat/jarolift/shutter/+",
        "qos": "2",
        "broker": "c6f4c5a6.743d78",
        "x": 210,
        "y": 360,
        "wires": [
            [
                "ddb8ae6.05acf5"
            ]
        ]
    },
    {
        "id": "f74b8747.b31d48",
        "type": "mqtt out",
        "z": "8e1aef14.aaf7f",
        "name": "",
        "topic": "domoticz/in",
        "qos": "",
        "retain": "",
        "broker": "c6f4c5a6.743d78",
        "x": 1110,
        "y": 160,
        "wires": []
    },
    {
        "id": "44086a88.17d814",
        "type": "mqtt out",
        "z": "8e1aef14.aaf7f",
        "name": "mqtt to jarolift",
        "topic": "",
        "qos": "0",
        "retain": "false",
        "broker": "c6f4c5a6.743d78",
        "x": 1120,
        "y": 280,
        "wires": []
    },
    {
        "id": "158534b2.714f1b",
        "type": "debug",
        "z": "8e1aef14.aaf7f",
        "name": "from jarolift",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "x": 1110,
        "y": 220,
        "wires": []
    },
    {
        "id": "7199c1d6.dbab8",
        "type": "debug",
        "z": "8e1aef14.aaf7f",
        "name": "from domoticz",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "x": 1120,
        "y": 340,
        "wires": []
    },
    {
        "id": "a2ddbea2.cf207",
        "type": "debug",
        "z": "8e1aef14.aaf7f",
        "name": "unlinked",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "x": 1100,
        "y": 420,
        "wires": []
    },
    {
        "id": "c6f4c5a6.743d78",
        "type": "mqtt-broker",
        "z": "",
        "name": "mqtt home",
        "broker": "localhost",
        "port": "1883",
        "clientid": "node-red",
        "usetls": false,
        "compatmode": true,
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "willTopic": "",
        "willQos": "0",
        "willPayload": ""
    }
]
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest