Hi to all,
How can I filter out 2 quality check (qc) values in my payload? Can I use a function node?
T_Zone_2_IST_Temperatur
T_Zone_2_IST_Temperatur_qc
T_Zone_2_SOLL_Temperatur
T_Zone_2_SOLL_Temperatur_qc
Many thanks for help
Wolfgang
Hi to all,
How can I filter out 2 quality check (qc) values in my payload? Can I use a function node?
T_Zone_2_IST_Temperatur
T_Zone_2_IST_Temperatur_qc
T_Zone_2_SOLL_Temperatur
T_Zone_2_SOLL_Temperatur_qc
Many thanks for help
Wolfgang
Yes you will be able to do it in a function node, add a debug node and show us an example of the message that contains them if you need more advice
or maybe a change node set to delete them ?
15.7.2019, 14:12:44.075node: 1ebcf650.656f2a1522a388105841f081acef04a2782eb8/Extruder/T_Zone_2_IST_Temperatur,T_Zone_2_SOLL_Temperatur: msg: array[2000]
[ object, object, object, object, object, object, object, object, object, object … ]
So you are sending an array with thousands objects.
How wide is your screen? Can you actually visualise all this data?
Where are you getting this data from?
Is it a database?
Are you building it in your flow? It might be better to not add it in the first place rather than try to filter it out.
However if you do want help to filter it out, seeing what one of this objects contain is important.
https://nodered.org/docs/user-guide/messages
Thats what I tried
Thats how the payload looks like!
[{"T_Zone_2_SOLL_Temperatur":210,"T_Zone_2_IST_Temperatur":114.7,"T_Zone_2_SOLL_Temperatur_qc":0,"_time":"2019-07-15T04:51:42.031Z","T_Zone_2_IST_Temperatur_qc":0},
{"T_Zone_2_SOLL_Temperatur":210,"T_Zone_2_IST_Temperatur":114.7,"T_Zone_2_SOLL_Temperatur_qc":0,"_time":"2019-07-15T04:51:42.209Z","T_Zone_2_IST_Temperatur_qc":0},
{"T_Zone_2_SOLL_Temperatur":210,"T_Zone_2_IST_Temperatur":114.7,"T_Zone_2_SOLL_Temperatur_qc":0,"_time":"2019-07-15T04:51:43.200Z","T_Zone_2_IST_Temperatur_qc":0},
delete: msg.payload.T_Zone_2_IST_Temperatur_qc
What is the output of msg.payload. (debug node screenshot) - i suspect an array.
That would work if you only had one object, but you have 2000 in an array. Which is why if this is coming from a database, it might be more efficient to fix what puts in there in the first place.
Completely agree with this -- somewhere there is probably a SQL select statement that is returning everything, instead of just those fields that you want to display. Narrowing down your query, and grouping the 1000's of data points into chunks of time, will greatly improve the performance of the UI chart.
But, for future reference, I would use a JSONata expression to remove those properties from your raw data (assuming you cannot change the raw data that is returned). Here is one way to use a change
node to remove those *_qc
properties from the entire array of objects:
Here are a couple expressions I can think of to return just the fields you need:
_qc
payload.$sift(function($val,$key) { $not($key.$match(/.*_qc/)) })
_qc
payload ~> | $ | {}, $keys($)~>$filter(/.*_qc/) |
payload.{ "T_Zone_2_SOLL_Temperatur": T_Zone_2_SOLL_Temperatur, "T_Zone_2_IST_Temperatur": T_Zone_2_IST_Temperatur, "_time": _time }
I found a solution see below
Solution is a function block
Many thanks to everybody for help and input
So you only delete the first [0]
element ?
The solution from @shrickus is more elegant but more advanced.
Actually I didn't even know you could do delete msg...