ESPEasy and global variables

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
orskavto
Normal user
Posts: 21
Joined: 21 Feb 2024, 14:49

ESPEasy and global variables

#1 Post by orskavto » 25 Feb 2024, 06:13

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.

User avatar
Ath
Normal user
Posts: 3522
Joined: 10 Jun 2018, 12:06
Location: NL

Re: ESPEasy and global variables

#2 Post by Ath » 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.
/Ton (PayPal.me)

TD-er
Core team member
Posts: 8756
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: ESPEasy and global variables

#3 Post by TD-er » 25 Feb 2024, 10:40

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.

orskavto
Normal user
Posts: 21
Joined: 21 Feb 2024, 14:49

Re: ESPEasy and global variables

#4 Post by orskavto » 25 Feb 2024, 11:33

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 40 guests