bledad wrote: ↑29 Nov 2020, 14:17
Code: Select all
On Clock#Time=All,**:** do
if %systime% > 07:30:00
Let,1,1
event RelayOn
endif
if %systime% > 19:30:00
Let,1,0
event RelayOff
endif
endon
with my english I need to understand the meaning of "On do"
The On ... Do construct are the events that are fired by the system when appropriate, read all about the standard events here:
https://espeasy.readthedocs.io/en/lates ... vents.html
Your current code will turn on the lights every minute, even if the LDR says it's light enough, so you should probably change this part:
The %systime% values aren't parsed correctly for comparison, so the %syssec_d% should be used
Code: Select all
On Clock#Time=All,**:** do
if %syssec_d% > 27000 and %syssec_d% < 70200
Let,1,1
else
Let,1,0
endif
endon
Every time the value for the LDR changes, an event is fired and handled by the 'on Ldr#Analog do' event handler. If the condition meets then the relay will be switched on there.
Maybe you would want to build in a little hysteresis, to avoid the relay/light flipping on/off if the LDR value is just fluctuating on/off 840, it would then be something like this:
Code: Select all
On Ldr#Analog do
if [Ldr#Analog] > 842 and %v1% = 1
event RelayOff
endif
if [Ldr#Analog] < 838 and %v1% = 1
event RelayOn
endif
endon
edit: Fixed %systime% to %syssec_d%