Time interval relay rules

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
mickutz
New user
Posts: 1
Joined: 31 Aug 2018, 00:12

Time interval relay rules

#1 Post by mickutz » 31 Aug 2018, 00:27

Hello everyone,
I've been struggling to go forward on my project for a week now.
My intention is to automate a set of lights so that they turn on automatically before sunset and switch off later in the evening, come on during the night on PIR activity only and then come back on early in the morning, then switch off after sunrise.

The Sonoff board is flashed and working, PIR attached and working, however, I just can't find a way to do all of the above via rules.

The idea is that if the board loses power for some reason, I would like it to check the time and take the appropriate action. I don't understand what trigger I should use instead of Relay#Switch=0 to trigger the action as Time#Clock does not work with greater than - lower than.

Any help would be appreciated.

Code: Select all

on Time#Initialized do
	gpio, 12, 0  //Board connected to wifi and time initialised
endon

on Relay#Switch=0 do
	if %systm_hm% > %sunset-20m% and %systm_hm% < 20:30
		gpio, 12, 1
	endif
endon

on Clock#Time=All,20:31 do
	gpio, 12, 0
endon

//Following code is working	
on PIR#Switch=1 do
	if %systm_hm% > 20:31:00  and %systm_hm% < 23:00:00
		gpio, 12, 1
		timerSet,2,30
	endif
endon

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

Re: Time interval relay rules

#2 Post by grovkillen » 31 Aug 2018, 06:20

You should do complicated rules with the unit hooked up to serial och using a log server. Bump the log level to debug and see how the rules are processed.
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:

Post Reply

Who is online

Users browsing this forum: No registered users and 34 guests