Clock#time in a rule

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Dick60
Normal user
Posts: 243
Joined: 11 Feb 2018, 17:35
Location: The Netherlands

Clock#time in a rule

#1 Post by Dick60 » 02 Jul 2021, 12:24

I am strugling to get this rule operational. I use the latest firmware on my Nodemcu. At this moment this rule execute on time, defined in the rule but doesn't take notice on the "Holiday#State]=1" option. How can I fix that?

On Clock#Time=All,**:** do // every day at **:** hours do
If [Holiday#State]=1 and %systime%=10:27 or %systime%=10:28
GPIO,12,0
timerset,1,30
endif
endon

On Rules#Timer=1 do
GPIO,12,1
endon

User avatar
Ath
Normal user
Posts: 3494
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Clock#time in a rule

#2 Post by Ath » 02 Jul 2021, 13:12

I think the combination of 'and' and 'or' in a single condition is causing you trouble, and also the %systime% variable can not be compared like that

To be sure, you'd better code it like this:

Code: Select all

On Clock#Time=All,**:** do // every day at **:** hours do
  If [Holiday#State]=1 and %syssec_d%>=37620 and %syssec_d%<=37680 // 10:27 = 10*3600 + 27*60 = 37620, 10:28 = 37680
    GPIO,12,0
    timerset,1,30
  endif
endon

On Rules#Timer=1 do
  GPIO,12,1
endon
/Ton (PayPal.me)

Dick60
Normal user
Posts: 243
Joined: 11 Feb 2018, 17:35
Location: The Netherlands

Re: Clock#time in a rule

#3 Post by Dick60 » 02 Jul 2021, 13:53

Thanks foor the reply but what I wanted is that I have 2 moments in time, say 13:00 and 17:00. On those moments I want to start the timer but only is the Holiday switch is active and if not active, It will not start the timer.

User avatar
Ath
Normal user
Posts: 3494
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Clock#time in a rule

#4 Post by Ath » 02 Jul 2021, 14:42

Dick60 wrote: 02 Jul 2021, 13:53 Thanks foor the reply but what I wanted is that I have 2 moments in time, say 13:00 and 17:00. On those moments I want to start the timer but only is the Holiday switch is active and if not active, It will not start the timer.

Code: Select all

On Clock#Time=All,**:** do // every day at **:** hours do
  If [Holiday#State]=1
    if %syssec_d%=37620 or %syssec_d%=37680 // 10:27 = 10*3600 + 27*60 = 37620, 10:28 = 37680
      GPIO,12,0
      timerset,1,30
    endif
  endif
endon

On Rules#Timer=1 do
  GPIO,12,1
endon
You will have to calculate the %syssec_d% value for the times you need
Another solution could be:

Code: Select all

On Clock#Time=All,13:00 do // every day at **:** hours do
  asyncevent,checkHolidayState
endon

On Clock#Time=All,17:00 do // every day at **:** hours do
  asyncevent,checkHolidayState
endon

on checkHolidayState do
  If [Holiday#State]=1
    GPIO,12,0
    timerset,1,30
  endif
endon

On Rules#Timer=1 do
  GPIO,12,1
endon
/Ton (PayPal.me)

Dick60
Normal user
Posts: 243
Joined: 11 Feb 2018, 17:35
Location: The Netherlands

Re: Clock#time in a rule

#5 Post by Dick60 » 02 Jul 2021, 16:07

both solutions are working so I can make a selection. Thanks for the support

Post Reply

Who is online

Users browsing this forum: No registered users and 87 guests