I would like to use the nice DateTime add-on’s Sunset/Sunrise capability. Alas, at Sunset it’s too dark already and want that event nn minutes earlier. At Sunrise it’s still too dark and want my lights to remain on later.
Q: How would I implement a + and/or - minute OFFSET to either Sunrise or Sunset timers?
Ideally, this should be built into the DateTime add-on (MR?). I think there are probably add-on tricks to delay but I have no clue how to force Sunrise earlier by nn minutes.
My legacy X10 ActiveHome program supports offset natively in their advanced scheduling.
Hi I have a fork that includes this feature. I found that one of my bulbs was located in a darker room so I created an offset event. Let me share the code shortly.
Sorry for the delay, you can install this pre-release of the date-time-adapter on your gateway. You will need to manually install it. Note as this is a manual install, you install at your own risk and I am not liable for any issues or data loss that arises from installing and using it. Note i have tested this for over 2 months and you should be able to install it without removing the existing datetime device or altering existing rules that use the Sunset or Sunrise events.
#ssh to the gateway
cd .mozilla-iot/addons
tar -xvf date-time-adapter-1.0.1.tgz
mv package date-time-adapter
cd date-time-adapter
mkdir .git
sudo systemctl restart mozilla-iot-gateway.service or sudo reboot
#configure the package
goto the Settings > Addons Page
Find DateTime Adapter Addon and Configure
Enable the DateTime Adapter Adapter
#Wait for it to build, can take about 5 mins then
Goto to Things page and Add the new DateTime Adapter
#Reinstall 1.0.0 version
You can returnto the release version 1.0.0 of the adapter by removing this one through the adapter add/remove page and then add back the 1.0.0 one.
Sample logs below of -30mins offset for Sunset
2020-01-23 16:12:10.427 INFO : date-time: date_device.py:169 INFO now:2020-01-23 16:12:10.424119+00:00 > next:2020-01-23 16:42:08.816134+00:00
2020-01-23 16:12:10.430 INFO : date-time: date_device.py:172 INFO New event sunset_offset
2020-01-23 16:42:10.722 INFO : date-time: date_device.py:169 INFO now:2020-01-23 16:42:10.718688+00:00 > next:2020-01-23 16:42:08.816134+00:00
2020-01-23 16:42:10.725 INFO : date-time: date_device.py:172 INFO New event sunset
2020-01-23 16:42:10.727 INFO : date-time: util.py:113 INFO CALC_SUNSET today.utc: 2020/1/23 16:42:11 sunset: 2020/1/24 16:44:05 sunset_local: 2020-01-24 16:44:05.394557+00:00
Hi there @mstegeman, I wanted this feature and a few others, so I took it upon myself to update the date-time-adapter with fixes to the way @damooooooooooh was doing things (he had a bug where if the desired offset was after the sunset, it would never happen because the sunset time would be reset at sunset to the next day). I also added properties to tell you how long in minutes until the next sunset/sunrise, and how long it’s been since the last one. I also added a couple of properties that let you see the sun’s azimuth and elevation, so that you can detect things like certain angles when the sun shines in a window, or position/uncover solar panels at certain times, etc. My repo is a fork from @damooooooooooh’s last changes , and my repo is at https://github.com/wfahle/date-time-adapter, and I am willing to take over maintenance. Edit: I successfully added a pull request to the addon-list.
Hi @damooooooooooh, I’m happy to continue to support the fork, or if you want you can merge in my changes (I can post a pull request). Basically I fixed a couple of bugs in your implementation and then added some useful properties like minutes until next sunset/sunrise and minutes since last sunset/sunrise, along with the azimuth and elevation of the sun from the given location.
Edit: according to https://github.com/tomasy/date-time-adapter/issues/23, I can also speed up the deployment / startup time greatly by making a few minor changes, too. As I said, I’m willing to work on this to fix the remaining issues and any new ones that come up.
Edit: As of 2021/03/10 0:50 UTC it looks like 1.0.2 version of the date-time-adapter is live, and supports this feature. Go to configure and choose update. It takes a while to install (next on the list to fix).