rules and variables

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
edstobi
Normal user
Posts: 39
Joined: 28 May 2020, 20:33

rules and variables

#1 Post by edstobi » 23 Jun 2020, 13:28

Hello
I have a question about the rules and variables.
I understood that I can use up to 16 variables.
Are the variables global so that I can use them over all 4 rules or do I have to allow a variable for a use in 2 different rules?
I define this variable in rule 4, but I have difficulties to process it in rule 1.

Code: Select all

Let,1,[Ultrashall#Distance]
Can my assumption be correct that the value, as it is set in rule 4 but rule 1 is processed earlier, is partly not yet available?


THX MArc

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: rules and variables

#2 Post by grovkillen » 23 Jun 2020, 14:28

The variables are global so to speak but from the start they are set to zero. If you use conditions based on this value you should set the variables to a bogus value at first.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

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

Re: rules and variables

#3 Post by TD-er » 23 Jun 2020, 20:48

They are indeed global.
So you can use them in any of the rules files, but you could also refer to them in other places where you can refer to internals like [taskname#varname] and also the variables.
For example in display plugins, or publish topics for MQTT controllers, etc.

The main difference between dummy task variables and the global vars is:
- Dummy tasks take up a slot which cannot be used for another task
- Values stored in a dummy task may survive a reboot, as long as the unit remains powered.
- A dummy task may send all stored values to a connected controller when you call taskrun on the task.

edstobi
Normal user
Posts: 39
Joined: 28 May 2020, 20:33

Re: rules and variables

#4 Post by edstobi » 25 Jun 2020, 13:58

THX
this are some value Informationsarm for me
The main difference between dummy task variables and the global vars is:
- Dummy tasks take up a slot which cannot be used for another task
- Values stored in a dummy task may survive a reboot, as long as the unit remains powered.
- A dummy task may send all stored values to a connected controller when you call taskrun on the task.

Post Reply

Who is online

Users browsing this forum: No registered users and 17 guests