I have an array output that varies in size depending on the data it is sending. The device sends data every 60 seconds on an occupancy count for a building. Every time the data changes, it added another item into the array, so if nobody enters, an empty message is sent, if 1 person enters over 60 seconds, the array contains one value, however if 10 people enter, there are 10 entries in the array. If 10 enter, and 5 leave, there are 15 values in the array, etc, etc.
I am looking for a way to grab the values out of the array, regardless of the index number. I am using a switch node to filter the empty values out, but if I do anything using = msg.payload.value, then it works for the first array item only, does that make sense? The "live" number may be vastly different to this.
If I cannot do it for each item, how would I always grab the LAST item in an array?