Page 1 of 1

Multiple average readings from sensors

Posted: 19 Jul 2021, 17:47
by manubis_sanchez
Hello,

I found this page to do an average with one of my sensors with the rules feature. It works great.
However, I would like to do the same for 2 more of my sensors on the same ESP. I tried to create a new rule but the target value of the first rule is affected by the second rule.

Code: Select all

On Temp#Temperature Do
 Let,10,[VAR#9]
[...]
 Let,2,[VAR#1]
 Let,1,[Temp#Temperature]
 TaskValueSet,9,1,([VAR#1]+[VAR#2]+[VAR#3]+[VAR#4]+[VAR#5]+[VAR#6]+[VAR#7]+[VAR#8]+[VAR#9]+[VAR#10])/10
EndOn

Code: Select all

On pH#ph Do
 Let,10,[VAR#9]
[...]
 Let,2,[VAR#1]
 Let,1,[pH#ph]
 TaskValueSet,10,1,([VAR#1]+[VAR#2]+[VAR#3]+[VAR#4]+[VAR#5]+[VAR#6]+[VAR#7]+[VAR#8]+[VAR#9]+[VAR#10])/10
EndOn
I tried to replace VAR by PH to test but it does'nt work. I think I did not understand the lines of the system of variables (Let,x,[VAR#y]).

Someone can help me, please ?

Thanks.

Edit : I found how it works ! We only have 16 variables so for my 3 sensors I can just use 5 var MAX if I understand well.
Do you confirm we can't make for loop to incremente juste one variable ?

Re: Multiple average readings from sensors

Posted: 19 Jul 2021, 19:25
by Ath
On a current build (2021-02 and newer IIRC) you can have [var#x] until memory runs out, so adding 10 to all the numerics in the second rule should fix that.

Re: Multiple average readings from sensors

Posted: 19 Jul 2021, 19:57
by manubis_sanchez
That's good to know ! Thank you.
My ESP8266 has rebooted several times, I think I ask it too much :s
I will work on that to find a good balance between precision of the values and load of the ESP.

Re: Multiple average readings from sensors

Posted: 19 Jul 2021, 19:57
by TD-er
Do you call "event" from your rules? Or "delay" ???