Timer Rule in ESPeasy

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
technotools
Normal user
Posts: 11
Joined: 10 Oct 2016, 00:45

Timer Rule in ESPeasy

#1 Post by technotools » 19 Nov 2016, 15:52

everytime ESPeasy boot i need GPIO0 remain to state 1 for 30 seconds and then come back to 0.
if during the timer GPIO 2 and/or gpio 1 are set to 1... Timer restart.

Anyone can help me?

technotools
Normal user
Posts: 11
Joined: 10 Oct 2016, 00:45

Re: Timer Rule in ESPeasy

#2 Post by technotools » 19 Nov 2016, 16:37

update... i successfully create the timer rule but i still cannot reset the timer everytime the gpio1 and 2 goes to 1

On System#Boot do
gpio,0,1
timerSet,1,50
endon
On Rules#Timer=1 do
gpio,0,0
endon

StephenF
Normal user
Posts: 13
Joined: 31 May 2016, 23:34

Re: Timer Rule in ESPeasy

#3 Post by StephenF » 22 Nov 2016, 21:17

I am not sure if I understand your problem, but maybe you can try something like this:
1. Create a Dummy device (e.g. Dummy#TimerSet on e.g. Task 1, value 1)
2. Assign your GPIO inputs to a device, like a switch (e.g. Input1#Switch, Input2#Switch)

On System#Boot do
gpio,0,1
timerSet,1,50
TaskValueSet 1,1,1 // set a flag on the Dummy device indicating that your timer is active
endon

On Rules#Timer=1 do
gpio,0,0
TaskValueSet 1,1,0 // reset the timer flag
endon

On Input1#Switch=1 do
if [Dummy#TimerSet] = 1 // checking the flag to see if the timer is still running
timerSet,1,50 // if the timer is running, reset the timer again to 50... or did you want to cancel the timer...?
endif
endon

On Input2#Switch=1 do
if [Dummy#TimerSet] = 1 // checking the flag to see if the timer is still running
timerSet,1,50
endif
endon

----------------

if you wanted to actually cancel the timer, then you will need to place a check (if) in the On Rules#Timer routine.. so just rearranging this concept.

Not sure if it works this way, but you are welcome to try.

technotools
Normal user
Posts: 11
Joined: 10 Oct 2016, 00:45

Re: Timer Rule in ESPeasy

#4 Post by technotools » 26 Nov 2016, 01:54

hi.. not working.. maybe the logic of the rule is wrong...

tryng to write a rule...

Until Switch#PIR (gpio2) or/and Switch#contact(gpio5) are to 1 mantain GPIO0 = 1...
Wait until twice PIR and contact are 0

wait 5 Seconds
gpio = 0

but can i do multiple condition in the if... or use while command?

BertB
Normal user
Posts: 1049
Joined: 25 Apr 2015, 14:39

Re: Timer Rule in ESPeasy

#5 Post by BertB » 26 Nov 2016, 16:26

Something like this?
Is there a reason to remember the fact that the timer runs?

1. Assign your GPIO inputs to a device, like a switch (e.g. Input1#Switch, Input2#Switch)

On System#Boot do
gpio,0,1
timerSet,1,50
endon

On Rules#Timer=1 do
gpio,0,0
endon

On Input1#Switch=1 do
timerSet,1,50 // if the timer is running, reset the timer again to 50... or did you want to cancel the timer...?
endon

On Input2#Switch=1 do
timerSet,1,50
endon

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Semrush [Bot] and 29 guests