Manually set date and time for testing

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
cybermaus
Normal user
Posts: 13
Joined: 24 Nov 2016, 11:15

Manually set date and time for testing

#1 Post by cybermaus » 16 Aug 2019, 10:14

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

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

Re: Manually set date and time for testing

#2 Post by grovkillen » 16 Aug 2019, 17:23

You could just test the event that is being triggered, no need to use the clock event for that.
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:

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

Re: Manually set date and time for testing

#3 Post by TD-er » 17 Aug 2019, 21:51

You can tweak the timezone settings to trigger some daily event on another moment during the day.

Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests