This is the next step (and last step) to solve.
You have several options to this.
1. You know it, is to upgrade to the latest stable 2020.2, as this has the option to prevent a MQTT loop.
2. The solution in Node Red.
I tested it with Domoticz v2020.2 build 12117. (currently the latest beta) running on a Raspberry Pi 1B (1st generation)
I decided not to use POWER1 and/or POWER2.
The goal is to prevent, that any message send to Domoticz is returned to the Shelly device.
So, I use the current output 1 on the switch node. (I left all the other outputs on the switch node, for future use, if desired. However you may remove these, if you are sure, that they do not have any function).
In order to make that function work, you have to install 1 additional node, if not done before.
To do so, go to the "Hamburger" menu and select "Manage palette". Go to "Install" and search for: "node-red-contrib-simple-gate".
Install this module.
.
At the end it has become a rather simple flow. I believe much simpler as the flow you posted some posts ago.
Code: Select all
[{"id":"af972d40.75509","type":"mqtt in","z":"56f1881a.2a6b9","name":"Shelly Out - MQTT In","topic":"stat/DZ_SH_A/RESULT","qos":"2","datatype":"auto","broker":"c2d9657a.d81bf8","x":200,"y":200,"wires":[["4936cdd.1c8c034"]]},{"id":"a331717e.bffac","type":"inject","z":"56f1881a.2a6b9","name":"Simulate Shelly Out","topic":"stat/DZ_SH_A/RESULT","payload":"{\"Shutter1\":{\"Position\":32,\"Direction\":0,\"Target\":64}}","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":190,"y":160,"wires":[["4936cdd.1c8c034"]]},{"id":"efd8ce75.fcd368","type":"function","z":"56f1881a.2a6b9","name":"Prepare To Domoticz","func":"msg.payload = {\"command\":\"switchlight\",\"idx\":18,\"switchcmd\":\"Set Level\",\"level\":msg.payload.Shutter1.Position}\nreturn msg;","outputs":1,"noerr":0,"x":840,"y":140,"wires":[["79ded80.70563a8","cb5324b1.83c65"]]},{"id":"79ded80.70563a8","type":"debug","z":"56f1881a.2a6b9","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1070,"y":100,"wires":[]},{"id":"cb5324b1.83c65","type":"mqtt out","z":"56f1881a.2a6b9","name":"Domoticz In","topic":"domoticz/in","qos":"","retain":"","broker":"c2d9657a.d81bf8","x":1070,"y":140,"wires":[]},{"id":"4936cdd.1c8c034","type":"switch","z":"56f1881a.2a6b9","name":"Split Messages","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"Shutter1","vt":"str"},{"t":"cont","v":"ShutterPosition1","vt":"str"},{"t":"cont","v":"POWER1","vt":"str"},{"t":"cont","v":"POWER2","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":5,"x":440,"y":140,"wires":[["11a8b3a6.bd921c","797d5ce8.065f5c","f4a907f1.37231"],["27477d7b.6dd8da"],["71ebf67c.496d68"],["3371904c.cebc6"],[]]},{"id":"91a92a37.bb5a18","type":"inject","z":"56f1881a.2a6b9","name":"Power 2 ON","topic":"stat/DZ_SH_A/RESULT","payload":"{\"POWER2\":\"ON\"}","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":80,"wires":[["4936cdd.1c8c034"]]},{"id":"deb751b8.b95878","type":"inject","z":"56f1881a.2a6b9","name":"POWER 2 OFF","topic":"stat/DZ_SH_A/RESULT","payload":"{\"POWER2\":\"OFF\"}","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":180,"y":120,"wires":[["4936cdd.1c8c034"]]},{"id":"3371904c.cebc6","type":"debug","z":"56f1881a.2a6b9","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":650,"y":259,"wires":[]},{"id":"11a8b3a6.bd921c","type":"debug","z":"56f1881a.2a6b9","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":650,"y":100,"wires":[]},{"id":"797d5ce8.065f5c","type":"json","z":"56f1881a.2a6b9","name":"","property":"payload","action":"","pretty":false,"x":630,"y":140,"wires":[["efd8ce75.fcd368","754432cb.b67bb4"]]},{"id":"754432cb.b67bb4","type":"debug","z":"56f1881a.2a6b9","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":850,"y":100,"wires":[]},{"id":"71ebf67c.496d68","type":"debug","z":"56f1881a.2a6b9","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":650,"y":219,"wires":[]},{"id":"27477d7b.6dd8da","type":"debug","z":"56f1881a.2a6b9","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":650,"y":180,"wires":[]},{"id":"4ed64dc1.307d1c","type":"mqtt in","z":"56f1881a.2a6b9","name":"Domoticz Out","topic":"domoticz/out","qos":"2","datatype":"json","broker":"c2d9657a.d81bf8","x":170,"y":400,"wires":[["bbe6f991.08fa2"]]},{"id":"bbe6f991.08fa2","type":"switch","z":"56f1881a.2a6b9","name":"Filter Shutter Switch","property":"payload.idx","propertyType":"msg","rules":[{"t":"eq","v":"18","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":400,"y":400,"wires":[["593177dc.96a45"]]},{"id":"e80893e.7b469f","type":"debug","z":"56f1881a.2a6b9","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":870,"y":460,"wires":[]},{"id":"593177dc.96a45","type":"function","z":"56f1881a.2a6b9","name":"Prepare Shelly","func":"msg.topic = \"cmnd/\" + msg.payload.name + \"/shutterPosition\";\nmsg.payload = msg.payload.svalue1;\nreturn msg;","outputs":1,"noerr":0,"x":660,"y":400,"wires":[["e80893e.7b469f","1304705f.9e7fa"]]},{"id":"eae40a75.f4b5d8","type":"mqtt out","z":"56f1881a.2a6b9","name":"Shelly In","topic":"","qos":"","retain":"","broker":"c2d9657a.d81bf8","x":1020,"y":400,"wires":[]},{"id":"1304705f.9e7fa","type":"gate","z":"56f1881a.2a6b9","name":"Gate","controlTopic":"control","defaultState":"open","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","persist":false,"x":850,"y":400,"wires":[["eae40a75.f4b5d8","2e506cd9.087e74"]]},{"id":"a03c44f.d5a0cb8","type":"trigger","z":"56f1881a.2a6b9","op1":"","op2":"open","op1type":"pay","op2type":"str","duration":"200","extend":true,"units":"ms","reset":"","bytopic":"all","name":"","x":860,"y":320,"wires":[["1304705f.9e7fa","fdcae9a7.3406d8"]]},{"id":"fdcae9a7.3406d8","type":"debug","z":"56f1881a.2a6b9","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1050,"y":320,"wires":[]},{"id":"f4a907f1.37231","type":"change","z":"56f1881a.2a6b9","name":"Set Control","rules":[{"t":"set","p":"topic","pt":"msg","to":"control","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"close","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":650,"y":320,"wires":[["a03c44f.d5a0cb8"]]},{"id":"2e506cd9.087e74","type":"debug","z":"56f1881a.2a6b9","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1090,"y":460,"wires":[]},{"id":"c2d9657a.d81bf8","type":"mqtt-broker","z":"","name":"","broker":"127.0.0.1","port":"1883","clientid":"","usetls":false,"verifyservercert":true,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
As said, I tested it on a Raspberry Pi 1B. In this case I needed a delay of 200 ms. If you have faster hardware, you may want to decrease this value to e.g. 100 ms. 100 ms. on my RPi1B was not enough and the message was returned.
So I suggest, test it and I await your response.