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

Tips, Tricks and Scripts to enhance your home automation and workaround known device bugs, limitations and incompatibilities
mhorst
Posts: 27
Joined: 30 Dec 2014 15:10

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

Post by mhorst » 12 Feb 2015 22:48

Yes, one sentence is tricky. In the end you can accomplish the same thing with both modules, so in that sense they are not that different.

This module is easier if you want to modify the behavior of your system depending on whether it is night or day (see the first post for how to do that). The SunriseSunset module is easier if you want to trigger actions when the sun rises or sets.

In the end, with this module you can still trigger actions on sunrise or sunset, but you need to add a seperate logical rule that triggers when the daylight "sensor" changes state. With the SunriseSunset module you can still change the behavior of your system by making a dummy switch that is changed upon sunrise/sunset and then use that dummy switch in your logical rules.


On a seperate note, I put v0.4.0 in the first post of this thread (this time with the correct version number :) )
I found a potential bug that could cause the module to miss sunrise or sunset when the sun rises or sets 1 minute before a whole hour.

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

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

Post by RottenMutt » 13 Feb 2015 20:04

i just installed V.4 and it shows off in my widgets, time zone is set correctly and show correctly in the expert ui and i looked out the window and the sun is up (11:00am)! :D

so what is the best way to turn on and off lights?

create one logical rule and scene to turn lights on and the same to turn lights off?
I would rather use your module then sunrise/sunset because your module calculates the time based on lat/longitude and i can also pick the zenith option for a event that happens when it is darker out.

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

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

Post by mhorst » 14 Feb 2015 00:29

To trigger on sunrise or sunset you just need a logical rule that triggers on a change of the sensor.

To have a scene that behaves differently at day and night you need that one scene and two logical rules, one for the daytime behavior and one for nighttime behavior. Personally I let the logical rules trigger just one specialized scene that contains the desired behavior. This is a bit more complicated with two additional scenes in my system, but the upside is that I can place those scenes also on the dashboard for testing purposes, or for triggering them manually if I want to (for example to put my home in night mode if I leave during the day).

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

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

Post by RottenMutt » 14 Feb 2015 18:04

I gave it 24hrs to calculate time after midnight, but Daylight shows "off" still. What am i doing wrong?

my settings:
latitude: 32.9XXXXX
Longitude: -97.4XXXXX
Zenith: Nautical

Z-Way V2.0.1-rc12

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

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

Post by pz1 » 14 Feb 2015 18:39

