Rule for LUX combined with CLOCK

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
duelago
Normal user
Posts: 8
Joined: 13 Aug 2017, 10:41

Rule for LUX combined with CLOCK

#1 Post by duelago » 02 Nov 2019, 20:38

Hello gurus,

I just bought myself an electric candlestick and I want to control it with a LUX sensor and a relay. The hardware is working and ESP Easy is up and running.
I basically want a rule that turns the relay on if it's dark and off if its daylight. However, how can I make sure that the relay is also off when I'm sleeping?

I can't figure out the syntax, but I want a rule like this:

If clock is between 06:00 and 22:30 and it is dark turn the relay on
If it is daylight, turn the relay off
If clock is between 22:30 and 06:00 turn the relay off

(My device is called lux#value and the relay turns on with gpio,12,1)

Any advice? :D

Best regards,
/David

duelago
Normal user
Posts: 8
Joined: 13 Aug 2017, 10:41

Re: Rule for LUX combined with CLOCK

#2 Post by duelago » 03 Nov 2019, 09:27

Think I solved it.
Used a dummy device to disable the lux sensor when I'm sleeping during the night.
Added 'Setpoint' so I can trigger the dummy manually via http

Code: Select all

on Setpoint do
  TaskValueSet 2,1,%eventvalue%
endon

On Clock#Time=All,06:00 do 
Taskvalueset,2,1,1
Endon

On Clock#Time=Sat,22:30 do 
Taskvalueset,2,1,0
Endon


on lux#value<10 do
if [candlestick#dummy]=1
  GPIO,12,1
 else
  GPIO,12,0

endif
endon

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

Re: Rule for LUX combined with CLOCK

#3 Post by TD-er » 03 Nov 2019, 12:27

You can also use the sunrise and sunset calculations in rules.
For this you have to enter the GPS coordinates in the Advanced Settings. (do not have to be very accurate)

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests