ESPEasy timer switch

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Brainfree
New user
Posts: 2
Joined: 30 Jan 2017, 15:30

ESPEasy timer switch

#1 Post by Brainfree » 30 Jan 2017, 15:45

Good day, dear friends, please kindly assist with rule for my device ( aquarium controller with temp sensor and timer switch for lighting)

in tutorial rules I find following example for timer switch, but I think it can work incorrectly


On Clock#Time=All,7:30 do // every day at 7:30 hours switch on relay on gpio 13
gpio,13,0
endon

On Clock#Time=All,22:00 do // every day at 22:00 hours switch off relay on gpio 13
gpio,13,0
endon

how device will work if it will be reboot in 14:00? i think GPIO state may be changed to default in this case.

is rule " if Clock#Time >7:00 and <22:00 then gpio,13,0" ? what is correct syntax for this case?

PS is firmware allow me to display on LCD relay(gpio) status as variable?
Now i make is as displaying status of input device and it displayed as "relay1: 1 or 0" on LCD
Can it be changed to "relay1: on/off" ?

thanks.

5ko
Normal user
Posts: 33
Joined: 03 Jan 2016, 17:58
Contact:

Re: ESPEasy timer switch

#2 Post by 5ko » 11 Feb 2017, 16:54

Hi to all,
the same question ? Some help.
Thanks

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: ESPEasy timer switch

#3 Post by toffel969 » 11 Feb 2017, 17:41

maybe try espmega, it has the feature to keep gpio states on reboot (not power off though).it also has an extended timer menu
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

User avatar
ManS-H
Normal user
Posts: 281
Joined: 27 Dec 2015, 11:26
Location: the Netherlands

Re: ESPEasy timer switch

#4 Post by ManS-H » 11 Feb 2017, 17:54

Brainfree wrote:Good day, dear friends, please kindly assist with rule for my device ( aquarium controller with temp sensor and timer switch for lighting)

in tutorial rules I find following example for timer switch, but I think it can work incorrectly


On Clock#Time=All,7:30 do // every day at 7:30 hours switch on relay on gpio 13
gpio,13,0
endon

On Clock#Time=All,22:00 do // every day at 22:00 hours switch off relay on gpio 13
gpio,13,0
endon

how device will work if it will be reboot in 14:00? i think GPIO state may be changed to default in this case.

is rule " if Clock#Time >7:00 and <22:00 then gpio,13,0" ? what is correct syntax for this case?

PS is firmware allow me to display on LCD relay(gpio) status as variable?
Now i make is as displaying status of input device and it displayed as "relay1: 1 or 0" on LCD
Can it be changed to "relay1: on/off" ?

thanks.
I use this for my toilet window, maybe this is a idea for you:

on wcraam-open do
gpio,0,0 // relay on
timerSet 1,2 // 2 seconds timer
endon

on Rules#Timer=1 do
gpio,0,1 // relay off
endon

on wcraam-dicht do
gpio,16,0 // relay on
timerSet 2,2 // 2 seconds timer
endon

on Rules#Timer=2 do
gpio,16,1 // relay off
endon

paxi
Normal user
Posts: 121
Joined: 02 Feb 2017, 00:48
Location: Germany

Re: ESPEasy timer switch

#5 Post by paxi » 13 Feb 2017, 01:09

Brainfree wrote:...
how device will work if it will be reboot in 14:00? i think GPIO state may be changed to default in this case.

is rule " if Clock#Time >7:00 and <22:00 then gpio,13,0" ? what is correct syntax for this case?

...
The clock#time event seems to work only with "=".
I solved a similar problem like this (in addition to the clock#time rules):

Code: Select all

on System#Boot do //delay 5 seconds to get the time
    timerSet,1,5
endon

on Rules#Timer=1 do
    if %systime% > 7:59 
        //do something (on) 
    endif
    if %systime% > 19:59
        //do something else (off) 
    endif
endon
Since the rules engine does not allow boolean logic or nesting of if-statements this will trigger the output for some microseconds if the reboot occurs after the "switch-off-time" but I don't think that's long enough to actually close the relay.

Brainfree
New user
Posts: 2
Joined: 30 Jan 2017, 15:30

Re: ESPEasy timer switch

#6 Post by Brainfree » 13 Feb 2017, 12:18

Dear Paxi, many thanks for assistance,

As i undestand code will work as following (for example for 20:00)

after boot, system will check current time every 5 seconds and compare will below terms

on Rules#Timer=1 do
if %systime% > 7:59
//do something (on)
endif

// this part will check 20:00>7:00, YES, so ESP will do something (on), and will check next condition

if %systime% > 19:59
//do something else (off)
endif

// here it will check 20:00>19:59, YES, so ESP will do something (off)
endon
//end of cycle

did relay will blink every 5 seconds after 19:59 because both of terms will be complied.

paxi
Normal user
Posts: 121
Joined: 02 Feb 2017, 00:48
Location: Germany

Re: ESPEasy timer switch

#7 Post by paxi » 13 Feb 2017, 20:54

No, there is no cycle - the system#boot event is only triggered once. Thus the rules#timer part runs only once, too - 5 seconds after booting is completed.

Here is a reworked code snippet that avoids the flickering:

Code: Select all

on System#Boot do
    timerSet,1,5
endon

on Rules#Timer=1 do
    if %systime% < 8:00
        (off) 
    else
        event checkdaytime
    endif
endon

on checkdaytime do
    if %systime% > 19:59
        (off) 
    else
        (on) 
    endif
endon
If you set the boot state of your pin to "output low" it can be simplified to:

Code: Select all

on System#Boot do
    timerSet,1,5
endon

on Rules#Timer=1 do
    if %systime% > 7:59
        event checkdaytime
    endif
endon

on checkdaytime do
    if %systime% < 20:00
        (on) 
    endif
endon

Post Reply

Who is online

Users browsing this forum: No registered users and 128 guests