You should see something like this in your log:
[2015-02-14 16:34:08.832] [core] Loading module Daylight from userModules/Daylight
[2015-02-14 16:34:08.836] [core] Executing script: /*** Daylight Z-Way HA module ******************************************* ...
[2015-02-14 16:34:08.840] [core] Instantiating module 7 from class Daylight
[2015-02-14 16:34:08.843] [core] --- Starting module Daylight
[2015-02-14 16:34:08.851] [core] Creating device sensorBinary Daylight7
[2015-02-14 16:34:08.915] [core] Daylight: Sunrise updated to 6:00
[2015-02-14 16:34:08.917] [core] Daylight: Sunset updated to 19:0
[2015-02-14 16:34:08.919] [core] Daylight: Status updated
[2015-02-14 16:34:08.920] [core] Daylight is on


(I've set mine on Nautical for this test, next restarted the z-way-server

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

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

Post by RottenMutt » 14 Feb 2015 18:53

where do i find the log???
edit: found it
cat /var/log/z-way-server.log | grep Daylight:

[2015-02-14 08:52:03.839] [core] Loading module Daylight from userModules/Daylight
[2015-02-14 08:52:03.857] [core] Executing script: /*** Daylight Z-Way HA module ******************************************* ...
[2015-02-14 08:52:03.875] [core] Instantiating module 14 from class Daylight
[2015-02-14 08:52:03.885] [core] --- Starting module Daylight
[2015-02-14 08:52:03.928] [core] Creating device sensorBinary Daylight14
[2015-02-14 08:52:04.124] [core] Daylight: Sunrise updated to 6:21
[2015-02-14 08:52:04.126] [core] Daylight: Sunset updated to 19:9
[2015-02-14 08:52:04.140] [core] Daylight: Status updated
[2015-02-14 08:52:04.141] [core] Daylight is off

clearly status update is wrong :( It should be on

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

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

Post by pz1 » 14 Feb 2015 19:18

Have you set your time zone correctly on your Pi? Some modules are sensitive to that. Don't know if this one is.

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

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

Post by RottenMutt » 14 Feb 2015 19:40

i used raspi-config to set the timezone, is that the wrong way? My raspberry pi OS version is 3.18.5+
time displays correctly in Z-Wave Expert UI
cmd line
>date
>Sat Feb 14 10:45:18 CST 2015

edit: I think the format of the time is wrong: 'Daylight: Sunset updated to 19:9'

perhaps it should be 19:09 , could it be just a formatting issue...

OK i set it to astronomical so the sunrise/sunset would get out of the 10 min hole and still get off... grrr

[2015-02-14 12:54:54.162] [core] Loading module Daylight from userModules/Daylight
[2015-02-14 12:54:54.179] [core] Executing script: /*** Daylight Z-Way HA module ******************************************* ...
[2015-02-14 12:54:54.196] [core] Instantiating module 14 from class Daylight
[2015-02-14 12:54:54.203] [core] --- Starting module Daylight
[2015-02-14 12:54:54.223] [core] Creating device sensorBinary Daylight14
[2015-02-14 12:54:54.322] [core] Daylight: Sunrise updated to 5:52
[2015-02-14 12:54:54.325] [core] Daylight: Sunset updated to 19:38
[2015-02-14 12:54:54.331] [core] Daylight: Status updated
[2015-02-14 12:54:54.332] [core] Daylight is off

edit:
It is night now:
[2015-02-14 13:57:44.035] [core] Loading module Daylight from userModules/Daylight
[2015-02-14 13:57:44.052] [I] [core] Executing script: /*** Daylight Z-Way HA module ******************************************* ...
[2015-02-14 13:57:44.072] [I] [core] Instantiating module 14 from class Dayligh
[2015-02-14 13:57:44.090] [I] [core] --- Starting module Daylight
[2015-02-14 13:57:44.126] [I] [core] Creating device sensorBinary Daylight14
[2015-02-14 13:57:44.535] [I] [core] Daylight: Sunrise updated to 5:52
[2015-02-14 13:57:44.549] [I] [core] Daylight: Sunset updated to 19:38
[2015-02-14 13:57:44.556] [I] [core] Daylight: Status updated
[2015-02-14 13:57:44.557] [I] [core] Daylight is off
[2015-02-14 19:38:00.478] [I] [core] Daylight: Status updated
[2015-02-14 19:38:00.479] [I] [core] Daylight is off

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

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

Post by pz1 » 15 Feb 2015 11:02

RottenMutt wrote:i used raspi-config to set the timezone, is that the wrong way? My raspberry pi OS version is 3.18.5+
I did/have the same"with v.04 on my Pi 2

Daylight is on as it should. Forgot to test last night to see if it went off.
edit: I think the format of the time is wrong: 'Daylight: Sunset updated to 19:9'
I also noticed that to in my initial log

Update: Looked into the log just now. It looks like things are working OK for me with "Nautical

Code: Select all

[2015-02-14 19:00:01.006] [I] [core] Daylight: Status updated
[2015-02-14 19:00:01.007] [I] [core] Daylight is off
[2015-02-14 19:00:01.028] [I] [core] Daylight sensor switched to off
[2015-02-15 00:01:00.980] [I] [core] Daylight: Sunrise updated to 6:37
[2015-02-15 00:01:00.986] [I] [core] Daylight: Sunset updated to 19:2
[2015-02-15 00:01:00.989] [I] [core] Daylight: Status updated
[2015-02-15 00:01:00.989] [I] [core] Daylight is off
[2015-02-15 06:37:00.171] [I] [core] Daylight: Status updated
[2015-02-15 06:37:00.171] [I] [core] Daylight is on
[2015-02-15 06:37:00.596] [I] [core] Daylight sensor switched to on

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

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

Post by mhorst » 15 Feb 2015 18:02

The format of the time in the logging is indeed wrong, but that was not what caused the problems.
The problem was that the module computes sunrise and sunset in UTC and then converts it to local time.
In this conversion I did not take into account that the date on which the sun rises/sets could be different for UTC and the local timezone.

@RottenMutt: in your case the sunset was (in your local timezone) a day before the sunrise. This caused the module to decide that the sun must be down. Unfortunately this was not visible in logging.

@pz1: I think you and I did not encounter this problem because our timezones are relatively close to the UTC timezone and the our sunrise/sunset will therefore never be on different dates in UTC and local time.

In any case v0.5.0 is available in the first post, with more extensive logging, and, naturally, a fix for this bug.

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests