Time & Timer Control

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Lonzo
New user
Posts: 7
Joined: 10 Jun 2020, 20:52

Time & Timer Control

#1 Post by Lonzo » 01 Jun 2021, 13:48

Hi, I tried so much, but no good results. What I want is this (in rules):

GPIO x has to switch ON every 20 Minutes for 2 Minutes if systime >10.00 and <22:00
GPIO x has to switch ON every 1 hour for 2 Minutes if systime >22:00 and <10:00

Is anyone able to give me some hints?

Thank you

Lonzo

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

Re: Time & Timer Control

#2 Post by TD-er » 01 Jun 2021, 14:39

See here for a list of events:
https://espeasy.readthedocs.io/en/lates ... tem-events

You want probably act on Time#Initialized
In this example I set 2 timers:
timer 1: turn off and schedule timer 2 based on the system time
timer 2: turn on and schedule timer 1 to turn it off.

Code: Select all

on Time#Initialized do
  timerset,1,120 // Set off timer to 2 minutes
  gpio,2,1  // Turn on GPIO2
endon

on Rules#Timer=1 do
  // Timer to turn off the GPIO
  gpio,2,0 // Turn off GPIO 2  
  let,1,1080 // Set variable 1 to (20 - 2) minutes in seconds
  If %systime% > 10:00:00
    let,1,3480 // Set variable 1 to (60 - 2) minutes in seconds
  endif
  If %systime% > 22:00:00
    let,1,1080 // Set variable 1 to (20 - 2) minutes in seconds
  endif
  
  timerset,2,[int#1] // Set timer 2
endon

on Rules#Timer=2 do
  timerset,1,120 // Set off timer to 2 minutes
  gpio,2,1  // Turn on GPIO2
endon

Lonzo
New user
Posts: 7
Joined: 10 Jun 2020, 20:52

Re: Time & Timer Control

#3 Post by Lonzo » 01 Jun 2021, 15:28

Thank you. I will study and try it.

Lonzo

Lonzo
New user
Posts: 7
Joined: 10 Jun 2020, 20:52

Re: Time & Timer Control

#4 Post by Lonzo » 13 Jun 2021, 17:14

@TD-er: Thank you very much! It works. I had to adjust some parameters and I am happy.

Lonzo

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

Re: Time & Timer Control

#5 Post by TD-er » 13 Jun 2021, 19:26

Great :)

Post Reply

Who is online

Users browsing this forum: No registered users and 29 guests