[userModule] Daylight (updated 2015-07-05)

Tips, Tricks and Scripts to enhance your home automation and workaround known device bugs, limitations and incompatibilities
pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

Re: [userModule] Daylight (updated 2015-02-15)

Post by pz1 » 15 Feb 2015 18:15

It is getting better and better :)

RottenMutt
Posts: 100
Joined: 31 Jan 2015 21:09

Re: [userModule] Daylight (updated 2015-02-15)

Post by RottenMutt » 15 Feb 2015 19:42

It is Daylight!!! woohoo the world isn't going to end, two days without daylight was rough..
fyi, Javascript file says "Version: 0.4.0" still...

[2015-02-15 10:24:04.971] [core] Loading module Daylight from userModules/Daylight
[2015-02-15 10:24:04.988] [core] Executing script: /*** Daylight Z-Way HA module ******************************************* ...
[2015-02-15 10:26:57.529] [core] Instantiating module 20 from class Daylight
[2015-02-15 10:26:57.535] [core] --- Starting module Daylight
[2015-02-15 10:26:57.568] [core] Creating device sensorBinary Daylight20
[2015-02-15 10:26:57.773] [core] Daylight: Schedule update executed
[2015-02-15 10:26:57.787] [core] Daylight: Sunrise in local time: Sun Feb 15 2015 06:19:10 GMT-0600 (CST)
[2015-02-15 10:26:57.788] [core] Daylight: Sunrise in UTC time : Sun, 15 Feb 2015 12:19:10 GMT
[2015-02-15 10:26:57.791] [core] Daylight: Sunrise event scheduled for 6:20
[2015-02-15 10:26:57.798] [core] Daylight: Sunset in local time: Sun Feb 15 2015 19:09:17 GMT-0600 (CST)
[2015-02-15 10:26:57.799] [I] [core] Daylight: Sunset in UTC time : Mon, 16 Feb 2015 01:09:17 GMT
[2015-02-15 10:26:57.800] [I] [core] Daylight: Sunset event scheduled for 19:10
[2015-02-15 10:26:57.809] [I] [core] Daylight: Status update executed
[2015-02-15 10:26:57.810] [I] [core] Daylight: current local time: Sun Feb 15 2015 10:26:57 GMT-0600 (CST)
[2015-02-15 10:26:57.810] [I] [core] Daylight: current UTC time : Sun, 15 Feb 2015 16:26:57 GMT
[2015-02-15 10:26:57.811] [I] [core] Daylight: Sunrise in local time: Sun Feb 15 2015 06:19:10 GMT-0600 (CST)
[2015-02-15 10:26:57.812] [I] [core] Daylight: Sunrise in UTC time : Sun, 15 Feb 2015 12:19:10 GMT
[2015-02-15 10:26:57.813] [I] [core] Daylight: Sunset in local time: Sun Feb 15 2015 19:09:17 GMT-0600 (CST)
[2015-02-15 10:26:57.814] [I] [core] Daylight: Sunset in UTC time : Mon, 16 Feb 2015 01:09:17 GMT
[2015-02-15 10:26:57.815] [I] [core] Daylight: Conclusion is that sensor should be on
[2015-02-15 10:26:57.852] [I] [core] Daylight: Sensor switched to on

THANK YOU

pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

Re: [userModule] Daylight (updated 2015-02-15)

Post by pz1 » 22 Feb 2015 11:02

In the latest rc 14 under notifications there is a new module DeviceMonitor Very usefull for tracking the times that Daylight switches. Results can be read on the HA-UI main screen notifications screen.

Geoff332
Posts: 2
Joined: 06 Feb 2015 23:46

Re: [userModule] Daylight (updated 2015-02-15)

Post by Geoff332 » 27 Feb 2015 00:08

Hi,

I hope this is the right place to post this. I've grabbed this module, put it in my userModules folder and restarted the server. But I can't see the sensor anywhere in the web GUI.

When I look in the logs, the module loads and executes, but the module is never instantiated.

I've just updated my z-way using wget so I assume it's 1.7-last.

Any help would be much appreciated.

--------
EDIT
--------
I updated to z-way 2.0.0 and it is showing now. I guess that answers my question!

pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

Re: [userModule] Daylight (updated 2015-02-15)

Post by pz1 » 06 Mar 2015 10:36

pz1 wrote:In the latest rc 14 under notifications there is a new module DeviceMonitor Very usefull for tracking the times that Daylight switches. Results can be read on the HA-UI main screen notifications screen.
For unknown reasons DeviceMonitor has been removed since rc18

RottenMutt
Posts: 100
Joined: 31 Jan 2015 21:09

Re: [userModule] Daylight (updated 2015-02-15)

Post by RottenMutt » 09 Mar 2015 03:23

I'm in Texas, and we switched to Daylight Savings time this morning, and now my outdoor lights are coming on an hour to early.

[2015-03-08 18:58:00.875] [core] Daylight: Status update executed
[2015-03-08 18:58:00.876] [core] Daylight: current local time: Sun Mar 08 2015 18:58:00 GMT-0500 (CDT)
[2015-03-08 18:58:00.877] [core] Daylight: current UTC time : Sun, 08 Mar 2015 23:58:00 GMT
[2015-03-08 18:58:00.878] [core] Daylight: Sunrise in local time: Sun Mar 08 2015 07:24:46 GMT-0500 (CDT)
[2015-03-08 18:58:00.879] [core] Daylight: Sunrise in UTC time : Sun, 08 Mar 2015 12:24:46 GMT
[2015-03-08 18:58:00.879] [core] Daylight: Sunset in local time: Sun Mar 08 2015 18:57:03 GMT-0500 (CDT)
[2015-03-08 18:58:00.880] [core] Daylight: Sunset in UTC time : Sun, 08 Mar 2015 23:57:03 GMT
[2015-03-08 18:58:00.881] [core] Daylight: Conclusion is that sensor should be off
[2015-03-08 18:58:00.986] [core] Daylight: Sensor switched to off

at 18:58 it should be daylight.

edit:
next day: (I did do a reboot of the Pi after posting and i don't know if that mattered)

~ $ cat /var/log/z-way-server.log | grep Daylight
[2015-03-09 07:25:00.579] [core] Daylight: Status update executed
[2015-03-09 07:25:00.580] [I] [core] Daylight: current local time: Mon Mar 09 2015 07:25:00 GMT-0500 (CDT)
[2015-03-09 07:25:00.580] [I] [core] Daylight: current UTC time : Mon, 09 Mar 2015 12:25:00 GMT
[2015-03-09 07:25:00.581] [I] [core] Daylight: Sunrise in local time: Mon Mar 09 2015 07:23:31 GMT-0500 (CDT)
[2015-03-09 07:25:00.582] [I] [core] Daylight: Sunrise in UTC time : Mon, 09 Mar 2015 12:23:31 GMT
[2015-03-09 07:25:00.583] [I] [core] Daylight: Sunset in local time: Mon Mar 09 2015 19:57:49 GMT-0500 (CDT)
[2015-03-09 07:25:00.584] [I] [core] Daylight: Sunset in UTC time : Tue, 10 Mar 2015 00:57:49 GMT
[2015-03-09 07:25:00.584] [I] [core] Daylight: Conclusion is that sensor should be on
[2015-03-09 07:25:00.716] [I] [core] Daylight: Sensor switched to on

The time is now correct. i wonder if there is a lingering effect the day after the switch.

mhorst
Posts: 27
Joined: 30 Dec 2014 15:10

Re: [userModule] Daylight (updated 2015-03-09)

Post by mhorst » 09 Mar 2015 21:48

There is some kind of bug, but I'm not sure whether it explains the behavior you saw.

At one minute after midnight each night the module computes the new sunrise and sunset times for that day. Unfortunately that is before any change caused by daylight savings time has taken effect. So the sunrise/sunset times will be off by an hour for the first day after a change to/from daylight savings time.

However, at those times the module does a sanity check to see if it really should change the state. So in your case the sunset should be at 18:58 local time if daylight savings was not applied. Then at 18:58 local time the module checks the status and should have come to the conclusion that it is actually an hour early and leave the sensor state untouched. The logging you posted shows, however, that the sensor is switched off.

So I'm not sure what is going on. There is certainly a lingering effect the day after the switch, and I fixed that in version 0.6.0 by re-calculating sunrise and sunset times at 03:01 in the morning, to ensure it is after any change caused by the change in daylight savings.

I'll be changing myself to DST in a few weeks, so I'll keep an eye on whether that solved it.

Otherwise, the change from UTC times from the algorithm to local times for the scheduling is done by the standard libraries on the system, so I'm not sure I can fix that.

RottenMutt
Posts: 100
Joined: 31 Jan 2015 21:09

Re: [userModule] Daylight (updated 2015-03-09)

Post by RottenMutt » 10 Mar 2015 17:14

mhorst wrote:... There is certainly a lingering effect the day after the switch, and I fixed that in version 0.6.0 by re-calculating sunrise and sunset times at 03:01 in the morning, to ensure it is after any change caused by the change in daylight savings...
I would bet a beer that will fix it!!! Thank You..

RottenMutt
Posts: 100
Joined: 31 Jan 2015 21:09

Re: [userModule] Daylight (updated 2015-03-09)

Post by RottenMutt » 11 Mar 2015 05:30

well it my lights didn't turn on tonight!

[2015-03-09 07:25:00.579] [core] Daylight: Status update executed
[2015-03-09 07:25:00.580] [core] Daylight: current local time: Mon Mar 09 2015 07:25:00 GMT-0500 (CDT)
[2015-03-09 07:25:00.580] [core] Daylight: current UTC time : Mon, 09 Mar 2015 12:25:00 GMT
[2015-03-09 07:25:00.581] [core] Daylight: Sunrise in local time: Mon Mar 09 2015 07:23:31 GMT-0500 (CDT)
[2015-03-09 07:25:00.582] [core] Daylight: Sunrise in UTC time : Mon, 09 Mar 2015 12:23:31 GMT
[2015-03-09 07:25:00.583] [core] Daylight: Sunset in local time: Mon Mar 09 2015 19:57:49 GMT-0500 (CDT)
[2015-03-09 07:25:00.584] [core] Daylight: Sunset in UTC time : Tue, 10 Mar 2015 00:57:49 GMT
[2015-03-09 07:25:00.584] [core] Daylight: Conclusion is that sensor should be on
[2015-03-09 07:25:00.716] [core] Daylight: Sensor switched to on
[2015-03-09 19:58:00.448] [core] Daylight: Status update executed
[2015-03-09 19:58:00.449] [I] [core] Daylight: current local time: Mon Mar 09 2015 19:58:00 GMT-0500 (CDT)
[2015-03-09 19:58:00.450] [I] [core] Daylight: current UTC time : Tue, 10 Mar 2015 00:58:00 GMT
[2015-03-09 19:58:00.450] [I] [core] Daylight: Sunrise in local time: Mon Mar 09 2015 07:23:31 GMT-0500 (CDT)
[2015-03-09 19:58:00.451] [I] [core] Daylight: Sunrise in UTC time : Mon, 09 Mar 2015 12:23:31 GMT
[2015-03-09 19:58:00.452] [I] [core] Daylight: Sunset in local time: Mon Mar 09 2015 19:57:49 GMT-0500 (CDT)
[2015-03-09 19:58:00.452] [I] [core] Daylight: Sunset in UTC time : Tue, 10 Mar 2015 00:57:49 GMT
[2015-03-09 19:58:00.453] [I] [core] Daylight: Conclusion is that sensor should be off
[2015-03-09 19:58:00.537] [I] [core] Daylight: Sensor switched to off
[2015-03-10 00:01:00.452] [I] [core] Daylight: Schedule update executed
[2015-03-10 00:01:00.454] [I] [core] Daylight: Sunrise in local time: Tue Mar 10 2015 07:23:31 GMT-0500 (CDT)
[2015-03-10 00:01:00.455] [I] [core] Daylight: Sunrise in UTC time : Tue, 10 Mar 2015 12:23:31 GMT
[2015-03-10 00:01:00.456] [I] [core] Daylight: Sunrise event scheduled for 7:24
[2015-03-10 00:01:00.471] [I] [core] Daylight: Sunset in local time: Tue Mar 10 2015 19:57:49 GMT-0500 (CDT)
[2015-03-10 00:01:00.471] [I] [core] Daylight: Sunset in UTC time : Wed, 11 Mar 2015 00:57:49 GMT
[2015-03-10 00:01:00.472] [I] [core] Daylight: Sunset event scheduled for 19:58
[2015-03-10 00:01:00.487] [I] [core] Daylight: Status update executed
[2015-03-10 00:01:00.488] [I] [core] Daylight: current local time: Tue Mar 10 2015 00:01:00 GMT-0500 (CDT)
[2015-03-10 00:01:00.489] [I] [core] Daylight: current UTC time : Tue, 10 Mar 2015 05:01:00 GMT
[2015-03-10 00:01:00.490] [I] [core] Daylight: Sunrise in local time: Tue Mar 10 2015 07:23:31 GMT-0500 (CDT)
[2015-03-10 00:01:00.491] [I] [core] Daylight: Sunrise in UTC time : Tue, 10 Mar 2015 12:23:31 GMT
[2015-03-10 00:01:00.492] [I] [core] Daylight: Sunset in local time: Tue Mar 10 2015 19:57:49 GMT-0500 (CDT)
[2015-03-10 00:01:00.492] [I] [core] Daylight: Sunset in UTC time : Wed, 11 Mar 2015 00:57:49 GMT
[2015-03-10 00:01:00.493] [I] [core] Daylight: Conclusion is that sensor should be off
[2015-03-10 00:01:00.493] [I] [core] Daylight: Sensor already off, nothing changed
[2015-03-10 07:24:00.354] [I] [core] Daylight: Status update executed
[2015-03-10 07:24:00.355] [I] [core] Daylight: current local time: Tue Mar 10 2015 07:24:00 GMT-0500 (CDT)
[2015-03-10 07:24:00.356] [I] [core] Daylight: current UTC time : Tue, 10 Mar 2015 12:24:00 GMT
[2015-03-10 07:24:00.357] [I] [core] Daylight: Sunrise in local time: Tue Mar 10 2015 07:22:15 GMT-0500 (CDT)
[2015-03-10 07:24:00.358] [I] [core] Daylight: Sunrise in UTC time : Tue, 10 Mar 2015 12:22:15 GMT
[2015-03-10 07:24:00.358] [I] [core] Daylight: Sunset in local time: Tue Mar 10 2015 19:58:34 GMT-0500 (CDT)
[2015-03-10 07:24:00.359] [I] [core] Daylight: Sunset in UTC time : Wed, 11 Mar 2015 00:58:34 GMT
[2015-03-10 07:24:00.360] [I] [core] Daylight: Conclusion is that sensor should be on
[2015-03-10 07:24:00.496] [I] [core] Daylight: Sensor switched to on
[2015-03-10 19:58:00.755] [I] [core] Daylight: Status update executed
[2015-03-10 19:58:00.756] [I] [core] Daylight: current local time: Tue Mar 10 2015 19:58:00 GMT-0500 (CDT)
[2015-03-10 19:58:00.757] [I] [core] Daylight: current UTC time : Wed, 11 Mar 2015 00:58:00 GMT
[2015-03-10 19:58:00.758] [I] [core] Daylight: Sunrise in local time: Tue Mar 10 2015 07:22:15 GMT-0500 (CDT)
[2015-03-10 19:58:00.759] [I] [core] Daylight: Sunrise in UTC time : Tue, 10 Mar 2015 12:22:15 GMT
[2015-03-10 19:58:00.759] [I] [core] Daylight: Sunset in local time: Tue Mar 10 2015 19:58:34 GMT-0500 (CDT)
[2015-03-10 19:58:00.760] [I] [core] Daylight: Sunset in UTC time : Wed, 11 Mar 2015 00:58:34 GMT
[2015-03-10 19:58:00.761] [I] [core] Daylight: Conclusion is that sensor should be on
[2015-03-10 19:58:00.761] [I] [core] Daylight: Sensor already on, nothing changed

edit next day:
last night i installed V0.6 and restarted the zway serrver, tonight the lights turned on. :D

mhorst
Posts: 27
Joined: 30 Dec 2014 15:10

Re: [userModule] Daylight (updated 2015-03-13)

Post by mhorst » 13 Mar 2015 22:34

Argh, how many mistakes can I make in such a small module? Timezones really give me a headache :roll:

If you look in your log you see that the sunrise and sunset times calculated at midnight differ from the ones calculated during the actual sunrise and sunset events. This is because the algorithm calculates the day of the year based on the number of days that have passed since the start of the year in local time and the current date in UTC. So if the system crosses a date boundary between midnight local time and the actual sunrise or sunset event, then the calculation will give a slightly different answer. If the calculated event occurs one minute later then the module will get confused when it does it's sanity check at the time of the scheduled sunrise/sunset (in your case sunset).

Long story short: there is a new version in the first post (v0.7.0). I fixed the calculation bug, and I also ensured that the schedule is updated 3 times a day: 3 o'clock in the morning and during the sunrise and sunset events themselves. So even if there is another bug, it should auto-correct itself without causing missed events.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest