Help with payload (object)

285 views
Skip to first unread message

Nick Buedts

unread,
Jun 9, 2018, 10:44:56 AM6/9/18
to Node-RED
Hi,

I'm really struggling with understanding the 'msg.payload" with objects.
I'm really looking for this since a while, but I really miss a basic link.

I'm just going to tell what I trie to do:

I'm playing with the homkit node to 'simulate' a locking mechanism.

The input of this node to open the lock needs this:

[{"id":"7ef6ccf3.9e93d4","type":"inject","z":"8a160ea4.9b8d5","name":"Op Slot","topic":"","payload":"{\"LockTargetState\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":253.16671752929688,"y":407.3333854675293,"wires":[["43573fc6.8f4c7"]]}]

The homekit nodes just passes this message. 
What I now need to do is to confirm that the lock is actually open.

Therefore I now need this message at the input of the node:

[{"id":"1607c7b0.d4dfb8","type":"inject","z":"8a160ea4.9b8d5","name":"Is Gesloten","topic":"","payload":"{\"LockCurrentState\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":159.0000228881836,"y":716.0000171661377,"wires":[[]]}]

As you can see, I only need to change the text 'LockTargetState' to 'LockCurrentState'.

I wanted to do this 'automatically' with the change function, but thats only for changing the value.
I've tried with a Function. I can analyse the 'input' but I have NO idea how to get a LockCurrentState object at the output.

It's quite simpele but i really don't see it.

Thanks for helping

Zenofmud

unread,
Jun 9, 2018, 1:11:05 PM6/9/18
to node...@googlegroups.com
 You should ask this onhttps://discourse.nodered.org

Reply all
Reply to author
Forward
0 new messages