Code: Select all
[{"id":"72059e25.d0bc8","type":"tab","label":"Powerplug Monitor","disabled":false,"info":""},{"id":"40e9230e.47f2bc","type":"tuya-local","z":"72059e25.d0bc8","devName":"socket1","devIp":"192.168.0.13","devId":"70116356840d8e5c","devKey":"d89c9a46c82c","protocolVer":"3.3","renameSchema":"","filterCB":"","x":540,"y":380,"wires":[["c2f44da8.5bff1","c1117431.dc1ee8","17a73342.cca49d"]]},{"id":"65260fd2.0df5b","type":"mqtt out","z":"72059e25.d0bc8","name":"","topic":"domoticz/in","qos":"2","retain":"","broker":"45e510fc.ec136","x":1330,"y":380,"wires":[]},{"id":"8cd37074.96bd5","type":"template","z":"72059e25.d0bc8","name":"Switch on","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\"command\": \"switchlight\", \"idx\": 272, \"switchcmd\": \"On\" }","output":"str","x":1140,"y":300,"wires":[["65260fd2.0df5b"]]},{"id":"bb387b2c.3fa1b8","type":"template","z":"72059e25.d0bc8","name":"Switch Off","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\"command\": \"switchlight\", \"idx\": 272, \"switchcmd\": \"Off\" }","output":"str","x":1130,"y":460,"wires":[["65260fd2.0df5b"]]},{"id":"37ddec6.91e9314","type":"mqtt in","z":"72059e25.d0bc8","name":"","topic":"domoticz/out","qos":"2","datatype":"auto","broker":"45e510fc.ec136","x":90,"y":380,"wires":[["2564e2dc.ae170e","3f31cc83.02a464"]]},{"id":"2564e2dc.ae170e","type":"switch","z":"72059e25.d0bc8","name":"IDX","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"\"idx\" : 272,","vt":"str"}],"checkall":"true","repair":true,"outputs":1,"x":250,"y":300,"wires":[["33fa47de.f8f908"]]},{"id":"ed5e5819.23c408","type":"change","z":"72059e25.d0bc8","name":"On","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":300,"wires":[["40e9230e.47f2bc"]]},{"id":"3f31cc83.02a464","type":"switch","z":"72059e25.d0bc8","name":"IDX","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"\"idx\" : 272,","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":250,"y":460,"wires":[["f3b3f4a1.206778"]]},{"id":"65e72386.bddc1c","type":"change","z":"72059e25.d0bc8","name":"Off","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":460,"wires":[["40e9230e.47f2bc"]]},{"id":"17a73342.cca49d","type":"switch","z":"72059e25.d0bc8","name":"false","property":"payload.dps[\"1\"]","propertyType":"msg","rules":[{"t":"cont","v":"false","vt":"str"}],"checkall":"true","repair":true,"outputs":1,"x":690,"y":380,"wires":[["f9573301.de463"]]},{"id":"33fa47de.f8f908","type":"switch","z":"72059e25.d0bc8","name":"state","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"\"nvalue\" : 1,","vt":"str"}],"checkall":"true","repair":true,"outputs":1,"x":370,"y":300,"wires":[["ed5e5819.23c408"]]},{"id":"f3b3f4a1.206778","type":"switch","z":"72059e25.d0bc8","name":"state","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"\"nvalue\" : 0,","vt":"str"}],"checkall":"true","repair":true,"outputs":1,"x":370,"y":460,"wires":[["65e72386.bddc1c"]]},{"id":"56a59c77.4a3e94","type":"http request","z":"72059e25.d0bc8","name":"","method":"GET","ret":"txt","paytoqs":false,"url":"http://192.168.0.101:8080/json.htm?type=devices&rid=272","tls":"","proxy":"","authType":"","x":830,"y":300,"wires":[["742a43b9.a5cf0c"]]},{"id":"742a43b9.a5cf0c","type":"switch","z":"72059e25.d0bc8","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"\"Status\" : \"Off\",","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":970,"y":300,"wires":[["8cd37074.96bd5"]]},{"id":"c1117431.dc1ee8","type":"switch","z":"72059e25.d0bc8","name":"true","property":"payload.dps[\"1\"]","propertyType":"msg","rules":[{"t":"cont","v":"true","vt":"str"}],"checkall":"true","repair":true,"outputs":1,"x":690,"y":300,"wires":[["56a59c77.4a3e94"]]},{"id":"f9573301.de463","type":"http request","z":"72059e25.d0bc8","name":"","method":"GET","ret":"txt","paytoqs":false,"url":"http://192.168.0.101:8080/json.htm?type=devices&rid=272","tls":"","proxy":"","authType":"","x":830,"y":380,"wires":[["587097d0.84f748"]]},{"id":"587097d0.84f748","type":"switch","z":"72059e25.d0bc8","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"\"Status\" : \"On\",","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":970,"y":380,"wires":[["bb387b2c.3fa1b8"]]},{"id":"c2f44da8.5bff1","type":"switch","z":"72059e25.d0bc8","name":"If offline switch off","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"undefined","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":730,"y":460,"wires":[["bb387b2c.3fa1b8"]]},{"id":"deca8f10.6b47","type":"comment","z":"72059e25.d0bc8","name":"If plug =On and switch =Off","info":"","x":828,"y":268,"wires":[]},{"id":"98791087.6a4a7","type":"comment","z":"72059e25.d0bc8","name":"If plug =Off and switch =On","info":"","x":830,"y":412,"wires":[]},{"id":"9bdccb66.88a618","type":"comment","z":"72059e25.d0bc8","name":"EDIT IDX SWITCH","info":"Edit the value to the IDX of the vitual dummy switch","x":290,"y":428,"wires":[]},{"id":"e4ec1f53.602ea","type":"comment","z":"72059e25.d0bc8","name":"EDIT IDX SWITCH","info":"Edit the value to the IDX of the vitual dummy switch","x":850,"y":326,"wires":[]},{"id":"f1951bec.707e48","type":"comment","z":"72059e25.d0bc8","name":"Search state switch and turn Off Plug","info":"","x":390,"y":491,"wires":[]},{"id":"14ce4ac6.bcbda5","type":"comment","z":"72059e25.d0bc8","name":"EDIT IDX SWITCH","info":"Edit the value to the IDX of the vitual dummy switch","x":290,"y":331,"wires":[]},{"id":"a8f6899a.73f3d8","type":"comment","z":"72059e25.d0bc8","name":"EDIT IDX SWITCH","info":"Edit the value to the IDX of the vitual dummy switch","x":850,"y":354,"wires":[]},{"id":"195c6fa4.207bc","type":"comment","z":"72059e25.d0bc8","name":"Search state switch and turn On Plug","info":"","x":392.6666564941406,"y":268.6666564941406,"wires":[]},{"id":"27d701e7.d6333e","type":"comment","z":"72059e25.d0bc8","name":"EDIT IDX SWITCH","info":"Edit the value to the IDX of the vitual dummy switch","x":1170,"y":270,"wires":[]},{"id":"f387f745.07cc48","type":"comment","z":"72059e25.d0bc8","name":"EDIT IDX SWITCH","info":"Edit the value to the IDX of the vitual dummy switch","x":1152,"y":491,"wires":[]},{"id":"b09785c8.055198","type":"inject","z":"72059e25.d0bc8","name":"connect","topic":"connect","payload":"connect","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":330,"y":365,"wires":[["40e9230e.47f2bc"]]},{"id":"c5aea957.053908","type":"inject","z":"72059e25.d0bc8","name":"disconnect","topic":"disconnect","payload":"disconnect","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":320,"y":394,"wires":[["40e9230e.47f2bc"]]},{"id":"45e510fc.ec136","type":"mqtt-broker","z":"","name":"","broker":"","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
Hopefully somebody can use it, feel free to ask questions or improve the code.