Compare data from one hour ago with current

I have a project where i collect the water level of a river with a sensor. When a predefined height is surpassed, the node red flow send a push message to my phone. Now i want to also compare the current level with the one, i detected on hour ago, so i can see the development over time. Is there a way i can buffer the collected data and compare it? New Data is collected every 10 Minutes.

Thanks in advance!

Hi and welcome.

You can use context storage to store data for use later.
One simple way would be store the new data in an array.
Set new data to array[6] and then delete array[0]. This would result in a 6 element array. With array[0] holding the reading from an hour ago, and array[5] holding the newest.

[{"id":"9dc7bc361d7f57e2","type":"inject","z":"b779de97.b1b46","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":140,"y":4840,"wires":[["af9dc0530e9f3f77"]]},{"id":"af9dc0530e9f3f77","type":"change","z":"b779de97.b1b46","name":"","rules":[{"t":"set","p":"sensor_data[6]","pt":"flow","to":"payload","tot":"msg"},{"t":"delete","p":"sensor_data[0]","pt":"flow"},{"t":"set","p":"payload","pt":"msg","to":"sensor_data","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":4840,"wires":[["06aabbd7aa405c1f"]]},{"id":"06aabbd7aa405c1f","type":"debug","z":"b779de97.b1b46","name":"debug 2483","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":470,"y":4840,"wires":[]}]

How to import/export a flow

You could also use a database to store the data. SQLite might be appropriate, or MySQL.
That way it's available if you decide you want to correlate the trend with rainfall records, etc.

Thank you both for your answers!
I think i will use both. The context storage for the problem i explained above and the database for future use.

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