Keep precipitation for 10 days in an array or fifo queue with 10 places and add a new value every day

Can that be done in an (advanced) flow? If so, would you have an example for me?

Thanks!

Try with Better logicā€¦ Better Logic Library App for Homey | Homey
You can import/export variables but it do not allow to create array as such, if Iā€™m not mistaken.
Why do you need to store them ? They are available in insights from some sensor, or ?

Eg. Netatmo Rain sensor have ā€œrain todayā€ :

So then you can use Insights trends for some statistical analysis / use.

Or Device capability app and read values via Retrieve valuesā€¦
obrazek

Thank you. I do not have a device, I use Weatherpro. The free version only provides the current precipitation every 15 minutes. I add them up during the day and for watering plants I would like to keep a running history of the precipitation of last 10 days.

I was wondering if a JSON structure could be used to store the values in a variable. But how to manipulate the JSON structureā€¦

In any case, I can probably do it in a Homey Script routine.

Paul

@pmeester

You can use the JSON handler app for handlering jsons.

But even in the BetterLogicLibrary you can use arrays.
Just place [1,2,3,4] in a variable for instance.
Now, use the BLL expression cards and place the variable containing the array in it, plus [0] behind it, and you will recieve the fiest element in the array.

BLL alows predefined functions, so you can create push functions for instance.

Example:

2 Likes

@Arie_J_Godschalk, Thank you. Can you give an example? If I have a string variable S1=[1,2,3,4,5], then:
If I use BLL ā€œSet Number Variableā€ then I do not get the string variable S1 as an option to do S1[0] with. I only get real number variables

If I use BLL ā€œSet a variable N1 S1[0]ā€ then I get the error ā€œNot a numberā€

Hi @Arie_J_Godschalk, I am trying to build a rate limit queue for logging to Google Sheets using an array but for some reason I canā€™t read the values. I managed to use your example to fill a 2-dimensional array with values (each log line is an array within the array variable), which is awesome, but when I try to read the first value, I get nothing:


Even though I can see that the array contains 2 values:
SchermĀ­afbeelding 2023-11-09 om 23.33.07
Iā€™m not sure what Iā€™m doing wrong. I am expecting to get ā€œ[ā€œBadkamerā€,ā€œ09-11-2023 11:03:44ā€,ā€œ39.8ā€,ā€œ25.5ā€,ā€ā€œ,ā€ā€œ]ā€ as a value, on which I would do further array value reading ([0], [1] etc).

At any rate, some array operation cards such as reading of values, push, pop, shift and unshift would be nice!

@Paul_Nas Well, what you expecting is that it would return an array, but this flowcard does not do that, because the returning tags are either string, number or boolean.
If you want to grap an json/array, use the json handler app.
But perhaps i can add a json tag to the execution flowcard. Please create a ticket?

@Arie_J_Godschalk it took some effort to figure this out but I got it working thanks to your help! I created a non-array array using ā€˜|ā€™ as a delimiter which I then turned into an array with a predefined function in BLL, read with JSON Handler and passed on to Google Sheets for logging. The (incomplete) AF is:

My buffer array looks like this:

Function ā€˜Splitsā€™:
SchermĀ­afbeelding 2023-11-10 om 15.23.12

To fill the array with new values, I use function ā€˜pushArrayā€™:
SchermĀ­afbeelding 2023-11-10 om 15.25.34

All I have to do now is write the oldest value of the array to Google Sheets every 3 minutes or so using the above (unless thereā€™s nothing in the array) and apply this solution to all my logging. Yay! Maybe I could do without the function ā€˜Splitsā€™ and instead use _.split but then I wouldnā€™t know what each element is called so I canā€™t reference them in JSON Handlerā€¦ @pmeester can you use any of my stuff to solve your problem?