Page 1 of 1

Manually set date and time for testing

Posted: 16 Aug 2019, 10:14
by cybermaus
So I am building a ESPEasy timer, very simple evening and morning light on.
And I believe I do have it working nicely (see below)

But testing is a bit hard. I have to either wait till sunset/sunrise rolls around (so 2 test per day) or modify the code to temporary read %sunset+2h51% to match the next few %systime% minutes.
Not ideal to test code when using different code.
Tried tweaking timezone UTC-offset in such a way the %sunrise% is about to roll past, but that also does not work, as %sunrise% is modded along with %systime%


Is there any way to set the system time directly?
I can turn of NTP, but how to set the time?


For reference: my rules:

Code: Select all

on Time#Initialized do
  event,Clock#Time=Recalc
endon

on Clock#Time=All,06:00 do
  event,Clock#Time=Recalc
endon

on Clock#Time=All,%sunrise-15m% do
    GPIO,12,0
endon

on Clock#Time=All,%sunset+15m% do
  event,Clock#Time=Recalc
endon

on Clock#Time=All,23:00 do
    GPIO,12,0
endon

on Clock#Time=Recalc do
  if %systime%>=23:00 or %systime%<06:00
    GPIO,12,0
  endif
  if %systime%>=06:00 and %systime%<%sunrise-15m% 
    GPIO,12,1
  endif
  if %systime%>=%sunrise-15m% and %systime%<%sunset+15m% 
    GPIO,12,0
  endif
  if %systime%>=%sunset+15m% and %systime%<23:00
    GPIO,12,1
  endif
endon

on Clock#Time=Override do
  if %systime%>=%sunset+15m% or %systime%<%sunrise-15m%
    GPIO,12,1
  endif
endon

Re: Manually set date and time for testing

Posted: 16 Aug 2019, 17:23
by grovkillen
You could just test the event that is being triggered, no need to use the clock event for that.

Re: Manually set date and time for testing

Posted: 17 Aug 2019, 21:51
by TD-er
You can tweak the timezone settings to trigger some daily event on another moment during the day.