Need rule systime

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
BuddhaZen
Normal user
Posts: 8
Joined: 07 Apr 2018, 14:23

Need rule systime

#1 Post by BuddhaZen » 05 Aug 2022, 21:30

Hi, a rule is required - if the system time is greater than 23:00 and less than 7:00 then do not enable gpio. I can't understand the syntax correctly. :roll:

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

Re: Need rule systime

#2 Post by TD-er » 05 Aug 2022, 21:38

See the system variables page for all system variables and their current value to get more ideas to use those.
And of course, see the rules documentation page: https://espeasy.readthedocs.io/en/lates ... Rules.html


I think the %syshour% variable is the easiest to use here as you don't need to check the minutes for your request.

Code: Select all

if %syshour% >= 23 or %syshour% <7
  // This is the time window you requested
 
else
  // Time window where the GPIO may be set

endif
N.B. see the >=23 to match 23:00 and later and the <7 to match upto 6:59

BuddhaZen
Normal user
Posts: 8
Joined: 07 Apr 2018, 14:23

Re: Need rule systime

#3 Post by BuddhaZen » 06 Aug 2022, 22:31

the logic is clear, I tried a similar option with %systime% - it did not work. Have you tried your version? is he functional? Are the "On .... do" lines not required here?

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

Re: Need rule systime

#4 Post by TD-er » 06 Aug 2022, 22:54

The on...do lines are for sure needed.
You need to act on an event, and in the on...do line you specify on what event you need to act.

So not sure what else you need or how often (or when) this check needs to be performed.

I assume you need to check it when the time is set (not yet at boot, but when you know the time) and switch the state when you get to the right moment.

Code: Select all

on Time#Set do
  if %syshour% >= 23 or %syshour% <7
    // This is the time window you requested
  
  else
    // Time window where the GPIO may be set

  endif
endon

on Clock#Time=All,23:00 do //will run once a day at 23:00 
  // Do the stuff you need to do
endon

on Clock#Time=All,7:00 do //will run once a day at 7:00 
  // Do the stuff you need to do
endon
Something like this, not tested, just a quick write down.

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests