Shelly 1 Plus

Does Anyone have a Shelly Plus 1 relay working in node-red? I successfully connected it to MQTT, but I can’t figure out how to turn it off and on with node-red. I think I have tried all combinations, but no luck. Any help would be appreciated.

I have a Shelly 1. I’ll look it up when i get home if no one has piped in.

1 Like

I think the Shelly 1 plus is different, as far as I can tell, but thank you for any help you can offer.

This is what I have, and it works well. You can control via mqtt or http request

Summary
[
    {
        "id": "ad32d745225d959b",
        "type": "ui_switch",
        "z": "4690839dc8e12c59",
        "name": "LS - Kitchen Lights",
        "label": "<b>Kitchen</b>",
        "tooltip": "",
        "group": "d526dd5f4deb65e7",
        "order": 7,
        "width": 0,
        "height": 0,
        "passthru": false,
        "decouple": "true",
        "topic": "Shelly/KitchenLights/rpc",
        "topicType": "str",
        "style": "",
        "onvalue": "on",
        "onvalueType": "str",
        "onicon": "",
        "oncolor": "",
        "offvalue": "off",
        "offvalueType": "str",
        "officon": "",
        "offcolor": "",
        "animate": true,
        "className": "",
        "x": 4030,
        "y": 1560,
        "wires": [
            [
                "1db12160680d1b7f"
            ]
        ]
    },
    {
        "id": "954d1537e5575a39",
        "type": "ui_switch",
        "z": "4690839dc8e12c59",
        "name": "Other Kitchen Lights",
        "label": " - Other",
        "tooltip": "",
        "group": "d526dd5f4deb65e7",
        "order": 8,
        "width": 0,
        "height": 0,
        "passthru": false,
        "decouple": "true",
        "topic": "Shelly/KitchenOther/rpc",
        "topicType": "str",
        "style": "",
        "onvalue": "on",
        "onvalueType": "str",
        "onicon": "",
        "oncolor": "",
        "offvalue": "off",
        "offvalueType": "str",
        "officon": "",
        "offcolor": "",
        "animate": true,
        "className": "",
        "x": 4040,
        "y": 1480,
        "wires": [
            [
                "1db12160680d1b7f"
            ]
        ]
    },
    {
        "id": "61df955e9c0584a7",
        "type": "mqtt in",
        "z": "4690839dc8e12c59",
        "name": "",
        "topic": "Shelly/KitchenLights/events/#",
        "qos": "1",
        "datatype": "auto",
        "broker": "5f6b63acb5bc0815",
        "nl": false,
        "rap": true,
        "rh": 0,
        "inputs": 0,
        "x": 3420,
        "y": 1560,
        "wires": [
            [
                "ec635b940a842c36"
            ]
        ]
    },
    {
        "id": "63ea00fd8df52cb0",
        "type": "change",
        "z": "4690839dc8e12c59",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "off",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 3820,
        "y": 1540,
        "wires": [
            [
                "ad32d745225d959b"
            ]
        ]
    },
    {
        "id": "b1f1f2cbda5b027b",
        "type": "change",
        "z": "4690839dc8e12c59",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "on",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 3820,
        "y": 1580,
        "wires": [
            [
                "ad32d745225d959b"
            ]
        ]
    },
    {
        "id": "255ff9da833808b8",
        "type": "mqtt out",
        "z": "4690839dc8e12c59",
        "name": "",
        "topic": "",
        "qos": "1",
        "retain": "true",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "5f6b63acb5bc0815",
        "x": 4430,
        "y": 1520,
        "wires": []
    },
    {
        "id": "5d55b1ef4672cc65",
        "type": "change",
        "z": "4690839dc8e12c59",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{\"id\":123, \"src\":\"user_1\", \"method\":\"Switch.Set\", \"params\":{\"id\":0,\"on\":false}}",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 4305,
        "y": 1500,
        "wires": [
            [
                "255ff9da833808b8"
            ]
        ],
        "l": false
    },
    {
        "id": "1db12160680d1b7f",
        "type": "switch",
        "z": "4690839dc8e12c59",
        "name": "",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "off",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "on",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 4235,
        "y": 1520,
        "wires": [
            [
                "5d55b1ef4672cc65"
            ],
            [
                "a0a7ec47a5011ea9"
            ]
        ],
        "l": false
    },
    {
        "id": "a0a7ec47a5011ea9",
        "type": "change",
        "z": "4690839dc8e12c59",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{\"id\":123, \"src\":\"user_1\", \"method\":\"Switch.Set\", \"params\":{\"id\":0,\"on\":true}}",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 4305,
        "y": 1540,
        "wires": [
            [
                "255ff9da833808b8"
            ]
        ],
        "l": false
    },
    {
        "id": "84f847b2ff4dd2f6",
        "type": "mqtt in",
        "z": "4690839dc8e12c59",
        "name": "",
        "topic": "Shelly/KitchenOther/events/#",
        "qos": "1",
        "datatype": "auto",
        "broker": "5f6b63acb5bc0815",
        "nl": false,
        "rap": true,
        "rh": 0,
        "inputs": 0,
        "x": 3420,
        "y": 1480,
        "wires": [
            [
                "92a14fdcdb754c2c"
            ]
        ]
    },
    {
        "id": "92a14fdcdb754c2c",
        "type": "switch",
        "z": "4690839dc8e12c59",
        "name": "",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "cont",
                "v": "\"output\":false",
                "vt": "str"
            },
            {
                "t": "cont",
                "v": "\"state\":false",
                "vt": "str"
            },
            {
                "t": "cont",
                "v": "\"output\":true",
                "vt": "str"
            },
            {
                "t": "cont",
                "v": "\"state\":true",
                "vt": "str"
            }
        ],
        "checkall": "false",
        "repair": false,
        "outputs": 4,
        "x": 3630,
        "y": 1480,
        "wires": [
            [
                "30d72fc18cf93e4d"
            ],
            [
                "30d72fc18cf93e4d"
            ],
            [
                "bea16bb0efd7658a"
            ],
            [
                "bea16bb0efd7658a"
            ]
        ]
    },
    {
        "id": "30d72fc18cf93e4d",
        "type": "change",
        "z": "4690839dc8e12c59",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "off",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 3820,
        "y": 1460,
        "wires": [
            [
                "954d1537e5575a39"
            ]
        ]
    },
    {
        "id": "bea16bb0efd7658a",
        "type": "change",
        "z": "4690839dc8e12c59",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "on",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 3820,
        "y": 1500,
        "wires": [
            [
                "954d1537e5575a39"
            ]
        ]
    },
    {
        "id": "f63ef4db51f22ab5",
        "type": "inject",
        "z": "4690839dc8e12c59",
        "name": "",
        "props": [
            {
                "p": "url",
                "v": "http://192.168.1.232/rpc/Switch.GetStatus?id=0",
                "vt": "str"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": "40",
        "topic": "",
        "x": 3365,
        "y": 1440,
        "wires": [
            [
                "e328afe5c2aff9fe"
            ]
        ],
        "l": false
    },
    {
        "id": "e328afe5c2aff9fe",
        "type": "http request",
        "z": "4690839dc8e12c59",
        "name": "",
        "method": "GET",
        "ret": "txt",
        "paytoqs": "ignore",
        "url": "",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [],
        "x": 3490,
        "y": 1440,
        "wires": [
            [
                "92a14fdcdb754c2c"
            ]
        ]
    },
    {
        "id": "8b09a91e7555354e",
        "type": "http request",
        "z": "4690839dc8e12c59",
        "name": "",
        "method": "GET",
        "ret": "txt",
        "paytoqs": "ignore",
        "url": "",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [],
        "x": 3500,
        "y": 1620,
        "wires": [
            [
                "ec635b940a842c36"
            ]
        ]
    },
    {
        "id": "ec635b940a842c36",
        "type": "switch",
        "z": "4690839dc8e12c59",
        "name": "",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "cont",
                "v": "\"output\":false",
                "vt": "str"
            },
            {
                "t": "cont",
                "v": "\"state\":false",
                "vt": "str"
            },
            {
                "t": "cont",
                "v": "\"output\":true",
                "vt": "str"
            },
            {
                "t": "cont",
                "v": "\"state\":true",
                "vt": "str"
            }
        ],
        "checkall": "false",
        "repair": false,
        "outputs": 4,
        "x": 3630,
        "y": 1560,
        "wires": [
            [
                "63ea00fd8df52cb0"
            ],
            [
                "63ea00fd8df52cb0"
            ],
            [
                "b1f1f2cbda5b027b"
            ],
            [
                "b1f1f2cbda5b027b"
            ]
        ]
    },
    {
        "id": "1bfcffcfb4b2ec73",
        "type": "inject",
        "z": "4690839dc8e12c59",
        "name": "",
        "props": [
            {
                "p": "url",
                "v": "http://192.168.1.208/rpc/Switch.GetStatus?id=0",
                "vt": "str"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": "40",
        "topic": "",
        "x": 3385,
        "y": 1620,
        "wires": [
            [
                "8b09a91e7555354e"
            ]
        ],
        "l": false
    },
    {
        "id": "d526dd5f4deb65e7",
        "type": "ui_group",
        "name": "Downstairs",
        "tab": "1862e313.45ffad",
        "order": 13,
        "disp": true,
        "width": "3",
        "collapse": false,
        "className": ""
    },
    {
        "id": "5f6b63acb5bc0815",
        "type": "mqtt-broker",
        "name": "zwave",
        "broker": "192.168.1.79",
        "port": "1883",
        "clientid": "",
        "autoConnect": true,
        "usetls": false,
        "protocolVersion": "4",
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willPayload": "",
        "willMsg": {},
        "userProps": "",
        "sessionExpiry": ""
    },
    {
        "id": "1862e313.45ffad",
        "type": "ui_tab",
        "name": "Mike",
        "icon": "dashboard",
        "order": 2,
        "disabled": false,
        "hidden": false
    }
]

Edit: took me a while to figure out

1 Like

I was going to suggest that you refer to this document with Shelly. They made it pretty universal. This is what I used when setting up my shelly’s. Once I got the syntax down.

MQTT | Shelly Technical Documentation

1 Like

Here following my only flow with a Shelly 1.

[{"id":"ee336003bb403c08","type":"tab","label":"Test","disabled":false,"info":"","env":[]},{"id":"0bf9a836ec5d853e","type":"group","z":"ee336003bb403c08","style":{"stroke":"#999999","stroke-opacity":"1","fill":"none","fill-opacity":"1","label":true,"label-position":"nw","color":"#a4a4a4"},"nodes":["e5fabee7676ada62","78edc7b405414b3f","c7a98e4c2dd5004c"],"x":94,"y":119,"w":432,"h":122},{"id":"8899d7d119c9215f","type":"group","z":"ee336003bb403c08","style":{"stroke":"#999999","stroke-opacity":"1","fill":"none","fill-opacity":"1","label":true,"label-position":"nw","color":"#a4a4a4"},"nodes":["75d74b2fa58ef7c1","0865ee01d5b2bbdb","ba0b97ac23e36547","fb761c4de3689446"],"x":899,"y":99,"w":312,"h":162},{"id":"610c6e1399d1319c","type":"stoptimer2","z":"ee336003bb403c08","duration":"5","durationType":"num","units":"Second","payloadtype":"num","payloadval":"0","name":"5sec","x":810,"y":240,"wires":[["ba0b97ac23e36547"],[]]},{"id":"0dc12ce23368ef6e","type":"change","z":"ee336003bb403c08","name":"START","rules":[{"t":"set","p":"payload","pt":"msg","to":"START","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":240,"wires":[["610c6e1399d1319c"]]},{"id":"e5fabee7676ada62","type":"comment","z":"ee336003bb403c08","g":"0bf9a836ec5d853e","name":"Check motion sensor status","info":"","x":240,"y":160,"wires":[]},{"id":"78edc7b405414b3f","type":"zigbee2mqtt-in","z":"ee336003bb403c08","g":"0bf9a836ec5d853e","name":"MT11-STANZINO","server":"411e2b8e9bdac70b","friendly_name":"MT11-STANZINO (SNZB-03)","device_id":"0x00124b001b78657c","state":"0","outputAtStartup":true,"filterChanges":true,"enableMultiple":false,"x":200,"y":200,"wires":[["c7a98e4c2dd5004c"]]},{"id":"c7a98e4c2dd5004c","type":"function","z":"ee336003bb403c08","g":"0bf9a836ec5d853e","name":"chk BLK & occupancy","func":"const messages = new Array(node.outputCount)\nblocked=global.get(\"BLK_STANZINO\",\"ram\") || false\n\nif (!blocked){\n    if (msg.payload.occupancy){\n        messages[0]=msg\n    }else{\n        messages[1]=msg\n    }\n    return messages;\n}\n","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":400,"y":200,"wires":[["3829f6ac8b415661","0865ee01d5b2bbdb"],["0dc12ce23368ef6e"]]},{"id":"75d74b2fa58ef7c1","type":"shelly-gen1","z":"ee336003bb403c08","g":"8899d7d119c9215f","hostname":"192.168.1.58","description":"Shelly 2.5","mode":"none","server":"561da6b1b53a8fed","outputmode":"status","uploadretryinterval":"0","pollinginterval":"0","pollstatus":false,"getstatusoncommand":true,"devicetype":"Relay","outputs":1,"x":1125,"y":200,"wires":[[]]},{"id":"0865ee01d5b2bbdb","type":"change","z":"ee336003bb403c08","g":"8899d7d119c9215f","name":"On","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"on\":true, \"relay\":0,\"last_seen\":Date.now()}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":975,"y":180,"wires":[["75d74b2fa58ef7c1"]]},{"id":"ba0b97ac23e36547","type":"change","z":"ee336003bb403c08","g":"8899d7d119c9215f","name":"Off","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"on\":false, \"relay\":0,\"last_seen\":Date.now()}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":975,"y":220,"wires":[["75d74b2fa58ef7c1"]]},{"id":"fb761c4de3689446","type":"comment","z":"ee336003bb403c08","g":"8899d7d119c9215f","name":"Send on/off commands","info":"","x":1025,"y":140,"wires":[]},{"id":"3829f6ac8b415661","type":"change","z":"ee336003bb403c08","name":"STOP  ","rules":[{"t":"set","p":"payload","pt":"msg","to":"STOP","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":630,"y":140,"wires":[["610c6e1399d1319c"]]},{"id":"411e2b8e9bdac70b","type":"zigbee2mqtt-server","name":"CORE","host":"10.10.2.1","mqtt_port":"1883","mqtt_username":"","mqtt_password":"","mqtt_qos":"0","tls":"","usetls":false,"base_topic":"zigbee2mqtt"},{"id":"561da6b1b53a8fed","type":"shelly-gen1-server","port":"3865","hostname":""}]

it is a simple motion ligth flow I simplified removing unnecessary sophistications.

The only thing I can say is to be sure to configure correctly the Shelly server getting the correct one (ge 1/gen 2) . In my case it is a Gen 1 server.
As I wanted to keep all my shellys local I could’nt use mqtt.
Do not be biased by the label “Shelly 2.5” (it is a copy/paste typo) , it is a Shelly 1L model.
It requires node-red-contrib-shelly

I hope it can help you

1 Like

Thanks everyone. This will help me a lot. I will poke around again this evening and see where it gets me. Ill post a test flow once I get it working.

You can use Shellies locally if you use MQTT, it is the Cloud that you can’t use if MQTT is enabled.

That Is true. I should try It. But I also would like to substitue them with zigbee devices…

I’m wondering if the gen 2 is different. The Plus 1 allows you to hook up to the cloud and MQTT. IN fact you can hook up to the cloud, bluetooth, wifi and mqtt it seems like to me.

I did It at last. It Is a little bit tricky, expecially for those as me, who do’nt read previously the shelly docs.
As far as I experimented there is not a command to get all device infos (status, last_seen, power, action fired,…) together. You have instead to query for each single value.
The good point Is mqtt can coexist with webhook interface.