HowTo: DateTime add-on Sunset/Sunrise event with a +/- OFFSET in minutes?

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.

Thanks for hints…

You’ll have to convince the author to add that feature. Somebody already requested it here:

We also have a gateway issue:

After digging around, there is already a DateTime GITHUB issue requesting +/- OFFSET support for sunrise/sunset 16.

Guess I’ll use static time for the time being.

What is your Sunrise/Sunset set to? Civilian, nautical, astronaumical? Adjusting these vaules may give you the desired effect.

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.

#Remove the existing date-time-adapter

#Copy the new package to your gateway
Download the package from the above Github link.
scp date-time-adapter-1.0.1.tgz pi@gateway.local:/home/pi/.mozilla-iot/addons
OR ssh to your gateway, cd /home/pi/.mozilla-iot/addons and wget

#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: 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: INFO New event sunset_offset
2020-01-23 16:42:10.722 INFO : date-time: 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: INFO New event sunset
2020-01-23 16:42:10.727 INFO : date-time: 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

@mrstegeman the code isn’t published on Github to issue pull requests.

@damooooooooooh It’s all on the release branch:

Just a heads up, the author isn’t usually very responsive.

Ah ok, let me issue a pull request on this.

@damooooooooooh what’s the state of your fork? It looks like you added some features, but then reverted them, and I never saw a PR opened.

I’d be willing to replace the current adapter with your fork if you intend to keep up with maintenance and such.

1 Like

Hey @mrstegeman,

Sorry I’ve been out with the flu for a week or so and will pick this up tomorrow.

I’d be fine with maintaining the fork going forward after I refactor the solution for this problem slightly.

Ok. When you’re ready, can you open a PR to the addon-list repo to replace the adapter with your fork?