# Filter by name in payload

**URL:** <https://discourse.nodered.org/t/filter-by-name-in-payload/50257>\
**Category:** General\
**Created:** [27 August 2021 08:03 UTC](https://discourse.nodered.org/t/filter-by-name-in-payload/50257 "2021-08-27T08:03:18Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![simda](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@simda](https://discourse.nodered.org/u/simda)\
**Post date:** [27 August 2021 08:03 UTC](https://discourse.nodered.org/t/filter-by-name-in-payload/50257/1 "2021-08-27T08:03:18Z")

</div>

Hello, i am new in node red  
Node (MQTT IN) is connected to the things network (TTN), ELSYS ERS Eye registered in TTN, HTTP GET request configured to external application works

payload is:

v3/motiondetection@ttn/devices/eui-a81758fffe0654c8/up : msg.payload : string[782]

"{"end\_device\_ids":{"device\_id":"eui-a81758fffe0654c8","application\_ids":{"application\_id":"motiondetection"},"dev\_eui":"A81758FFFE0654C8","join\_eui":"0000000000000000"},"correlation\_ids":["as:up:01FE39GWYM12QSTX410B86MWR6","rpc:/ttn.lorawan.v3.AppAs/SimulateUplink:43864109-9910-45f8-bb86-ca23804cad76"],"received\_at":"2021-08-27T07:52:23.253656996Z","uplink\_message":{"f\_port":1,"frm\_payload":"BQERAQ==","decoded\_payload":{"motion":1,"occupancy":1},"rx\_metadata":[{"gateway\_ids":{"gateway\_id":"test"},"rssi":42,"channel\_rssi":42,"snr":4.2}],"settings":{"data\_rate":{"lora":{"bandwidth":125000,"spreading\_factor":7}}},"received\_at":"0001-01-01T00:00:00Z","locations":{"user":{"latitude":47.49257222077071,"longitude":8.720179064421783,"source":"SOURCE\_REGISTRY"}}},"simulated":true}"

now i will filter exactly and only the value "motion:1" to send it to ext. application  
What is the correct configuration for this ?  
Thank you very much for feedback.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [27 August 2021 08:22 UTC](https://discourse.nodered.org/t/filter-by-name-in-payload/50257/2 "2021-08-27T08:22:38Z")

</div>

Set the mqtt node to output an object, then `msg.payload.uplink_message.decoded_payload.motion`  
should hold the value of 1  
as in image below

 ![Screenshot_20210827-110418](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/4/148ad64b21c5f631c502dec288a3d3f5b8724e9d.png)  
then use copy path in the debug pain to get the path to the info, as in below image  
 ![Screenshot_20210827-110823](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/b/dbc5bb92cc3b03aa201aee00d3e6223d48b2371c.png)

---

<div class="post-metadata">

**Author:** ![simda](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@simda](https://discourse.nodered.org/u/simda)\
**Post date:** [27 August 2021 09:25 UTC](https://discourse.nodered.org/t/filter-by-name-in-payload/50257/3 "2021-08-27T09:25:12Z")

</div>

thank you  
what object can i take ? change object or function object ?

---

<div class="post-metadata">

**Author:** ![simda](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@simda](https://discourse.nodered.org/u/simda)\
**Post date:** [27 August 2021 12:50 UTC](https://discourse.nodered.org/t/filter-by-name-in-payload/50257/4 "2021-08-27T12:50:25Z")

</div>

thank you very much, that looks better now  
my topic in MQTT must be #  
one more question ; what object can filter exactly value motion 1 to send only message with value motion 1 , at the moment all messages with motion are transmitted. how to configure ?

---

<div class="post-metadata">

**Author:** ![simda](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@simda](https://discourse.nodered.org/u/simda)\
**Post date:** [27 August 2021 12:51 UTC](https://discourse.nodered.org/t/filter-by-name-in-payload/50257/5 "2021-08-27T12:51:50Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/f/4fead63de7fff6d74ffc52305a8b8d6b08433dde.png)

---

<div class="post-metadata">

**Author:** ![simda](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@simda](https://discourse.nodered.org/u/simda)\
**Post date:** [27 August 2021 12:52 UTC](https://discourse.nodered.org/t/filter-by-name-in-payload/50257/6 "2021-08-27T12:52:26Z")

</div>

thats my "dream" it should be looking like that.....

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [27 August 2021 12:57 UTC](https://discourse.nodered.org/t/filter-by-name-in-payload/50257/7 "2021-08-27T12:57:40Z")

</div>

> [@simda](#):
>
> topic in MQTT must be #

If you do that you will get all mqtt messages, not just the one you want. Set it to the topic you are interested in.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [27 August 2021 12:59 UTC](https://discourse.nodered.org/t/filter-by-name-in-payload/50257/8 "2021-08-27T12:59:40Z")

</div>

The images you supply do not help as there is no info i can get from them.  
You may use any topic you like. The example in the image i supplied is only to show you how to otput an object.  
As to the object you would need to use the path to the motion value "1" then create the message you wish to send. I Showed you in image above how to get the path to any value in your incoming object.

If you require more help you will need to supply text or flow json, so any one helping can easily copy info to give you more examples.

here is a simple example how to extract the "1" and create a message that will output "Motion 1", it uses a switch node to only allow the value 1 through

```auto
[{"id":"98ed224a.4e929","type":"inject","z":"c74669a0.6a34f8","name":"simulate mqtt in","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"end_device_ids\":{\"device_id\":\"eui-a81758fffe0654c8\",\"application_ids\":{\"application_id\":\"motiondetection\"},\"dev_eui\":\"A81758FFFE0654C8\",\"join_eui\":\"0000000000000000\"},\"correlation_ids\":[\"as:up:01FE39GWYM12QSTX410B86MWR6\",\"rpc:/ttn.lorawan.v3.AppAs/SimulateUplink:43864109-9910-45f8-bb86-ca23804cad76\"],\"received_at\":\"2021-08-27T07:52:23.253656996Z\",\"uplink_message\":{\"f_port\":1,\"frm_payload\":\"BQERAQ==\",\"decoded_payload\":{\"motion\":1,\"occupancy\":1},\"rx_metadata\":[{\"gateway_ids\":{\"gateway_id\":\"test\"},\"rssi\":42,\"channel_rssi\":42,\"snr\":4.2}],\"settings\":{\"data_rate\":{\"lora\":{\"bandwidth\":125000,\"spreading_factor\":7}}},\"received_at\":\"0001-01-01T00:00:00Z\",\"locations\":{\"user\":{\"latitude\":47.49257222077071,\"longitude\":8.720179064421783,\"source\":\"SOURCE_REGISTRY\"}}},\"simulated\":true}","payloadType":"json","x":230,"y":3060,"wires":[["bb5d3d9f.314f1"]]},{"id":"bb5d3d9f.314f1","type":"switch","z":"c74669a0.6a34f8","name":"","property":"msg.payload.uplink_message.decoded_payload.motion","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":420,"y":3080,"wires":[["b2bd381b.685f98"]]},{"id":"b2bd381b.685f98","type":"change","z":"c74669a0.6a34f8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"\"Motion \" & $$.msg.payload.uplink_message.decoded_payload.motion","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":600,"y":3080,"wires":[["f8d76bc5.f3ef18"]]},{"id":"f8d76bc5.f3ef18","type":"debug","z":"c74669a0.6a34f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":700,"y":3040,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![simda](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@simda](https://discourse.nodered.org/u/simda)\
**Post date:** [28 August 2021 05:53 UTC](https://discourse.nodered.org/t/filter-by-name-in-payload/50257/9 "2021-08-28T05:53:59Z")

</div>

thank you very very much !  
now it works. Filtering only for motion 1 transmitted.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [27 October 2021 05:54 UTC](https://discourse.nodered.org/t/filter-by-name-in-payload/50257/10 "2021-10-27T05:54:42Z")

</div>

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