Problem with %unixday%

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Micha_he
Normal user
Posts: 372
Joined: 07 Feb 2018, 19:14
Location: Helmstedt, Germany

Problem with %unixday%

#1 Post by Micha_he » 12 Mar 2021, 09:53

I've a problem with the following rule. The event isn't executed:

Code: Select all

on System#Boot do
  Let,1,18698 // for test today
endon

on Clock#Time=All,06:30 do
  if %unixday%=[INT#1]
    Event, TestEvent
  endif
endon
Firmware is the last official 'hard_other_POW_ESP8285_1M', NTP is set and working, variable 1 is correctly set but the event isn't executed today morning.
Where is my problem ?

User avatar
Ath
Normal user
Posts: 3480
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Problem with %unixday%

#2 Post by Ath » 12 Mar 2021, 10:48

Has the event System#Boot been executed? Or have you added that without the device being restarted?
/Ton (PayPal.me)

Micha_he
Normal user
Posts: 372
Joined: 07 Feb 2018, 19:14
Location: Helmstedt, Germany

Re: Problem with %unixday%

#3 Post by Micha_he » 12 Mar 2021, 11:42

Yes, I checked the content of INT#1 (resp. %v1%). It's correct.

User avatar
Ath
Normal user
Posts: 3480
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Problem with %unixday%

#4 Post by Ath » 12 Mar 2021, 12:21

Tested this code on an older release (don't have access to an ESP with the latest release while at work :oops:)

Code: Select all

on Clock#Time=All,**:** do
  let,1,%unixday%
  LogEntry,"Unixday: %unixday%"
  if %unixday%=[INT#1]
    LogEntry,"Unixday matched"
  else
    LogEntry,"Unixday NOT matched"
  endif
endon
And that works as expected ;)
/Ton (PayPal.me)

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

Re: Problem with %unixday%

#5 Post by TD-er » 12 Mar 2021, 12:44

The problem may be that you try to match on an exact second and the moment an event is fired may not be exactly on the minute (and thus an exact multiple of 60 seconds)
On top of that without needing the calculator, I can see that 18698 isn't a multiple of 60 and the Clock#Time event is only fired every minute (or at least scheduled to be processed at that interval).

Micha_he
Normal user
Posts: 372
Joined: 07 Feb 2018, 19:14
Location: Helmstedt, Germany

Re: Problem with %unixday%

#6 Post by Micha_he » 12 Mar 2021, 13:01

:?: :roll: Isn't %unixday% the DAYS since 01.01.1970 ???

Why multiple from 60 ? The number should be the same since all the day, or?

I will continue tests at the weekend, then on another ESP with more memory so I can see log-entries.

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

Re: Problem with %unixday%

#7 Post by TD-er » 12 Mar 2021, 13:28

Sorry, you're absolutely right.
As can be seen on the system variables page:

Code: Select all

System
%uptime%	10
%unixtime%	1615551732
%unixday%	18698
%unixday_sec%	44532
%sunset%	19:13
%sunset-1h%	18:13
%sunrise%	7:06
%sunrise+10m%	7:16
I was confusing it with %unixday_sec%

But this also means I don't have a clue to why your check does not work.

You may try to write the value of %unixday% to a log, or to a MQTT topic, or a display to check if it is showing the correct value.

Micha_he
Normal user
Posts: 372
Joined: 07 Feb 2018, 19:14
Location: Helmstedt, Germany

Re: Problem with %unixday%

#8 Post by Micha_he » 16 Mar 2021, 13:47

The if-comparison seems to work. The problem was a reboot shortly after the Clock#Time-event.
And that reset the gpio-output. All test over the last days, are worked.

Post Reply

Who is online

Users browsing this forum: No registered users and 18 guests