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

Tips, Tricks and Scripts to enhance your home automation and workaround known device bugs, limitations and incompatibilities
RottenMutt
Posts: 100
Joined: 31 Jan 2015 21:09

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

Post by RottenMutt »

Thank You, I installed V0.7

cat /var/log/z-way-server.log | grep Daylight
[2015-03-13 07:19:00.137] [core] Daylight: Status update executed
[2015-03-13 07:19:00.138] [core] Daylight: current local time: Fri Mar 13 2015 07:19:00 GMT-0500 (CDT)
[2015-03-13 07:19:00.139] [core] Daylight: current UTC time : Fri, 13 Mar 2015 12:19:00 GMT
[2015-03-13 07:19:00.140] [core] Daylight: Sunrise in local time: Fri Mar 13 2015 07:18:25 GMT-0500 (CDT)
[2015-03-13 07:19:00.140] [core] Daylight: Sunrise in UTC time : Fri, 13 Mar 2015 12:18:25 GMT
[2015-03-13 07:19:00.141] [core] Daylight: Sunset in local time: Fri Mar 13 2015 20:00:48 GMT-0500 (CDT)
[2015-03-13 07:19:00.142] [core] Daylight: Sunset in UTC time : Sat, 14 Mar 2015 01:00:48 GMT
[2015-03-13 07:19:00.142] [core] Daylight: Conclusion is that sensor should be on
[2015-03-13 07:19:00.286] [core] Daylight: Sensor switched to on
[2015-03-13 18:59:02.973] [core] Deleting device sensorBinary Daylight20
[2015-03-13 18:59:02.976] [I] [core] --- Stopping module Daylight
[2015-03-13 19:01:20.701] [I] [core] Instantiating module 20 from class Daylight
[2015-03-13 19:01:20.706] [I] [core] --- Starting module Daylight
[2015-03-13 19:01:20.733] [I] [core] Creating device sensorBinary Daylight20
[2015-03-13 19:01:20.959] [I] [core] Daylight: Schedule update executed
[2015-03-13 19:01:20.960] [I] [core] Daylight: Sunrise in local time: Fri Mar 13 2015 07:18:25 GMT-0500 (CDT)
[2015-03-13 19:01:20.961] [I] [core] Daylight: Sunrise in UTC time : Fri, 13 Mar 2015 12:18:25 GMT
[2015-03-13 19:01:20.962] [I] [core] Daylight: Sunrise event scheduled for 7:19
[2015-03-13 19:01:20.965] [I] [core] Daylight: Sunset in local time: Fri Mar 13 2015 20:00:48 GMT-0500 (CDT)
[2015-03-13 19:01:20.966] [I] [core] Daylight: Sunset in UTC time : Sat, 14 Mar 2015 01:00:48 GMT
[2015-03-13 19:01:20.967] [I] [core] Daylight: Sunset event scheduled for 20:01
[2015-03-13 19:01:20.975] [I] [core] Daylight: Status update executed
[2015-03-13 19:01:20.976] [I] [core] Daylight: current local time: Fri Mar 13 2015 19:01:20 GMT-0500 (CDT)
[2015-03-13 19:01:20.977] [I] [core] Daylight: current UTC time : Sat, 14 Mar 2015 00:01:20 GMT
[2015-03-13 19:01:20.978] [I] [core] Daylight: Sunrise in local time: Fri Mar 13 2015 07:18:25 GMT-0500 (CDT)
[2015-03-13 19:01:20.979] [I] [core] Daylight: Sunrise in UTC time : Fri, 13 Mar 2015 12:18:25 GMT
[2015-03-13 19:01:20.979] [I] [core] Daylight: Sunset in local time: Fri Mar 13 2015 20:00:48 GMT-0500 (CDT)
[2015-03-13 19:01:20.980] [I] [core] Daylight: Sunset in UTC time : Sat, 14 Mar 2015 01:00:48 GMT
[2015-03-13 19:01:20.981] [I] [core] Daylight: Conclusion is that sensor should be on
[2015-03-13 19:01:20.981] [I] [core] Daylight: Sensor already on, nothing changed

