Sun_down() - Easy way to offset?

Really like the built-in sun_down and sun_up functions. I often find myself wanting to add an offset though, any easy way to do that? Maybe this is a feature request? :slight_smile:

sun_down and up are just times.
so you can easy calculate with that like:
self.sundown() - datetime.timedelta(minutes=30) or
self.sunrise() + datetime.timedelta(hours=1)

if you use the same offset over and over, you could create a general function:

self.mysunrise(self):
  return self.sunrise() + datetime.timedelta(hours=1)

edit: or even with your own flexible offset:

self.mysunrise(self,offset):
  return self.sunrise() + datetime.timedelta(seconds=offset)
1 Like

Check this out:

http://appdaemon.readthedocs.io/en/latest/APIREFERENCE.html#parse-time

3 Likes

Thank you both! (Have I said it lately? I love AppDaemon!!! :slight_smile: )

2 Likes

i didnt even think of that one. :wink:
guess thats because i mostly use time in my triggers and constraints.

2 Likes

I just use something like this

self.run_at_sunrise(self.sunrise_cb, offset=+300)
1 Like