Relay daily timer - reboot handle?

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
spachal
Normal user
Posts: 55
Joined: 22 Feb 2018, 22:11

Relay daily timer - reboot handle?

#1 Post by spachal » 11 Mar 2018, 18:05

Hallo, I need to keep one of my relays, connected to ESP8266, switch on and off every day, at the same time interval.
So far, it's easy to do so by rules. Relay is defined as switch input device, but I'm controlling it directly via GPIO (GPIO13 in this case):

Code: Select all

On Clock#Time=All,09:00 do 
  Gpio,13,1
Endon

On Clock#Time=All,15:30 do 
  Gpio,13,0
Endon
But I need to handle the situation, when ESP could be rebooted between 9:00-15:30 for any reason. In this case, the relay will stay off == problem.
I found this solution, that could handle this reboot, but it's not ideal. It 'takes' one of system timers and could cause very short on/off switch of relay, that is not 'healthy' for connected AC device ..

Code: Select all

On System#Boot do
  TimerSet,6,1  // timer for relay02
Endon

On Clock#Time=All,09:00 do 
  Gpio,13,1
Endon

On Clock#Time=All,15:30 do 
  Gpio,13,0
Endon

On Rules#Timer=6 do
  If %systime% < 09:00:00
    Gpio,13,0
  Else
    Gpio,13,1
  Endif
  If %systime% > 15:30:00
    Gpio,13,0
  Endif 
Endon
It's a pity that we can't use boolean logic or nested if-if conditions .. Is there any 'more elegant' solution how to handle relay timer for any accidental reboot of controller?
Thanks for help! :]
Please excuse my English, thanks!

papperone
Normal user
Posts: 497
Joined: 04 Oct 2016, 23:16

Re: Relay daily timer - reboot handle?

#2 Post by papperone » 11 Mar 2018, 19:48

I think the AND / OR boolean have been introduced recently so you can certainly use them:

Code: Select all

On System#Boot do
  If %systime% > 09:00:00 and %systime% < 15:30:00
    Gpio,13,1
  Else
    Gpio,13,0
  Endif
Endon
My TINDIE Store where you can find all ESP8266 boards I manufacture --> https://www.tindie.com/stores/GiovanniCas/
My Wiki Project page with self-made PCB/devices --> https://www.letscontrolit.com/wiki/inde ... :Papperone

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

Re: Relay daily timer - reboot handle?

#3 Post by grovkillen » 11 Mar 2018, 22:22

Yep, not yet documented. Sorry :oops: ;)
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:

spachal
Normal user
Posts: 55
Joined: 22 Feb 2018, 22:11

Re: Relay daily timer - reboot handle?

#4 Post by spachal » 12 Mar 2018, 10:04

papperone wrote: 11 Mar 2018, 19:48 I think the AND / OR boolean have been introduced recently so you can certainly use them:
PERFECT, that's exactly what I need, it helps a lot, thanks!! :]
Please excuse my English, thanks!

Post Reply

Who is online

Users browsing this forum: No registered users and 34 guests