Rename Rules Vars

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
User avatar
ThomasB
Normal user
Posts: 1274
Joined: 17 Jun 2018, 20:41
Location: USA

Rename Rules Vars

#1 Post by ThomasB » 16 Jan 2025, 21:09

Is there a feature that allows renaming the %v% user variables used in Rules? What I mean is, to be able to do something like this:

From:

Code: Select all

Let,1,0 // Clear LED Flag
if %v1%=0 // Is LED Flag reset?
To:

Code: Select all

Let,LED_FLG,0
if %LED_FLG%=0
I didn't see anything in the ReadTheDocs. But maybe it's there and hasn't been documented yet?

- Thomas

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

Re: Rename Rules Vars

#2 Post by TD-er » 16 Jan 2025, 21:37

It isn't documented yet... but this is according to the current implementation.
I get why you might want to have this, as it greatly improves readability.
However it will also add quite a lot of memory usage to ESP8266.

Right now, you could use dummy tasks and through [taskname#taskvaluename] kind of syntax use this.
Only you need to use taskvalueset here.
You can however use taskname etc. as arguments for taskvalueset.
See: https://espeasy.readthedocs.io/en/lates ... skvalueset


There are plans for "virtual tasks" which are about inbetween of dummy tasks and variables, but that's not yet implemented.
Mainly because this concept is not yet clear in my head how it should be used.

P.S.
When using taskvalueset, you might need to prefix any calculation with '=' when using it as an argument.
e.g. taskvalueset,foo,bar,=123+456
Or temporary store it in a var using 'let' and then copy it to the dummy task using taskvalueset.

User avatar
ThomasB
Normal user
Posts: 1274
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Rename Rules Vars

#3 Post by ThomasB » 16 Jan 2025, 22:07

Thanks for the info.
- Thomas

User avatar
ThomasB
Normal user
Posts: 1274
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Rename Rules Vars

#4 Post by ThomasB » 17 Jan 2025, 21:45

I can move my system vars to dummy vars. But with one second updates, won't I wear out the ESP32's FLASH? I recall it is rated for 100K writes, which is just a couple days of writing before the little fellow is going to get mad at me.

I could tolerate 5 sec writes, but not much more. Is my concern real, or am I safe to use the dummy method?

- Thomas

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

Re: Rename Rules Vars

#5 Post by TD-er » 17 Jan 2025, 21:57

Dummy tasks are not stored to flash. or at least not the taskvalues.
These are kept in RTC memory, which may survive a reboot or crash (or deep sleep) as long as the node remains powered.

User avatar
ThomasB
Normal user
Posts: 1274
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Rename Rules Vars

#6 Post by ThomasB » 17 Jan 2025, 22:34

That is good news. Thanks!

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests