Shelly integration Nodered

I've been controlling mine for a couple of years though Node-Red using MQTT. Very reliable. I use Mosquito as the MQTT broker.

Hi, I am managing about 30 shellies with node-red. For switching and actions I am unsing http requests. Only for reporting of for example power data I use MQTT.

Here a simple mqqt monitor flow that I am using:

[{"id":"8229b935.7206f8","type":"tab","label":"MQTT Monitor","disabled":false,"info":""},{"id":"7beb40c6.3de98","type":"mqtt in","z":"8229b935.7206f8","name":"","topic":"#","qos":"0","datatype":"auto","broker":"f5f6599b.7711a8","x":90,"y":300,"wires":[["8196fe1e.f726f"]]},{"id":"ff1d0abe.727f98","type":"ui_template","z":"8229b935.7206f8","group":"b3c4dc44.72872","name":"","order":1,"width":20,"height":15,"format":"<div style=\"margin: 0 0 0 -40px;\">\n  <ul>\n    <li ng-repeat=\"name in msg.payload track by $index\"\n        style=\"list-style-type: none;\"\n        >\n        {{name}}\n    </li>\n  </ul>\n</div>\n","storeOutMessages":true,"fwdInMessages":false,"templateScope":"local","x":1460,"y":280,"wires":[[]]},{"id":"c9b7429a.b8de","type":"function","z":"8229b935.7206f8","name":"","func":"msg.topic = flow.get('time') + \" --> \" + msg.topic;\nvar msg_arr = flow.get('msgarr');\nvar new_msg = \"\";\nif (msg_arr.length < 25){\n    msg.payload = msg.topic + '\\xa0\\xa0\\xa0' + \":\" + '\\xa0\\xa0\\xa0' + msg.payload;\n    msg_arr.push(msg.payload);\n    msg.payload = msg_arr;\n    flow.set('msgarr', msg_arr);\n}\nelse{\n    msg_arr.shift();\n    msg.payload = msg.topic + '\\xa0\\xa0\\xa0' + \":\" + '\\xa0\\xa0\\xa0' + msg.payload;    \n    msg_arr.push(msg.payload);\n    msg.payload = msg_arr;\n    flow.set('msgarr', msg_arr);\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"// Code added here will be run once\n// whenever the node is deployed.\nvar a = [];\nflow.set('msgarr',a);","finalize":"","x":1320,"y":280,"wires":[["ff1d0abe.727f98"]]},{"id":"c160ee74.cefc4","type":"moment","z":"8229b935.7206f8","name":"MM:DD:YYYY HH:mm:ss:SSS","topic":"","input":"xyz","inputType":"flow","inTz":"Europe/Berlin","adjAmount":0,"adjType":"days","adjDir":"add","format":"DD:MM:YYYY HH:mm:ss:SSS","locale":"de_DE","output":"time","outputType":"flow","outTz":"Europe/Berlin","x":1110,"y":280,"wires":[["c9b7429a.b8de"]]},{"id":"94129b49.74f688","type":"switch","z":"8229b935.7206f8","name":"home","property":"topic","propertyType":"msg","rules":[{"t":"cont","v":"home","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":810,"y":220,"wires":[["c160ee74.cefc4"]]},{"id":"c6976ac4.389878","type":"switch","z":"8229b935.7206f8","name":"shellies","property":"topic","propertyType":"msg","rules":[{"t":"cont","v":"shellies","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":800,"y":260,"wires":[["c160ee74.cefc4"]]},{"id":"693d8a9.256cc74","type":"switch","z":"8229b935.7206f8","name":"Raspi","property":"topic","propertyType":"msg","rules":[{"t":"cont","v":"Raspi","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":810,"y":340,"wires":[["c160ee74.cefc4"]]},{"id":"afa7a4df.9745b8","type":"switch","z":"8229b935.7206f8","name":"shellies/announce","property":"topic","propertyType":"msg","rules":[{"t":"cont","v":"shellies/announce","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":770,"y":300,"wires":[["c160ee74.cefc4"]]},{"id":"2602db1f.47e4d4","type":"function","z":"8229b935.7206f8","name":"","func":"if (flow.get('mqtt_type') === 0) {\n return msg;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","x":580,"y":180,"wires":[["b3136bc4.dd7a48"]]},{"id":"444fa39c.90e15c","type":"function","z":"8229b935.7206f8","name":"","func":"if (flow.get('mqtt_type') === 1) {\n return msg;\n}","outputs":1,"noerr":0,"x":580,"y":220,"wires":[["94129b49.74f688"]]},{"id":"6f87fa1c.25df54","type":"function","z":"8229b935.7206f8","name":"","func":"if (flow.get('mqtt_type') === 2) {\n return msg;\n}","outputs":1,"noerr":0,"x":580,"y":260,"wires":[["c6976ac4.389878"]]},{"id":"d17cc7f5.979a48","type":"function","z":"8229b935.7206f8","name":"","func":"if (flow.get('mqtt_type') === 3) {\n return msg;\n}","outputs":1,"noerr":0,"x":580,"y":300,"wires":[["afa7a4df.9745b8"]]},{"id":"4cc7da4d.753b14","type":"function","z":"8229b935.7206f8","name":"","func":"if (flow.get('mqtt_type') === 4) {\n return msg;\n}","outputs":1,"noerr":0,"x":580,"y":340,"wires":[["693d8a9.256cc74"]]},{"id":"b3136bc4.dd7a48","type":"function","z":"8229b935.7206f8","name":"NoOp","func":"return msg;","outputs":1,"noerr":0,"x":810,"y":180,"wires":[["c160ee74.cefc4"]]},{"id":"69f1b72c.e10108","type":"inject","z":"8229b935.7206f8","name":"alle","repeat":"","crontab":"","once":true,"onceDelay":"1","topic":"","payload":"0","payloadType":"num","x":190,"y":100,"wires":[["ca395821.ed99e8"]]},{"id":"ca395821.ed99e8","type":"change","z":"8229b935.7206f8","name":"","rules":[{"t":"set","p":"mqtt_type","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":100,"wires":[[]]},{"id":"49bff3d5.a4da1c","type":"ui_button","z":"8229b935.7206f8","name":"","group":"3d5f625.a1c4b9e","order":3,"width":2,"height":1,"passthru":false,"label":"Alle","tooltip":"","color":"","bgcolor":"","icon":"","payload":"0","payloadType":"num","topic":"","x":270,"y":660,"wires":[["65ccf042.91427"]]},{"id":"7258f9e4.49ce88","type":"ui_button","z":"8229b935.7206f8","name":"","group":"3d5f625.a1c4b9e","order":5,"width":2,"height":1,"passthru":false,"label":"home","tooltip":"","color":"","bgcolor":"","icon":"","payload":"1","payloadType":"num","topic":"","x":270,"y":700,"wires":[["65ccf042.91427"]]},{"id":"24082040.ba67a","type":"ui_button","z":"8229b935.7206f8","name":"","group":"3d5f625.a1c4b9e","order":6,"width":2,"height":1,"passthru":false,"label":"shellies","tooltip":"","color":"","bgcolor":"","icon":"","payload":"2","payloadType":"num","topic":"","x":260,"y":740,"wires":[["65ccf042.91427"]]},{"id":"98312d9d.2b8d9","type":"ui_button","z":"8229b935.7206f8","name":"","group":"3d5f625.a1c4b9e","order":7,"width":3,"height":1,"passthru":false,"label":"announce","tooltip":"","color":"","bgcolor":"","icon":"","payload":"3","payloadType":"num","topic":"","x":260,"y":780,"wires":[["65ccf042.91427"]]},{"id":"dd0678c2.a15038","type":"ui_button","z":"8229b935.7206f8","name":"","group":"3d5f625.a1c4b9e","order":8,"width":2,"height":1,"passthru":false,"label":"Raspi","tooltip":"","color":"","bgcolor":"","icon":"","payload":"4","payloadType":"num","topic":"","x":270,"y":820,"wires":[["65ccf042.91427"]]},{"id":"65ccf042.91427","type":"change","z":"8229b935.7206f8","name":"","rules":[{"t":"set","p":"mqtt_type","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":820,"wires":[[]]},{"id":"b9e767b5.498a48","type":"link out","z":"8229b935.7206f8","name":"","links":["f5407a1a.5c7708"],"x":595,"y":1100,"wires":[]},{"id":"2630eaa.a836e16","type":"function","z":"8229b935.7206f8","name":"","func":"msg.payload = \"Fehlerzeitpunkt: \" + msg.payload + \" / \" +\n              \"Flow: Monitor MQTT Monitor\" + \" / \" +\n              \"Fehlermeldung: \" + msg.error.message + \" / \" +\n              \"Fehler ID: \"+ msg.error.source.id + \" / \" +\n              \"Fehlertyp: \" + msg.error.source.type + \" / \" +\n              \"Fehlernode: \" + msg.error.source.name + \" / \" + \n              \"Fehlerzähler: \" + msg.error.source.count;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":480,"y":1080,"wires":[["c59f6c5c.7763e","b9e767b5.498a48"]]},{"id":"e9e296a4.e36258","type":"moment","z":"8229b935.7206f8","name":"HH:mm:ss DD:MM:YYYY","topic":"","input":"xyz","inputType":"flow","inTz":"Europe/Berlin","adjAmount":0,"adjType":"days","adjDir":"add","format":"HH:mm:ss DD:MM:YYYY","locale":"de_DE","output":"","outputType":"msg","outTz":"Europe/Berlin","x":290,"y":1080,"wires":[["2630eaa.a836e16"]]},{"id":"c59f6c5c.7763e","type":"file","z":"8229b935.7206f8","name":"Monitor error log","filename":"/home/pi/logs/Monitor-error.txt","appendNewline":true,"createDir":true,"overwriteFile":"false","x":660,"y":1060,"wires":[[]]},{"id":"96ab5f76.16bba","type":"catch","z":"8229b935.7206f8","name":"All errors","scope":null,"uncaught":false,"x":100,"y":1080,"wires":[["e9e296a4.e36258"]]},{"id":"4e9eb0ed.fb7cd","type":"ui_button","z":"8229b935.7206f8","name":"","group":"3d5f625.a1c4b9e","order":4,"width":2,"height":1,"passthru":false,"label":"unipi","tooltip":"","color":"","bgcolor":"","icon":"","payload":"5","payloadType":"num","topic":"","x":270,"y":860,"wires":[["65ccf042.91427"]]},{"id":"ea0438d1.72c598","type":"switch","z":"8229b935.7206f8","name":"unipi","property":"topic","propertyType":"msg","rules":[{"t":"cont","v":"home/ug/Buero/unipi/","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":810,"y":380,"wires":[["c160ee74.cefc4","a60d7718.165d28"]]},{"id":"45e1584a.e036b8","type":"function","z":"8229b935.7206f8","name":"","func":"if (flow.get('mqtt_type') === 5) {\n return msg;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","x":580,"y":380,"wires":[["ea0438d1.72c598"]]},{"id":"761c9043.cfe5e","type":"delay","z":"8229b935.7206f8","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1300,"y":380,"wires":[["c160ee74.cefc4"]]},{"id":"a60d7718.165d28","type":"switch","z":"8229b935.7206f8","name":"","property":"topic","propertyType":"msg","rules":[{"t":"cont","v":"281893C00700005E","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":970,"y":380,"wires":[["cbb15bd3.9264d8"]]},{"id":"cbb15bd3.9264d8","type":"change","z":"8229b935.7206f8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"------","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"--------------------------------------------------------","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1120,"y":380,"wires":[["761c9043.cfe5e"]]},{"id":"a8e1344.3a30fc8","type":"ui_text_input","z":"8229b935.7206f8","name":"","label":"Enter topic:","tooltip":"","group":"3d5f625.a1c4b9e","order":1,"width":0,"height":0,"passthru":true,"mode":"text","delay":300,"topic":"","x":250,"y":620,"wires":[["927b91c7.1556"]]},{"id":"7ba652c3.f858ec","type":"ui_button","z":"8229b935.7206f8","name":"","group":"3d5f625.a1c4b9e","order":9,"width":2,"height":1,"passthru":false,"label":"special","tooltip":"","color":"","bgcolor":"","icon":"","payload":"6","payloadType":"num","topic":"","x":270,"y":900,"wires":[["65ccf042.91427"]]},{"id":"927b91c7.1556","type":"change","z":"8229b935.7206f8","name":"","rules":[{"t":"set","p":"special","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":620,"wires":[[]]},{"id":"8fbd0665.dbe978","type":"function","z":"8229b935.7206f8","name":"","func":"if (flow.get('mqtt_type') === 6) {\n return msg;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","x":580,"y":420,"wires":[["5b294ae5.f9c144"]]},{"id":"5b294ae5.f9c144","type":"function","z":"8229b935.7206f8","name":"","func":"let x = flow.get('special');\nx = `${x}`;\nif (msg.topic.includes(x)){\n    return msg;\n} \n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":800,"y":420,"wires":[["c160ee74.cefc4"]]},{"id":"3eb69fc6.bc68b","type":"ui_button","z":"8229b935.7206f8","name":"","group":"3d5f625.a1c4b9e","order":9,"width":2,"height":1,"passthru":false,"label":"off","tooltip":"","color":"","bgcolor":"","icon":"","payload":"7","payloadType":"num","topic":"","topicType":"str","x":270,"y":940,"wires":[["65ccf042.91427"]]},{"id":"8196fe1e.f726f","type":"switch","z":"8229b935.7206f8","name":"","property":"mqtt_type","propertyType":"flow","rules":[{"t":"neq","v":"7","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":210,"y":300,"wires":[["2602db1f.47e4d4","444fa39c.90e15c","6f87fa1c.25df54","d17cc7f5.979a48","4cc7da4d.753b14","45e1584a.e036b8","8fbd0665.dbe978"]]},{"id":"f5f6599b.7711a8","type":"mqtt-broker","broker":"10.0.0.43","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"b3c4dc44.72872","type":"ui_group","name":"Group 1","tab":"800f5253.4ba94","order":2,"disp":false,"width":"20","collapse":false},{"id":"3d5f625.a1c4b9e","type":"ui_group","name":"Group 2","tab":"800f5253.4ba94","order":1,"disp":false,"width":"20","collapse":false},{"id":"800f5253.4ba94","type":"ui_tab","name":"MQTT","icon":"dashboard","order":14,"disabled":false,"hidden":false}]
1 Like

This is a flow for shelly actions if you don't do it directly from shelly to shelly:

[{"id":"f3ce99b7.610008","type":"http in","z":"fc4662e7.a795c","name":"output","url":"/output","method":"get","upload":true,"swaggerDoc":"","x":110,"y":320,"wires":[["27e96a80.9a6886"]]},{"id":"14271ccb.da1c23","type":"http response","z":"fc4662e7.a795c","name":"","statusCode":"200","headers":{},"x":400,"y":360,"wires":[]},{"id":"4f82628a.bbe19c","type":"html","z":"fc4662e7.a795c","name":"","property":"payload","outproperty":"payload","tag":"body","ret":"html","as":"single","x":390,"y":320,"wires":[["5aa114d2.b81e8c","5530e1c5.ec0df"]]},{"id":"27e96a80.9a6886","type":"template","z":"fc4662e7.a795c","name":"html page","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<html>\n    <head></head>\n    <body>\n        {{req.query.s}}\n    </body>\n</html>","x":240,"y":320,"wires":[["4f82628a.bbe19c","14271ccb.da1c23"]]},{"id":"f130819f.cf62a","type":"function","z":"fc4662e7.a795c","name":"shelly25","func":"let input = msg.payload[0].split(\":\");\nlet c = input[1];\nlet t = Date.now();\nreturn {payload : {\"command\":c,\"timestamp\":t}};","outputs":1,"noerr":0,"initialize":"","finalize":"","x":820,"y":240,"wires":[["15675040.b68ea","234f8ac7.a54146"]]},{"id":"15675040.b68ea","type":"debug","z":"fc4662e7.a795c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":970,"y":200,"wires":[]},{"id":"5aa114d2.b81e8c","type":"switch","z":"fc4662e7.a795c","name":"shelly actions","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"Hannes:Untiedt","vt":"str"},{"t":"cont","v":"shelly25_UGTR:","vt":"str"},{"t":"cont","v":"shellybutton_DGWZ:","vt":"str"},{"t":"cont","v":"shellymotion_1:","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":560,"y":320,"wires":[["58a7f529.62d15c"],["f130819f.cf62a"],["f20e0655.1a04b8"],["34052e84.783962"]]},{"id":"f20e0655.1a04b8","type":"function","z":"fc4662e7.a795c","name":"button","func":"let input = msg.payload[0].split(\":\");\nlet c = input[1];\nlet t = Date.now();\nreturn {payload : {\"command\":c,\"timestamp\":t}};","outputs":1,"noerr":0,"initialize":"","finalize":"","x":810,"y":300,"wires":[["751c1244.a0780c"]]},{"id":"751c1244.a0780c","type":"switch","z":"fc4662e7.a795c","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"single","vt":"str"},{"t":"eq","v":"double","vt":"str"},{"t":"eq","v":"triple","vt":"str"},{"t":"eq","v":"long","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":950,"y":300,"wires":[["aeec29c4.f8a598"],["aeec29c4.f8a598"],["aeec29c4.f8a598"],["aeec29c4.f8a598"]]},{"id":"aeec29c4.f8a598","type":"debug","z":"fc4662e7.a795c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1150,"y":300,"wires":[]},{"id":"5530e1c5.ec0df","type":"debug","z":"fc4662e7.a795c","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":510,"y":240,"wires":[]},{"id":"8ab923db.068f","type":"debug","z":"fc4662e7.a795c","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1230,"y":780,"wires":[]},{"id":"34052e84.783962","type":"function","z":"fc4662e7.a795c","name":"motion_1","func":"let input = msg.payload[0].split(\":\");\nlet c = input[1];\nlet t = Date.now();\nreturn {payload : {\"command\":c,\"timestamp\":t}};","outputs":1,"noerr":0,"initialize":"","finalize":"","x":820,"y":440,"wires":[["e920d7df.2e9008","6124b0e8.f40d2","90ba0b91.3346d8"]]},{"id":"e920d7df.2e9008","type":"switch","z":"fc4662e7.a795c","name":"","property":"payload.command","propertyType":"msg","rules":[{"t":"eq","v":"motion","vt":"str"},{"t":"eq","v":"motion-bright","vt":"str"},{"t":"eq","v":"motion-twilight","vt":"str"},{"t":"eq","v":"motion-dark","vt":"str"},{"t":"eq","v":"motion-end","vt":"str"},{"t":"eq","v":"tamper","vt":"str"},{"t":"eq","v":"tamper-end","vt":"str"}],"checkall":"true","repair":false,"outputs":7,"x":970,"y":440,"wires":[["8ab923db.068f","367d9767.c1aa88"],["8ab923db.068f","755bba14.99fd14"],["8ab923db.068f","31784db.cba82b2"],["8ab923db.068f","e07eeec6.ac0ca"],["8ab923db.068f","d84b670a.344448"],["8ab923db.068f","8b5fe052.e8937"],["8ab923db.068f","6662f02f.694c6"]]},{"id":"b707d5e2.22e368","type":"inject","z":"fc4662e7.a795c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":140,"y":680,"wires":[["b3d11b3.99db4e8"]]},{"id":"b3d11b3.99db4e8","type":"http request","z":"fc4662e7.a795c","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"http://10.0.0.131/status","tls":"","persist":false,"proxy":"","authType":"","x":370,"y":680,"wires":[["c487bc32.ed9b5"]]},{"id":"d6e3d2d5.dbad6","type":"debug","z":"fc4662e7.a795c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":790,"y":680,"wires":[]},{"id":"c487bc32.ed9b5","type":"json","z":"fc4662e7.a795c","name":"","property":"payload","action":"","pretty":false,"x":510,"y":680,"wires":[["69cf5b7a.b8e6a4","53dbad25.a48ea4","4fc7dfca.ed975"]]},{"id":"69cf5b7a.b8e6a4","type":"function","z":"fc4662e7.a795c","name":"lux","func":"msg.topic = \"lux\";\nmsg.payload = msg.payload.lux.value;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":650,"y":680,"wires":[["d6e3d2d5.dbad6"]]},{"id":"53dbad25.a48ea4","type":"debug","z":"fc4662e7.a795c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":670,"y":640,"wires":[]},{"id":"4fc7dfca.ed975","type":"function","z":"fc4662e7.a795c","name":"bat","func":"msg.topic = \"bat\";\nmsg.payload = msg.payload.bat.value + \"%\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":650,"y":720,"wires":[["93e760cd.d005a"]]},{"id":"93e760cd.d005a","type":"debug","z":"fc4662e7.a795c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":790,"y":720,"wires":[]},{"id":"a90d1c40.ec99e","type":"comment","z":"fc4662e7.a795c","name":"http://10.0.0.47:1880/output?s=shellymotion_1:motion","info":"request/action = http://10.0.0.47:1880/output?s=shellymotion_1:motion\n\nbody = shellymotion_1:motion","x":380,"y":120,"wires":[]},{"id":"58a7f529.62d15c","type":"function","z":"fc4662e7.a795c","name":"HU","func":"let input = msg.payload[0].split(\":\");\nlet c = input[1];\nlet t = Date.now();\nreturn {payload : {\"command\":c,\"timestamp\":t}};","outputs":1,"noerr":0,"initialize":"","finalize":"","x":810,"y":180,"wires":[["1f9515ba.415fea"]]},{"id":"1f9515ba.415fea","type":"debug","z":"fc4662e7.a795c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":970,"y":120,"wires":[]},{"id":"c94b5204.b0da7","type":"function","z":"fc4662e7.a795c","name":"","func":"let path = \"/home/pi/synology/Raspi/\" + msg.was + \"/Logging/\";\nlet file = \"log.txt\";\nlet filename = path + file;\nreturn {payload:msg.payload, filename:filename};","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1360,"y":240,"wires":[["6e9b62e4.30b08c"]]},{"id":"6e9b62e4.30b08c","type":"file","z":"fc4662e7.a795c","name":"status","filename":"","appendNewline":true,"createDir":true,"overwriteFile":"false","encoding":"none","x":1490,"y":240,"wires":[[]]},{"id":"d9ba3b6b.e46ba8","type":"function","z":"fc4662e7.a795c","name":"","func":"let was = \"10-0-0-104-shelly-25-UGTR\";\nlet payload = msg.time + \": \" + msg.command;\nreturn {was:was,payload:payload};","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1220,"y":240,"wires":[["c94b5204.b0da7"]]},{"id":"409a05dc.00453c","type":"comment","z":"fc4662e7.a795c","name":"http://10.0.0.47:1880/output?s=shelly25_UGTR:shelly25_UGTR on","info":"","x":1360,"y":200,"wires":[]},{"id":"234f8ac7.a54146","type":"moment","z":"fc4662e7.a795c","name":"DD-MM-YYYY HH:mm:ss","topic":"","input":"timestamp","inputType":"msg","inTz":"Europe/Berlin","adjAmount":0,"adjType":"days","adjDir":"add","format":"","locale":"DD-MM-YYYY HH:mm:ss","output":"time","outputType":"msg","outTz":"Europe/Berlin","x":1030,"y":240,"wires":[["d9ba3b6b.e46ba8"]]},{"id":"dda5ff55.12edd","type":"ui_audio","z":"fc4662e7.a795c","name":"test motion","group":"5c0b34c.d1538cc","voice":"Google Deutsch","always":false,"x":1450,"y":360,"wires":[]},{"id":"367d9767.c1aa88","type":"change","z":"fc4662e7.a795c","name":"motion","rules":[{"t":"set","p":"payload","pt":"msg","to":"motion festgestellt","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1230,"y":360,"wires":[["dda5ff55.12edd"]]},{"id":"49373827.af60b8","type":"ui_audio","z":"fc4662e7.a795c","name":"test motion bright","group":"5c0b34c.d1538cc","voice":"Google Deutsch","always":false,"x":1470,"y":400,"wires":[]},{"id":"755bba14.99fd14","type":"change","z":"fc4662e7.a795c","name":"motion bright","rules":[{"t":"set","p":"payload","pt":"msg","to":"motion hell festgestellt","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1250,"y":400,"wires":[["49373827.af60b8"]]},{"id":"6b9d198a.c0a4d8","type":"ui_audio","z":"fc4662e7.a795c","name":"test motion twilight","group":"5c0b34c.d1538cc","voice":"Google Deutsch","always":false,"x":1470,"y":440,"wires":[]},{"id":"31784db.cba82b2","type":"change","z":"fc4662e7.a795c","name":"motion twilight","rules":[{"t":"set","p":"payload","pt":"msg","to":"motion Dämmerung festgestellt","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1260,"y":440,"wires":[["6b9d198a.c0a4d8"]]},{"id":"3ae728bf.f20448","type":"ui_audio","z":"fc4662e7.a795c","name":"test motion dark","group":"5c0b34c.d1538cc","voice":"Google Deutsch","always":false,"x":1460,"y":480,"wires":[]},{"id":"e07eeec6.ac0ca","type":"change","z":"fc4662e7.a795c","name":"motion dark","rules":[{"t":"set","p":"payload","pt":"msg","to":"motion dunkel festgestellt","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1250,"y":500,"wires":[["3ae728bf.f20448","9b2d846d.ee3b08"]]},{"id":"4db23b98.aa0274","type":"ui_audio","z":"fc4662e7.a795c","name":"test mtion end","group":"5c0b34c.d1538cc","voice":"Google Deutsch","always":false,"x":1460,"y":560,"wires":[]},{"id":"d84b670a.344448","type":"change","z":"fc4662e7.a795c","name":"motion end","rules":[{"t":"set","p":"payload","pt":"msg","to":"motion ende festgestellt","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1250,"y":580,"wires":[["4db23b98.aa0274","fa24457c.7dd9f8"]]},{"id":"9b2d846d.ee3b08","type":"http request","z":"fc4662e7.a795c","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"http://10.0.0.68/relay/0?turn=on","tls":"","persist":false,"proxy":"","authType":"","x":1450,"y":520,"wires":[[]]},{"id":"fa24457c.7dd9f8","type":"http request","z":"fc4662e7.a795c","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"http://10.0.0.68/relay/0?turn=off","tls":"","persist":false,"proxy":"","authType":"","x":1450,"y":600,"wires":[[]]},{"id":"659ef2e2.19339c","type":"inject","z":"fc4662e7.a795c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1260,"y":540,"wires":[["9b2d846d.ee3b08"]]},{"id":"452d0a1b.144c64","type":"inject","z":"fc4662e7.a795c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1260,"y":620,"wires":[["fa24457c.7dd9f8"]]},{"id":"bf0eb531.0bf168","type":"ui_audio","z":"fc4662e7.a795c","name":"test tamper","group":"5c0b34c.d1538cc","voice":"Google Deutsch","always":false,"x":1450,"y":660,"wires":[]},{"id":"8b5fe052.e8937","type":"change","z":"fc4662e7.a795c","name":"tamper","rules":[{"t":"set","p":"payload","pt":"msg","to":"Erschßtterung festgestellt","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1230,"y":660,"wires":[["bf0eb531.0bf168"]]},{"id":"361d4823.fca0c8","type":"ui_audio","z":"fc4662e7.a795c","name":"test tamper end","group":"5c0b34c.d1538cc","voice":"Google Deutsch","always":false,"x":1460,"y":700,"wires":[]},{"id":"6662f02f.694c6","type":"change","z":"fc4662e7.a795c","name":"tamper end","rules":[{"t":"set","p":"payload","pt":"msg","to":"Erschßtterung Ende festgestellt","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1250,"y":700,"wires":[["361d4823.fca0c8"]]},{"id":"6124b0e8.f40d2","type":"debug","z":"fc4662e7.a795c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":920,"y":540,"wires":[]},{"id":"90ba0b91.3346d8","type":"ui_text","z":"fc4662e7.a795c","group":"5c0b34c.d1538cc","order":7,"width":0,"height":0,"name":"","label":"action commands","format":"{{msg.payload}}","layout":"row-left","x":650,"y":540,"wires":[]},{"id":"5c0b34c.d1538cc","type":"ui_group","name":"motion","tab":"eb6429e1.2d17e8","order":1,"disp":true,"width":"20","collapse":false},{"id":"eb6429e1.2d17e8","type":"ui_tab","name":"Actions","icon":"dashboard","order":12,"disabled":false,"hidden":false}]
1 Like

That means, however, that you have to make Node-RED do 30x polling requests every x seconds.

Using MQTT lets the Shelley's push the data to MQTT - you could even have them on different push schedules. Node-RED need only then listen for an MQTT event.

That's not what I am doing. Only switching (turn on or off or dimmer 50 %) is done by http request. All other information from the shellies comes per mqtt. Node-Red does not poll for information. See picture above. This is all done with mqtt. I use Mosquito as well.

HTTP on off with http request:

[{"id":"b8b20ee5.f9c62","type":"inject","z":"d3bb5a5a.aab1a8","name":"on","props":[{"p":"url","v":"http://IP_of_shelly1pm/relay/0?turn=on","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"str","x":250,"y":1340,"wires":[["51e6e69d.8c39c8"]]},{"id":"d59c9529.0c39a8","type":"inject","z":"d3bb5a5a.aab1a8","name":"off","props":[{"p":"url","v":"http://IP_of_shelly1pm/relay/0?turn=on","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":250,"y":1380,"wires":[["51e6e69d.8c39c8"]]},{"id":"51e6e69d.8c39c8","type":"http request","z":"d3bb5a5a.aab1a8","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":430,"y":1360,"wires":[[]]}]

image

1 Like

yes you can, Look further down.

Hello everybody
I have mosquitto on my rasp. Installed. now I just have to activate mqtt on the Shelly and my rasp. specify as server, and the same in nodered .. but this does not work .. what kind of topics does Shelly work with?

Many Thanks

use this as your topic in node-red: #
you should get all messages from mosquito and than you will find out the one you need.

also have a look MQTT support of shellies

1 Like

@automati Please don't duplicate posts.
Once a person has already replied in the thread, they will normally get an alert when a new post is made, so no need duplicate posts to tag other people.
Your last post has been removed.

You don't have to use "#", see: API Reference

look what I said and klick the link .

Yes, I saw your post. Just wanted to clarify that you don't have to subscribe to all topics with "#" and do some filtering afterwards. Might be less effort to only subscribe to the topics you really want to use :smiley:

Hello everybody
I have mosquitto on my rasp. Installed. now I just have to activate mqtt on the Shelly and my rasp. specify as server, and the same in nodered .. but this does not work .. what kind of topics does Shelly work with?

Many Thanks

A link to the API was posted earlier.

If you install the most excellent tool MQTT Explorer then you should easily be able to see it publishing and on what topics.

1 Like

Don’t forget latest version of mosquito restricts access to local machine only by default. Must update config to allow remote access.

2 Likes

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.