Page 1 of 1

Subtracting values of variables in rules

Posted: 17 Mar 2019, 11:13
by ulfh2018
I am trying to subtract to values in a rule, but it looks like I am missing on the syntax. I have set up the following rule:

on BadNede do
TaskValueSet 2,1,%eventvalue%
if [Variables#BadNede]>32
TaskValueSet,2,1,32
endif
TaskValueSet 2,2,[Variables#BadNede - Floor#Bad-Nede]
timerSet,1,5
endon

Everything works as expected, except the line TaskValueSet 2,2,[Variables#BadNede - Floor#Bad-Nede], so there must be a syntax error. Can someone please correct me?

The log from ESPEasy shows the following:

EVENT: BadNede=28.50
310694: ACT : TaskValueSet 2,1,28.50
310705: Command: taskvalueset
310768: ACT : TaskValueSet 2,2,


Best regards

Ulf

Re: Subtracting values of variables in rules

Posted: 17 Mar 2019, 11:15
by grovkillen

Code: Select all

TaskValueSet 2,2,[Variables#BadNede]-[Floor#Bad-Nede]

Re: Subtracting values of variables in rules

Posted: 17 Mar 2019, 11:22
by ulfh2018
Thank you for your reply (Have'nt I seen you on another forum - you are Swedish if I'm not totally wrong)

Tried that. Result in the log file is like this:

504587: EVENT: BadNede=29.50
504609: ACT : TaskValueSet 2,1,29.50
504619: Command: taskvalueset
504679: ACT : TaskValueSet 2,2,29.50 - 25.69

Re: Subtracting values of variables in rules

Posted: 17 Mar 2019, 11:41
by grovkillen
Then do this:

Code: Select all

TaskValueSet 2,2,([Variables#BadNede]-[Floor#Bad-Nede])
And yep, I'm swedish. Located in Hudiksvall and part of the core team of ESP Easy. If you want, join the FB group "ESP Easy Sweden".

Re: Subtracting values of variables in rules

Posted: 17 Mar 2019, 11:49
by ulfh2018
I'll be happy to join the group!

Still not working.

Have checked that there is a legal value of Floor#Bad-Nede and Variables#BadNede, but the log file now shows me the following result:
330822: HTTP: event,BadNede=29.00
330864: EVENT: BadNede=29.00
330884: ACT : TaskValueSet 2,1,29.00
330894: Command: taskvalueset
330954: ACT : TaskValueSet 2,2,(29.00-25.69)

It's a hard life :D

Re: Subtracting values of variables in rules

Posted: 17 Mar 2019, 12:01
by ulfh2018
Sorry, must have had a typo. Now it works!

Thank you SOOOOO much :D :D :D :D :D