Page 1 of 1

ESPEasy and global variables

Posted: 25 Feb 2024, 06:13
by orskavto
Hi Dear!
How to create global variables in Rules ESPEasy?
For example, I find it tedious that, depending on the value of a global variable, when the same events occur, the program performs different actions. At the initial stage, the user selects the "operating mode" of the device - this is the first global variable. Then, in the process of work, there are "stages of work"-this is the second global variable. And depending on what is equal to "mode of operation" + "stages of operation", when you click on the same button, different actions occur.

Re: ESPEasy and global variables

Posted: 25 Feb 2024, 09:53
by Ath
You have some reading to do: https://espeasy.readthedocs.io/en/lates ... Rules.html
That will help you in creating the solution you have in mind.

Re: ESPEasy and global variables

Posted: 25 Feb 2024, 10:40
by TD-er
In short, see the command "let"
This can also be used to perform calculations.

To access those variables, you can use either [var#1] or [int#1] or %v1%
Where "1" is the variable nr.
The difference between those is that "int" returns the integer representation of the value, where [var#N] and %vN% notation refer to floating point representation.

%vN% notation can also be used to 'nest' indices so you can add some offset in variables.

For example: [int#%v1%] and on really recent builds %v%v%1%%% etc should work.

Re: ESPEasy and global variables

Posted: 25 Feb 2024, 11:33
by orskavto
Ath wrote: 25 Feb 2024, 09:53 You have some reading to do: https://espeasy.readthedocs.io/en/lates ... Rules.html
That will help you in creating the solution you have in mind.
Yes, thank you!
I found this Let,<n>,<value>
I think that should be enough.
It remains only to figure out how to create and then read the log file on the SD card. To be able to continue working from the stop in case there is a power outage.