Help with filtering payload

I'm using 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?


[{"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}]

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)

Sorry. Try now.

1 Like

Better.

I'm a bit busy just now.

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

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

Well - assuming that data.attributes.current_positionis 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

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

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.

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