I like to calculate the avarage energy level (W) over the last 5 minutes.
What is my goal?
I have solar panels and I want to switch on/off a device when the panels start to produce energy. But when they start the amount is not so high and if someone is in the house and switches stuff on and off then it can make large steps from negative energy to positive and back. T prevent to much flipping i use a timer now, but a much better approch is to use average data over a certain period, to prevent to much switching my device on and off.
Also due to clouds the energy levels can very a lot.
I found the thread how to calculate the average humidity, but that’s a continues average and not an average over the last 5 minuts.
What I thought but cannot find: can I use the history of Insights in a flow card, to calculate an average, max, min, sum, etc. over the last 1, 5, 10, 15, 30, 60 minutes and maybe even hours and day’s? The numbers are there, but how to use them in a flow?
Numbers for example (in W):
Normal use: 200, no one at home (NAS, Homey, cameras, etc).
CV 65
Washing machine 2200
Fohn / vacume cleaner, dishwasher, etc…
Solar full sun: -2400
Solar with cloud -10 till -1200
@Osorkon because the sun could be hidden behind clouds for 4 minutes and 55 seconds, and then, just when you’re using the current value, the sun breaks through to the almost overcast sky…
@M_a_r_c_o did you find a solution already? I’m looking for the same formula, but to switch the lights on/off with the lux sensor of the Hue motion sensor. I don’t want the current value, because if someone walks by, the lux drops for a second and isn’t reliable. I’d like an average for let’s say a minute or so.
@TKroon No, not yet found it.
I did try the < < group> > app, but for a group of energy only total exist and no selectable period. Maybe for Lux the average exist in the sensors.
To do it manually, I think I need 2 count downs, one for every 15 or 30 seconds, a second one for 5 minutes, make it a loop and use betterlogic to calculate average over an array of numbers (if that is possible).
Another flow to update every 15 seconds the oldest updated value in the array.
Or use homeyscript may be.
@Caseda thanks, that sounds like an acceptable workaround. Still, for example when the threshold is 10, and I’ve got lots of 3’s, and then one spike of 11, the timer resets. But it’s better than nothing.
Well, I did not investigate further or implemented this, the waf is to unpredicatable
But I did something which looks a bit like this. Using the apps Insight Trends Reloaded and the app Temporary Variables. And results in 3 new Insight graphs (numeric logics).
Danger is with 5 minutes that you can have a flow which disables often.