(Change 192 to the appropriate IDX in your system and change the ip address in case it runs on another server)
Then in Nodered you can perform that JSON call and test the result in a formula block.
Example get the Data field which will be either "On" or "Off"... when "Off" it sets the msg to null making the flow stop, but you can use your own logic there.
Code: Select all
[{"id":"67c37422.c6a7bc","type":"http request","z":"dbd5d34b.5859c","name":"Get device info","method":"GET","ret":"txt","paytoqs":"ignore","url":"http://127.0.0.1:8080/json.htm?type=devices&rid=192","tls":"","persist":false,"proxy":"","authType":"","x":279.00000762939453,"y":372.00000286102295,"wires":[["aa1d1dde.94931"]]},{"id":"aa1d1dde.94931","type":"json","z":"dbd5d34b.5859c","name":"","property":"payload","action":"","pretty":false,"x":424.43359756469727,"y":370.6333055496216,"wires":[["7c0dcf64.2b72e"]]},{"id":"7c0dcf64.2b72e","type":"function","z":"dbd5d34b.5859c","name":"get Switch state","func":"if (msg.payload.result[0].Data == \"Off\") {\n msg = null;\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":578.9335556030273,"y":370.6333065032959,"wires":[["c8db0f94.c4e49"]]},{"id":"b97c7c56.c4091","type":"inject","z":"dbd5d34b.5859c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":116.60000610351562,"y":371.0000047683716,"wires":[["67c37422.c6a7bc"]]},{"id":"c8db0f94.c4e49","type":"debug","z":"dbd5d34b.5859c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":766.6000595092773,"y":370.0000047683716,"wires":[]}]