Increase / Decrease


Im quite new to Node-Red but have begun my journey to learn more about it, atm. im have a device giving me the following input:

msg.payload : Object

ts: 1566388338405
objects: array[2]
0: object
frame: 1922815
oid: 5794
x0: 0.665
x1: 0.568
y0: 0.557
y1: 0.058
type: "person"

1: object
frame: 1922815
oid: 5796
x0: 0.707
x1: 0.604
y0: 0.509
y1: 0.057
type: "person"

My interrest is how i can get:

  1. The "oid" and send a count pr. "oid"
  2. The x0/y0 if that count increase send a 1 and if decrease send a 0

Dont know if this is the right place to ask for this kind of help :slight_smile:

You’ve got an array so you have multiple values of oid and x0 y0
so do you want to compare the first
with the second within one message

or between messages?

There’s a handy page in the docs which will show you how to get the path to a bit of data
and then if you want to compare within the same message you could look at the switch node or a function node.

If you want to compare between messages then you will need to store the result somewhere as each node doesn’t have a memory of previous messages. Look at the docs about storing context and there are also some examples in the cookbook

I would like to check each Array message by them selv, because the oid is a unique ID, so in general i wanted to check that the oid value is now counted more then 1 time and then chekc the x0 y0 if that increase of decreases..

ill check the cookbook didn knew that one :slight_smile: