Page 1 of 1

rules and variables

Posted: 23 Jun 2020, 13:28
by edstobi
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

Re: rules and variables

Posted: 23 Jun 2020, 14:28
by grovkillen
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.

Re: rules and variables

Posted: 23 Jun 2020, 20:48
by TD-er
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.

Re: rules and variables

Posted: 25 Jun 2020, 13:58
by edstobi
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.