# Help with filtering payload

**URL:** <https://discourse.nodered.org/t/help-with-filtering-payload/70518>\
**Category:** General\
**Created:** [12 November 2022 22:34 UTC](https://discourse.nodered.org/t/help-with-filtering-payload/70518 "2022-11-12T22:34:03Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![hugovsky](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hugovsky/32/67691_2.png) [@hugovsky](https://discourse.nodered.org/u/hugovsky)\
**Post date:** [12 November 2022 22:34 UTC](https://discourse.nodered.org/t/help-with-filtering-payload/70518/1 "2022-11-12T22:34:03Z")

</div>

I'm using **[node-red-contrib-sun-position](https://github.com/rdmtc/node-red-contrib-sun-position)** to control my roller blinders. I need to pass blinder position to the node if I use the manual commands. To do this, I'm using this example flow to:

1- get current position but only the number.  
2- block repeated messages so that it doesn't reset blinder node  
3- pass it to blinder control node

It works but, is there a simpler or more correct(beautiful) way of doing it?

```auto

[{"id":"6d541357a13be106","type":"poll-state","z":"c807ae25c9316897","name":"Posi","server":"e1926eef.58258","version":2,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"updateinterval":"1","updateIntervalType":"num","updateIntervalUnits":"hours","outputinitially":false,"outputonchanged":true,"entity_id":"cover.cozinha1","state_type":"str","halt_if":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"x":210,"y":900,"wires":[["da4bce5497b4c17d"]]},{"id":"da4bce5497b4c17d","type":"change","z":"c807ae25c9316897","name":"Data","rules":[{"t":"set","p":"payload","pt":"msg","to":"data.attributes.current_position","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":900,"wires":[["986f54b992dc39a9"]]},{"id":"3d354d9cea62dd46","type":"debug","z":"c807ae25c9316897","name":"debug 3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":640,"y":900,"wires":[]},{"id":"986f54b992dc39a9","type":"rbe","z":"c807ae25c9316897","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"topic","x":490,"y":900,"wires":[["3d354d9cea62dd46"]]},{"id":"e1926eef.58258","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30,"areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true}]

```

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [12 November 2022 22:39 UTC](https://discourse.nodered.org/t/help-with-filtering-payload/70518/2 "2022-11-12T22:39:25Z")

</div>

I can't copy the code.

Usually when that kind of _code_ is posted (grey box area) there is a _copy to clipboard_ icon in the top right corner.

I'm not seeing it.

(but just now I am having network problems, so it could be at my end)

---

<div class="post-metadata">

**Author:** ![hugovsky](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hugovsky/32/67691_2.png) [@hugovsky](https://discourse.nodered.org/u/hugovsky)\
**Post date:** [12 November 2022 22:45 UTC](https://discourse.nodered.org/t/help-with-filtering-payload/70518/3 "2022-11-12T22:45:46Z")

</div>

Sorry. Try now.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [12 November 2022 22:47 UTC](https://discourse.nodered.org/t/help-with-filtering-payload/70518/4 "2022-11-12T22:47:17Z")

</div>

Better.

I'm a bit busy just now.

I just wanted to mention that no one could copy the code.

---

<div class="post-metadata">

**Author:** ![hugovsky](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hugovsky/32/67691_2.png) [@hugovsky](https://discourse.nodered.org/u/hugovsky)\
**Post date:** [12 November 2022 22:51 UTC](https://discourse.nodered.org/t/help-with-filtering-payload/70518/5 "2022-11-12T22:51:18Z")

</div>

Thank you for the warning. I'm not in a hurry, everything is working. Just trying to improve.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [13 November 2022 00:00 UTC](https://discourse.nodered.org/t/help-with-filtering-payload/70518/6 "2022-11-13T00:00:39Z")

</div>

Well - assuming that `data.attributes.current_position`is part of the msg, you don't need to use jsonata in the change node. Change the from using jsaoata to grab it from the msg object:  
 ![Screen Shot 2022-11-12 at 6.57.06 PM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/d/bdca070752d4f42487c8a10599df4ac96f1e9c59.png)

Other than that, a two node flow is very good!

---

<div class="post-metadata">

**Author:** ![hugovsky](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hugovsky/32/67691_2.png) [@hugovsky](https://discourse.nodered.org/u/hugovsky)\
**Post date:** [13 November 2022 13:53 UTC](https://discourse.nodered.org/t/help-with-filtering-payload/70518/7 "2022-11-13T13:53:18Z")

</div>

Well, thank you then! I'm happy with the solution, also. Just remembered to ask because I like to optimize things and maybe there was a better way to do it.

---

<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:** [12 January 2023 13:54 UTC](https://discourse.nodered.org/t/help-with-filtering-payload/70518/8 "2023-01-12T13:54:08Z")

</div>

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