Variables for use in rules??

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
bastibasti
Normal user
Posts: 22
Joined: 31 Jul 2018, 11:41

Variables for use in rules??

#1 Post by bastibasti » 09 Jan 2019, 21:19

Hi,

I'm trying to do something like this
(its a simple dimmer, a push button increases a variable, and the pwm output is set according to one of the 5 available dimmer levels)

Code: Select all

on button#switch do
 
  if [button#switch]=0
   $a=$a+1
  endif

  if $a=5
   $a=0
  endif

 if $a=0
  pwm,2,1024,750
 endif

 if $a=1
  pwm,2,1000,750
 endif

 if $a=2
  pwm,2,800,750
 endif

 if $a=3
  pwm,2,500,750
 endif

 if $a=4
  pwm,2,0,750
 endif

endon 
any idea how to achieve this??

Domosapiens
Normal user
Posts: 277
Joined: 06 Nov 2016, 13:45

Re: Variables for use in rules??

#2 Post by Domosapiens » 09 Jan 2019, 21:25

In rules you can use the command let
let,1,10 this will assign the value 10 to %v1%.

To get the value of %v1%, you can use %v1% or [VAR#1] depending on the rule syntax:
if %v1%=10
or
taskvalueset,1,1,%v1%
or
taskvalueset,1,1,[VAR#1]
30+ ESP units for production and test. Ranging from control of heating equipment, flow sensing, floor temp sensing, energy calculation, floor thermostat, water usage, to an interactive "fun box" for my grandson. Mainly Wemos D1.

Jackill
Normal user
Posts: 5
Joined: 10 Jan 2019, 08:38

Re: Variables for use in rules??

#3 Post by Jackill » 11 Jan 2019, 01:28

Domosapiens wrote:
09 Jan 2019, 21:25
In rules you can use the command let
let,1,10 this will assign the value 10 to %v1%.
WOW!
Great info! Searched for it resultless..

Where did you find the list of commands to use in rules?

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

Re: Variables for use in rules??

#4 Post by grovkillen » 11 Jan 2019, 05:35

I'm doing my best but need to work on my daytime job too. But the commands are found here: https://espeasy.readthedocs.io/en/lates ... mmand.html

Not all are listed, I will do my best adding them but I don't have the the time just now.
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:

Domosapiens
Normal user
Posts: 277
Joined: 06 Nov 2016, 13:45

Re: Variables for use in rules??

#5 Post by Domosapiens » 11 Jan 2019, 10:06

Where did you find the list of commands to use in rules?
While reading the forum, I collect snippets of Rules as examples in a document.

The (new) "Let" statement one was found here:
viewtopic.php?f=4&t=5961&p=32580&hilit= ... ill#p32580
30+ ESP units for production and test. Ranging from control of heating equipment, flow sensing, floor temp sensing, energy calculation, floor thermostat, water usage, to an interactive "fun box" for my grandson. Mainly Wemos D1.

Jackill
Normal user
Posts: 5
Joined: 10 Jan 2019, 08:38

Re: Variables for use in rules??

#6 Post by Jackill » 11 Jan 2019, 14:44

grovkillen wrote:
11 Jan 2019, 05:35
I'm doing my best but need to work on my daytime job too.
Shure. This is not even discussed, daytime job on first place.
Nevertheless, system variables can save much.
Face this when I had to do calculations for my solar heating system.
Code like this: "if [Boiler#Temp]<[Solar#Temp]+5 <do smthng> endif" not worked, it need to be passed thru dummy (taskValueSet).
Now I'll save 1 of 12 tasks.
Domosapiens wrote:
11 Jan 2019, 10:06
While reading the forum, I collect snippets of Rules as examples in a document.
Good practice! I will put into service.

bastibasti
Normal user
Posts: 22
Joined: 31 Jul 2018, 11:41

Re: Variables for use in rules??

#7 Post by bastibasti » 14 Jan 2019, 12:11

any idea how to increment a value?

let 1,%v1%+1??

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

Re: Variables for use in rules??

#8 Post by grovkillen » 14 Jan 2019, 13:45

Code: Select all

Let,1,[VAR#1]+1
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:

Post Reply

Who is online

Users browsing this forum: enesbcs and 2 guests