edit: update 3/16/2015 - everything is working, thanks again.
pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

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

Post by pz1 »

To make de naming of the virtual device follow the conventions of modules, I suggest to add an underscore in line 36 of index.js

Code: Select all

        deviceId: "Daylight_" + this.id,
mhorst
Posts: 27
Joined: 30 Dec 2014 15:10

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

Post by mhorst »

I did that change in my local set-up. It does require that your logical rules are modified manually, as the system loses it "DaylightXX" device and does not automatically replace it with the "Daylight_XX" device.

I'll test it for a few days before I put the new version up.
pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

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

Post by pz1 »

mhorst wrote: as the system loses it "DaylightXX" device and does not automatically replace it with the "Daylight_XX" device.
That is a known problem on github, but not yet been assigned.

EDIT 20150329: Github issue #190
mhorst
Posts: 27
Joined: 30 Dec 2014 15:10

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

Post by mhorst »

I don't think it's a big deal. I'll add a warning to the original post when I upload the new version.

Another reason I'm waiting with an update is that tonight I will switch to daylight savings time, and I want to see if everything works. If not, I'll fix that too.

EDIT:
Tonight was the switch to DST. My logging shows that at 03:01 the Daylight module correctly calculated the new sunrise time in the (new) local time.
There was a reboot of my Raspberry between that and the actual sunrise (not sure where that is coming from, my Raspberry has been acting up lately.
The sunrise event was raised at the correct time.
jhmartin
Posts: 29
Joined: 14 Apr 2015 02:52

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

Post by jhmartin »

Can I suggest an 'offset' for each of sunrise and sunset? For example I'd like my porch lights to come on about an hour before sunset, then I'd set a delayed scene to turn them off 2 hours later. Potentially the same behavior for the morning. The offset might be negative depending on the scenario.
pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

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

Post by pz1 »

A work-around is to make multiple instances of Daylight where you specify different longitudes that reflect the time offset you need.
pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

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

Post by pz1 »

In my own installation (v2.0.1 now) I added an icon to this module to see how I can make it more in line with the standard modules.

Problem
The icon does show in the Apps collection, but when I add and configure this app, the configuration screen does not show that icon. I have no clue what happened. See my private Github space for the changes I made to Martijn's version 0.7.0
Daylightapp.PNG
Daylightapp.PNG (4 KiB) Viewed 78319 times
Image is based on: icon made by Freepik from Flaticon is licensed by Creative Commons BY 3.0

Side note: Also tried to make a separate language file to support multilinguality with a separate language file in folder lang. Those strings also did not appear on the screens. I quess that problem is related to the icon issue, so I have not yet committed those changes to github


edit 13:59: The code related to the configuration screen image according to Inspector of Firefox says:

Code: Select all

<img src="/ZAutomation/api/v1/load/modulemedia/null/icon.png" class="app-image-alpaca ng-scope" ng-src="/ZAutomation/api/v1/load/modulemedia/null/icon.png" ng-if="input.icon" alt="img">
The path to the icon seems wrong. Other modules show the moduleName instead off null in the path.

Tried this on a different Pi, same result. Did install an other userModule, that installed OK. Looks like the problem is with Daylight module, and not directly in the v2.0.1 release
Since 29-12-2016 I am no longer a moderator for this forum
pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

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

Post by pz1 »

pz1 wrote:The icon does show in the Apps collection, but when I add and configure this app, the configuration screen does not show that icon.
Solved it for the icon. I suddenly remembered that for the new v2.0.1 the module.json configuration file needs an entry for the moduleName:

Code: Select all

"moduleName": "Daylight",
Unfortunately that does not yet solve my additional problem with the external translation file

Edit: Translation has been solved too
pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

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

Post by pz1 »

@mhorst

My final polished version adapted for v2.0.1 is here for consideration, and possible inclusion in the ZIP in the first post of this topic.

Edit 12:24 : I could not resist adding sunset/rise times to the virtual device

Edit 20150709: removed Daylight from my github space since I returned the maintenance token to mhorst
Post Reply