i wanted to create a bash script, that runs every x seconds and calculates the average of all the measured power values in the last minute.
When playing around with the feed API , i noticed that ‘/feed/data.json’ and ‘/feed/average.json’ don’t give me the most recent values.
I assume, the reason for this is, that these commands only access data, that has already been written to the SD card?
So my idea was to run a script every 10 seconds, that gathers the last value and adds it to a rotating logfile on a ramdisk (/tmp). Or maybe it would be better to get the last value every 5 seconds and only store it if it’s changed, so I’m sure not to miss any updates.
Then I would make another script hat runs every 30 seconds to gather the last 6 values from my file and calculate the average.
Maybe somebody has a better solution for this, that im not aware of?
Thanks and best regards