Reading a Node's message payload when the state changes and putting that into another Node

Hi All,

I have a reed switch on a gate, when the switch triggers it updates on my device from false, to true.

Is there a way that when this occurs, that it populates a node? Intention is to get this information into OpenHAB as a Contact Item (so, OPEN/CLOSED)

Here is the debug from the door

07/12/2021, 8:45:22 amnode: get-status
get-status : msg.payload : Object
object
deviceId: 225024747
state: object
serialNumber: 225024747
event: object
doors: object
1: false
2: true
3: false
4: false

Under Doors: object, you can see TRUE. This is the data I want to populate in to OpenHAB

Any points would be fantastic, thank you!

Regards

What do you mean by 'populates a node'. The normal way to pass information to a node is to send it a message.

What im confused about is what I need to use when the gate opens/triggers and the reed switch changes from closed to open.

How do I get that message and put it into a node?

How did you get the message that you showed us above - did it get sent automatically when the switch was activated, or did you somehow request the current status?

I used this template

That flow has three Inject nodes, each labelled "test".
The there are the three nodes "get door control", "set door control" and "open door". I don't know which of these gives you the data you posted above since I do not have a UHPPOTE TCP/IP Wiegand access controller board.

However, you can set the inject node to repeat. It could be once a minute or 10 times a second, whatever meets your requirement.
Then the bit of data that you want seems to be in msg.payload.doors.2. You can use a change node to extract it and a Filter node to only pass the message on when it's value changes.

Maybe something like this:

[{"id":"c021986865969964","type":"inject","z":"3140aa6bccad4d0d","name":"","props":[{"p":"payload"}],"repeat":"5","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":110,"y":140,"wires":[["c8a9529354c8383b"]]},{"id":"656d89ab5b23e7ed","type":"rbe","z":"3140aa6bccad4d0d","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"topic","x":710,"y":80,"wires":[["e9eb86e2885f32ec"]]},{"id":"ba760dea443b6668","type":"change","z":"3140aa6bccad4d0d","name":"Door 1","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.doors.1","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"door1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":80,"wires":[["656d89ab5b23e7ed"]]},{"id":"a93ae9247c9db0cc","type":"rbe","z":"3140aa6bccad4d0d","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"topic","x":710,"y":120,"wires":[["9dfbe9fb125a2bcf"]]},{"id":"8f06051413e1ad57","type":"change","z":"3140aa6bccad4d0d","name":"Door 2","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.doors.2","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"door2","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":120,"wires":[["a93ae9247c9db0cc"]]},{"id":"81792cdce7a35da7","type":"rbe","z":"3140aa6bccad4d0d","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"topic","x":710,"y":160,"wires":[["8f92b3f367e2801d"]]},{"id":"cff78b9aca10ce0a","type":"change","z":"3140aa6bccad4d0d","name":"Door 3","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.doors.3","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"door3","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":160,"wires":[["81792cdce7a35da7"]]},{"id":"2ad8e28ac9b4d7c6","type":"rbe","z":"3140aa6bccad4d0d","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"topic","x":710,"y":200,"wires":[["be0f9557384ce526"]]},{"id":"b7c9e1c6563420c2","type":"change","z":"3140aa6bccad4d0d","name":"Door 4","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.doors.4","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"door4","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":200,"wires":[["2ad8e28ac9b4d7c6"]]},{"id":"e9eb86e2885f32ec","type":"debug","z":"3140aa6bccad4d0d","name":"Door 1 status changed","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":880,"y":80,"wires":[]},{"id":"9dfbe9fb125a2bcf","type":"debug","z":"3140aa6bccad4d0d","name":"Door 2 status changed","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":880,"y":120,"wires":[]},{"id":"8f92b3f367e2801d","type":"debug","z":"3140aa6bccad4d0d","name":"Door 3 status changed","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":880,"y":160,"wires":[]},{"id":"be0f9557384ce526","type":"debug","z":"3140aa6bccad4d0d","name":"Door 4 status changed","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":880,"y":200,"wires":[]},{"id":"c8a9529354c8383b","type":"get-door-control","z":"3140aa6bccad4d0d","name":"One of the UHPPOTE nodes","topic":"","config":"cbd92359.dbf19","x":360,"y":140,"wires":[["ba760dea443b6668","8f06051413e1ad57","cff78b9aca10ce0a","b7c9e1c6563420c2"]]},{"id":"378b04a7268fe0fd","type":"comment","z":"3140aa6bccad4d0d","name":"A possible way to get status changes of 4 doors","info":"","x":200,"y":100,"wires":[]},{"id":"cbd92359.dbf19","type":"config","name":"examples","timeout":"5000","bind":"192.168.1.100","broadcast":"192.168.1.255:60000","listen":"192.168.1.100:60001","controllers":"{\"303986753\":{\"address\":\"192.168.1.100:60000\",\"broadcast\":false},\"405419896\":{\"address\":\"192.168.1.100:60000\",\"broadcast\":true}}","debug":true}]

Thanks, but can't NR react to the code changing (Closed to Open) or must it use some kind of timer like you said ?

All I have to go on is what you've told us.
I don't have the slightest idea what you mean by "the code changing".

There are nodes which watch for an event and send a message when a change occurs. An example is the Raspberry PI GPIO In node. Perhaps one of the UHPPOTE nodes does that? I don't know.

The alternative is to poll the device periodically, as I suggested above.

Changing, by this i mean the door ie from Closed to Open. But I guess this is all NR polling the device, rather than the device sending a message to NR upon it changing (which it wouldnt do)

I dont think NR is the right way to do it.

From what I can tell, you may have better luck taking a look at this example for a closer to real-time data feed.

Most devices do send data when they change state. What device are you using and how is it connected to the system?

Seems listen is what I need.

Need to extract that open/closed data then to send to openHab

Should be pretty easy past that point. Hit us up if you run into trouble.

With lots of other APIs, the best you get is the equivalent of check status (philips hue, this shade is cast at you.) In that situation, the typical approach is to just check the status every X amount of time (referred to as "polling.")

1 Like

Thanks Jay I will if thats OK by you.

I need to go and open/close the gate a few times to see if the debug on the code I imported registers correctly. Then I'm not sure where to start but basically i want to extract that gate 'status' so to speak and send that to an OpenHAB Contact Item. The link between NR and OH is working , at least in the sense that if I send a ON command to the Electric Strike switch, it opens the gate via NR, but sending the gate status/state, in the other direction is new..

cheers!

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.