I am using 4.10717.
Updating is not possible, i am not running buster on my pi.
I made a switch in it. That when i receive an "ON" message from shelly tasmota device. The ON message i receive when a input or webbrowser is triggered. That it disables the input for device idx<->shelly.
All incomming domoticz mqtt messages can't reacht the idx<->shelly and therefor don't shoot mqtt messages to shelly tasmota
Code: Select all
[{"id":"638a85e3.ce91cc","type":"tab","label":"shelly generic","disabled":false,"info":""},{"id":"8bb85714.bb4258","type":"json","z":"638a85e3.ce91cc","name":"","property":"payload","action":"","pretty":false,"x":440.25,"y":180,"wires":[["90342cf9.e9727"]]},{"id":"bc5348ac.393518","type":"mqtt in","z":"638a85e3.ce91cc","name":"","topic":"domoticz/out","qos":"2","datatype":"auto","broker":"6211af79.02186","x":130,"y":180,"wires":[["234122dd.2cd7fe"]]},{"id":"9e8b8d53.2286d","type":"mqtt in","z":"638a85e3.ce91cc","name":"shelly/out","topic":"stat/+/RESULT","qos":"2","datatype":"auto","broker":"6211af79.02186","x":120,"y":260,"wires":[["bff402bf.82d3b"]]},{"id":"720304a2.459d1c","type":"function","z":"638a85e3.ce91cc","name":"idx <-> shelly","func":"var idx_shelly_table = [\n //[ domoticz idx, shelly name topic, relay ], // syntax\n [540, \"DZ_SH_A\"], // shelly 2.5\n];\n\nif ( msg.src == 'shelly' ) {\n var matches = msg.topic.match( /stat\\/(.*)\\/RESULT/ );\n \n if ( matches.length == 2 ) {\n var shelly_id = matches[1];\n \n for ( var i = 0; i < idx_shelly_table.length; i++ ) {\n if ( idx_shelly_table[i][1] == shelly_id ) {\n var val = (msg.payload.Position)\n msg = {\n payload:\n {\n \"command\": \"switchlight\", \n \"idx\": idx_shelly_table[i][0], \n \"switchcmd\": \"Set Level\", \n \"level\": val,\n \n }\n }\n \n return [msg, null, null];\n }\n }\n \n // shelly not found in table\n msg.shelly_id = shelly_id;\n msg.relay = shelly_relay;\n return [null, null, msg];\n }\n}\n\nif ( msg.src == 'domoticz' ) {\n for ( var i = 0; i < idx_shelly_table.length; i++ ) {\n if ( idx_shelly_table[i][0] == parseInt(msg.payload.idx) ) {\n var aval = (msg.payload.svalue1);\n if (aval == 0) {\n msg.payload = 100;\n } \n else if (aval == 100) { \n msg.payload = 0;\n }\n else msg.payload = aval;\n //msg.topic = \"cmnd/\" + idx_shelly_table[i][1] + \"/shutterposition/\" + idx_shelly_table[i][2] + \"/command\";\n msg.topic = \"cmnd/\" + idx_shelly_table[i][1] + \"/shutterposition\";\n return [null, msg, null ];\n }\n }\n}\n\n// dismiss\nreturn [null, null, null];","outputs":3,"noerr":0,"x":1169.964111328125,"y":226.67852783203125,"wires":[["55333a53.9885d4"],["b71d3154.ee4","b20758ef.196b48"],[]]},{"id":"90342cf9.e9727","type":"function","z":"638a85e3.ce91cc","name":"add src","func":"msg.src = 'domoticz';\n\nreturn msg;","outputs":1,"noerr":0,"x":577.2142333984375,"y":180,"wires":[["46063ddb.177474"]]},{"id":"55333a53.9885d4","type":"mqtt out","z":"638a85e3.ce91cc","name":"","topic":"domoticz/in","qos":"","retain":"","broker":"6211af79.02186","x":1378.1070556640625,"y":198.8214111328125,"wires":[]},{"id":"b20758ef.196b48","type":"mqtt out","z":"638a85e3.ce91cc","name":"Shelly/in","topic":"","qos":"","retain":"","broker":"6211af79.02186","x":1368.678466796875,"y":247.10711669921875,"wires":[]},{"id":"bff402bf.82d3b","type":"json","z":"638a85e3.ce91cc","name":"","property":"payload","action":"","pretty":false,"x":246.19044494628906,"y":260,"wires":[["d02ec7a4.557f58"]]},{"id":"d02ec7a4.557f58","type":"function","z":"638a85e3.ce91cc","name":"add src","func":"msg.src = 'shelly';\nreturn msg;","outputs":1,"noerr":0,"x":372.857177734375,"y":259.20635986328125,"wires":[["e285f5f0.10d138"]]},{"id":"e285f5f0.10d138","type":"split","z":"638a85e3.ce91cc","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":500.0001525878906,"y":259.8411865234375,"wires":[["6c1a59a9.b7dc18","d0bcf23f.236a6"]]},{"id":"6c1a59a9.b7dc18","type":"switch","z":"638a85e3.ce91cc","name":"","property":"payload.Position","propertyType":"msg","rules":[{"t":"lte","v":"100","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":671.873046875,"y":260.206298828125,"wires":[["6c63207d.043b1"]]},{"id":"6c63207d.043b1","type":"rbe","z":"638a85e3.ce91cc","name":"Anti-Loop-Shelly","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":884,"y":259.75,"wires":[["720304a2.459d1c"]]},{"id":"46063ddb.177474","type":"rbe","z":"638a85e3.ce91cc","name":"Anti-loop-Domoticz","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":751.2500610351562,"y":180,"wires":[["6345c362.fb967c"]]},{"id":"b3c05808.3f08e8","type":"switch","z":"638a85e3.ce91cc","name":"","property":"payload","propertyType":"msg","rules":[{"t":"false"},{"t":"true"}],"checkall":"true","repair":false,"outputs":2,"x":913,"y":306,"wires":[["f614c20f.860ae"],["23f29e47.70d872"]]},{"id":"d80da56e.637dc8","type":"debug","z":"638a85e3.ce91cc","name":"DZ_out_Payload_disabled","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1225,"y":118,"wires":[]},{"id":"23f29e47.70d872","type":"change","z":"638a85e3.ce91cc","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"relayOn","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":1400,"y":385,"wires":[[]]},{"id":"6345c362.fb967c","type":"switch","z":"638a85e3.ce91cc","name":"","property":"relayOn","propertyType":"flow","rules":[{"t":"true"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":915,"y":180,"wires":[["d80da56e.637dc8"],["720304a2.459d1c","32952f63.42b8a"]]},{"id":"f614c20f.860ae","type":"delay","z":"638a85e3.ce91cc","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1128,"y":304,"wires":[["23f29e47.70d872","36147959.ad32d6"]]},{"id":"d0bcf23f.236a6","type":"change","z":"638a85e3.ce91cc","name":"Convert state to boolean","rules":[{"t":"change","p":"payload","pt":"msg","from":"ON","fromt":"str","to":"true","tot":"bool"},{"t":"change","p":"payload","pt":"msg","from":"OFF","fromt":"str","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":733,"y":306,"wires":[["b3c05808.3f08e8"]]},{"id":"b71d3154.ee4","type":"debug","z":"638a85e3.ce91cc","name":"SH_Debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1380,"y":298,"wires":[]},{"id":"32952f63.42b8a","type":"debug","z":"638a85e3.ce91cc","name":"DZ_out_Payload-Enabled","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1214,"y":161,"wires":[]},{"id":"5c51156b.ca8c5c","type":"inject","z":"638a85e3.ce91cc","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":912,"y":394,"wires":[["23f29e47.70d872"]]},{"id":"b3da728e.b1e7b","type":"inject","z":"638a85e3.ce91cc","name":"","topic":"","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":913,"y":355,"wires":[["23f29e47.70d872"]]},{"id":"234122dd.2cd7fe","type":"delay","z":"638a85e3.ce91cc","name":"","pauseType":"delay","timeout":"200","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":296,"y":180,"wires":[["8bb85714.bb4258"]]},{"id":"36147959.ad32d6","type":"debug","z":"638a85e3.ce91cc","name":"State","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1360,"y":342,"wires":[]},{"id":"6211af79.02186","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":""}]
Only thing i don't get. If i click on "close" for the device. It send value 100
If i then again click on "close" for the same device. Then is send value 0
Looks more as a toggle function. But because i am at an old version, it could be that the new stable works different.