Timer not correct

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
pascalbianca
New user
Posts: 4
Joined: 10 Apr 2020, 18:31

Timer not correct

#1 Post by pascalbianca » 11 Apr 2020, 17:54

Hello everyone,

I have this in my rules1.txt

Code: Select all

On System#Boot do
 gpio,12,0    //esp test test 1=aan 0 = uit 
 mcpgpio, 6,0 //MCP23017 test 1=aan 0 = uit 
 let,1,0
 let,2,0
 timerSet,1,5 //Set Timer 1 for the next event in 5 seconds
 timerSet,2,1 //Set Timer 2 for the next event in 2 seconds
endon

On Rules#Timer=1 do
 timerSet,1,5 //Set Timer 1 for the next event in 5 seconds
 if [VAR#1]=1
   let,1,0
   gpio,12,0
  else 
   let,1,1
   gpio,12,1
 endif
endon

On Rules#Timer=2 do
timerSet,2,1 //Set Timer 2 for the next event in 2 seconds
 if [VAR#1]=1
   let,2,0
  mcpgpio, 6,0
  else 
   let,2,1
   mcpgpio, 6,1
 endif
endon
But for some reason , i think my mistake , the timers are not working correct.
The first goes on and then after 5 seconds of, then led 2 on MCP23017 for 2 seconds and the loop.
But the timer of MCP23017 should normal blink faster then the timer 1.

is that normal or do i have i fould in my code?

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

Re: Timer not correct

#2 Post by ThomasB » 11 Apr 2020, 21:29

In the Rules#Timer 2 event you are setting var #2, but testing var #1.

I think you want this:

Code: Select all

On Rules#Timer=2 do
timerSet,2,1 //Set Timer 2 for the next event in 2 seconds
 if [VAR#2]=1
   let,2,0
  mcpgpio, 6,0
  else 
   let,2,1
   mcpgpio, 6,1
 endif
endon
- Thomas

pascalbianca
New user
Posts: 4
Joined: 10 Apr 2020, 18:31

Re: Timer not correct

#3 Post by pascalbianca » 11 Apr 2020, 21:50

Thanks that's it. : :D

pascalbianca
New user
Posts: 4
Joined: 10 Apr 2020, 18:31

Re: Timer not correct

#4 Post by pascalbianca » 13 Apr 2020, 15:20

Small question so i can understand it correct.

Let means.:
internal class
Set the value of n (1..16).
Let,<n>,<value>

But is Let a part of the timer or what is it exactly?
I tryed it in the timer to leave it away, but then the timer dos'nt do anything.

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

Re: Timer not correct

#5 Post by TD-er » 13 Apr 2020, 16:29

See the documentation: https://espeasy.readthedocs.io/en/lates ... task-names
With the command "let" you can set an internal variable to a certain value.

What the current values of your system are, can be seen on the system variables page of the web interface. (tools => System variables)
These values can be set and read using rules, but the variables can also be used in any place where you can refer to system variables (e.g. in publish topics of controllers, and many many other places)
One difference between these variables and a dummy task is that you loose their content after a reboot.

Post Reply

Who is online

Users browsing this forum: No registered users and 37 guests