Rule for LUX combined with CLOCK

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
duelago
New user
Posts: 9
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
New user
Posts: 9
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: 8643
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)

mlazarov
New user
Posts: 4
Joined: 01 Mar 2020, 09:35
Location: Bulgaria

Re: Rule for LUX combined with CLOCK

#4 Post by mlazarov » 13 Mar 2020, 09:17

Here is my solution for turning the backyard light on and off without an LDR sensor using sunset and sunrise features with up-to-date startup checking. I use ESP-1s relay

Code: Select all

on Time#Initialized do
GPIO,0,0
timerSet,1,5
endon

On Rules#Timer=1 do
   If  %systm_hm% > %sunset+25m%
    Gpio,0,1
    timerSet,1,0
   else
    timerSet,2,1
   Endif
endon

On Rules#Timer=2 do
   If  %systm_hm% < %sunrise-25m%
    Gpio,0,1
    timerSet,2,0
   else
    timerSet,3,1
   Endif
endon

On Rules#Timer=3 do
   If %systm_hm% > %sunrise-25m%
    Gpio,0,0
    timerSet,4,1
   else
    timerSet,1,1
   Endif
endon

On Rules#Timer=4 do
   If %systm_hm% < %sunset+25m%
    Gpio,0,0
    timerSet,4,0
   else
    timerSet,1,1
   Endif
endon

On Clock#Time=All,%sunrise-25m% do
    Gpio,0,0
endon

On Clock#Time=All,%sunset+25m% do
    Gpio,0,1
endon

Post Reply

Who is online

Users browsing this forum: No registered users and 17 guests