IFs and %syshour% issue

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
DimOkIdE
Normal user
Posts: 15
Joined: 13 Oct 2018, 19:46

IFs and %syshour% issue

#1 Post by DimOkIdE » 13 Oct 2018, 20:02

Hi there.

I'm using the following rule on mega-20180104:

Code: Select all

On System#Boot do
	If %systime% < 05:00:00
		GPIO,13,0
		GPIO,14,0
		timerSet,7,240
	Endif
	If %systime% > 05:00:00
		timerSet,7,0
		timerSet,8,0
		timerSet,3,5
		timerSet,4,15
	Endif
	If %systime% > 21:00:00
		GPIO,13,0
		GPIO,14,0
		timerSet,7,240
	Endif
endon

...

//ON timers
on Rules#Timer=1 do
	GPIO,0,1
endon
on Rules#Timer=2 do
	GPIO,13,1
endon
on Rules#Timer=3 do
	GPIO,12,1
endon
on Rules#Timer=4 do
	GPIO,14,1
endon

//OFF timers
on Rules#Timer=5 do
	GPIO,0,0
endon
on Rules#Timer=6 do
	GPIO,13,0
endon
on Rules#Timer=7 do
	GPIO,12,0
endon
on Rules#Timer=8 do
	GPIO,14,0
endon
and it's working like a charm (turns on/off relays on their pins correctly).

Right now I'd like to update the SW version to the latest (mega-20181011) and trying to use the following rule:

Code: Select all

On System#Boot do
	If %syshour% < 05 or %syshour% > 21
		GPIO,13,0
		GPIO,14,0
		timerSet,7,240
	else
		timerSet,7,0
		timerSet,8,0
                timerSet,3,5
		timerSet,4,15
	Endif
endon

//ON timers
on Rules#Timer=1 do
	GPIO,0,1
endon
on Rules#Timer=2 do
	GPIO,13,1
endon
on Rules#Timer=3 do
	GPIO,12,1
endon
on Rules#Timer=4 do
	GPIO,14,1
endon

//OFF timers
on Rules#Timer=5 do
	GPIO,0,0
endon
on Rules#Timer=6 do
	GPIO,13,0
endon
on Rules#Timer=7 do
	GPIO,12,0
endon
on Rules#Timer=8 do
	GPIO,14,0
endon
As I've understood, the %systime% is not working right now (not float) so I've replaced it with the %syshour%. I've also replaced several IFs with logic+else.

But it doesn't works :( The gpios remain 0 no matter what time is it now.

It seems like the problem with the IF inside System#Boot or with %syshour%.

Could anybody help me with this please?

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

Re: IFs and %syshour% issue

#2 Post by grovkillen » 13 Oct 2018, 20:15

It's not working because the event System#Boot is only happening once.

Try this:

Code: Select all

on Clock#Time do
 If %syshour% < 05 or %syshour% > 21
  GPIO,13,0
  GPIO,14,0
  timerSet,7,240
 else
  timerSet,7,0
  timerSet,8,0
  timerSet,3,5
  timerSet,4,15
 Endif
 endon
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:

DimOkIdE
Normal user
Posts: 15
Joined: 13 Oct 2018, 19:46

Re: IFs and %syshour% issue

#3 Post by DimOkIdE » 13 Oct 2018, 20:56

grovkillen, thanks for a such quick reply!
grovkillen wrote: 13 Oct 2018, 20:15 It's not working because the event System#Boot is only happening once.
Actually, it supposed to fire only once (when the ESP boots) to check the current time and disable/enable gpios depending on the time range.
As I've inderstood - the System#Boot is the right place where to put these conditions?

In the earlier versions of FW it worked. And now it's logic was changed?

If I put the simple IF (without %syshour%) - it works:

Code: Select all

On System#Boot do
	GPIO,12,1
	if [Relay4#Switch]=0
		GPIO,13,1
	endif
endon
grovkillen wrote: 13 Oct 2018, 20:15 Try this:

Code: Select all

on Clock#Time do
It works but it fires every minute:

Code: Select all

403333: EVENT: Clock#Time=Sat,21:48
403354: ACT : timerSet,7,0
403368: ACT : timerSet,8,0
403381: ACT : timerSet,3,35
403394: ACT : timerSet,4,55
403454: Command: timerset
403455: Command: timerset
403455: Command: timerset
403455: Command: timerset
But I need it to fire once on startup. And then I have several rules on dummy buttons.

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

Re: IFs and %syshour% issue

#4 Post by grovkillen » 13 Oct 2018, 21:07

Then you should use the Time#Initialized event.

https://www.letscontrolit.com/wiki/inde ... .29_events

We have made the boot sequence more stable and now the boot event is triggered on actual boot. Thus we needed a time initialized event.
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:

DimOkIdE
Normal user
Posts: 15
Joined: 13 Oct 2018, 19:46

Re: IFs and %syshour% issue

#5 Post by DimOkIdE » 13 Oct 2018, 21:22

Oh, intersting.

Trying:

Code: Select all

On Time#Initialized do  
	If %syshour% > 12 and %syshour% < 23
		timerSet,7,0
		timerSet,8,0
		timerSet,3,85
		timerSet,4,95
	Endif
endon
Doesn't work.

Found the similar topic here (http://www.letscontrolit.com/forum/view ... zed#p31376). Modified to:

Code: Select all

On Time#Initialized do
	event checkRelays
endon

on checkRelays do
	If %syshour% > 12 and %syshour% < 23
		timerSet,7,0
		timerSet,8,0
		timerSet,3,85
		timerSet,4,95
	Endif
endon
And it really works :)

grovkillen, thank you greatly! I think this will be enough for me on this stage because it really fires only once.

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

Re: IFs and %syshour% issue

#6 Post by grovkillen » 13 Oct 2018, 22:31

Your first example might actually happen before the %syshour% is populated. Maybe we should add a issue for that?
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:

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

Re: IFs and %syshour% issue

#7 Post by TD-er » 13 Oct 2018, 23:10

It should be fixed with this pull request: https://github.com/letscontrolit/ESPEasy/pull/1900
I will merge it as soon as possible.

Post Reply

Who is online

Users browsing this forum: No registered users and 34 guests