[userModule] Daylight (updated 2015-07-05)
Posted: 31 Dec 2014 13:23
Last updated: 2015-07-05
Tested with: v2.0.1
STATUS:testing
Another sunrise/sunset module. This one creates a binarySensor that indicates whether it is daytime (on) or nighttime (off), which is useful in combination with logical rules.
This module calculates the sunset and sunrise times based on the longtitude and latitude that you configure and compares that with the current system time to determine whether the sun is in the sky or not (so no internet connection needed). It also allows to configure what counts as sun up or down: official twilight, civil twilight, nautical twilight or astronomical twilight (see wikipedia for definitions).
Using this sensor you can make a logical rule to trigger actions when the sun sets or rises, i.e. when the value of this sensor changes.
Personally I will use this to close my window shutters when it becomes dark outside.
Also, you can make scenes that behave differently during daytime or night time. Just make three scenes: one empty one, one for daytime and one for night time. Then make two logical rules: one that triggers the daytime scene when the empty scene is triggered and the Daylight sensor is on, and one that triggers the night time scene when the empty scene is triggered when the Daylight sensor is off.
Hide these daytime and nighttime scenes and only put the empty scene on the dashboard. Now when you trigger the "empty" scene you will get different behavior based on whether it is day or night time.
Personally I will use this to change the behavior of my "Arrive home" scene; if I arrive home during the day the window shutters open, if I arrive home after dark then the lights come on and the window shutters stay closed.
Why this module if there exist already the SunriseSunset and ScheduleSun modules? Well, I just wanted to see if I could write a module myself. Also I thought it would be useful to be able to tell whether it is daytime or nighttime in logical rules.
Version history:
1.0.0 - Updated for version 2.0.1 by Pieter (pz1), he added an Icon, support for internationalization, and the sunrise and sunset times to the virtual device.
0.7.0 - Fixed bug that causes sunrise/sunset times to change between schedule and actual event. Update schedule also during sunrise/sunset events.
0.6.0 - Calculate new sunrise/sunset times at 03:01 to ensure it is done after any daylight savings time change
0.5.0 - Added more logging. Fixed bug when sunrise/sunset falls on different dates in UTC and the local timezone
0.4.0 - Fixed potential bug when the sun rises or sets 1 minute before a whole hour
0.3.0 - Added Cron dependency and ensured sensor is only updated when a real change occurs.
0.2.0 - Fixed bug in algorithm that caused sunrise to be one day too late on some dates
0.1.0 - First version
Tested with: v2.0.1
STATUS:testing
Another sunrise/sunset module. This one creates a binarySensor that indicates whether it is daytime (on) or nighttime (off), which is useful in combination with logical rules.
This module calculates the sunset and sunrise times based on the longtitude and latitude that you configure and compares that with the current system time to determine whether the sun is in the sky or not (so no internet connection needed). It also allows to configure what counts as sun up or down: official twilight, civil twilight, nautical twilight or astronomical twilight (see wikipedia for definitions).
Using this sensor you can make a logical rule to trigger actions when the sun sets or rises, i.e. when the value of this sensor changes.
Personally I will use this to close my window shutters when it becomes dark outside.
Also, you can make scenes that behave differently during daytime or night time. Just make three scenes: one empty one, one for daytime and one for night time. Then make two logical rules: one that triggers the daytime scene when the empty scene is triggered and the Daylight sensor is on, and one that triggers the night time scene when the empty scene is triggered when the Daylight sensor is off.
Hide these daytime and nighttime scenes and only put the empty scene on the dashboard. Now when you trigger the "empty" scene you will get different behavior based on whether it is day or night time.
Personally I will use this to change the behavior of my "Arrive home" scene; if I arrive home during the day the window shutters open, if I arrive home after dark then the lights come on and the window shutters stay closed.
Why this module if there exist already the SunriseSunset and ScheduleSun modules? Well, I just wanted to see if I could write a module myself. Also I thought it would be useful to be able to tell whether it is daytime or nighttime in logical rules.
Version history:
1.0.0 - Updated for version 2.0.1 by Pieter (pz1), he added an Icon, support for internationalization, and the sunrise and sunset times to the virtual device.
0.7.0 - Fixed bug that causes sunrise/sunset times to change between schedule and actual event. Update schedule also during sunrise/sunset events.
0.6.0 - Calculate new sunrise/sunset times at 03:01 to ensure it is done after any daylight savings time change
0.5.0 - Added more logging. Fixed bug when sunrise/sunset falls on different dates in UTC and the local timezone
0.4.0 - Fixed potential bug when the sun rises or sets 1 minute before a whole hour
0.3.0 - Added Cron dependency and ensured sensor is only updated when a real change occurs.
0.2.0 - Fixed bug in algorithm that caused sunrise to be one day too late on some dates
0.1.0 - First version