Hi,
I am working on some functionality in Node-Red.
I have a motion sensor that switches the light on and off through my script.
Now i want to check status of a dummy switch in Domoticz before actually switching the light, because i may want to prevent automatically switching.
I've reached the end of internet, maybe i've overlooked, but i have not found anything that would help me.
I think that it would be fastest to send an MQTT request to Domoticz/in topic to obtain info about IDX 62 but how can i catch the response? Lost
Check status (ON/OFF) of dummy switch from Node-Red Topic is solved
Moderator: leecollings
-
- Posts: 128
- Joined: Saturday 26 March 2016 10:19
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.4834
- Location: Netherlands
- Contact:
- jvdz
- Posts: 2189
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: Check status (ON/OFF) of dummy switch from Node-Red
In Node-Red you can easily get the status of a switch by doing an json call: http://127.0.0.1:8080/json.htm?type=devices&rid=192
(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.
Jos
(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":[]}]
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 128
- Joined: Saturday 26 March 2016 10:19
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.4834
- Location: Netherlands
- Contact:
Re: Check status (ON/OFF) of dummy switch from Node-Red
Thanks, that's very helpfull! I guess this could work, so i'll play with it.
Who is online
Users browsing this forum: No registered users and 1 guest