Page 1 of 1

Dawn and Dusk Time

PostPosted: Tue Jul 09, 2019 3:02 pm
by McIntoshBear
On my 35 yo StarGate I implemented a very crude approximation of dawn and dusk time based on the time of year and an approximation from the published calculations I could find at the time. This approximation has served my needs. I now am attempting to re-implement this functionality and others I created in a very different home automation environment - Indigo. I am beginning to teach myself Python and I quickly realized what I now could do if I mastered this new (for me) programing environment.

1. Has anyone wrote a Python script that would calculate the dawn and dusk time in Indigo?
2. Has anyone requested that dawn and dusk times be included in Indigo just like Sunrise and Sunset times can be selected from a drop down?

I know that using a "luminescence" sensor can be used to give an actual light level but I like the idea of being able to use more that 1 bit of information to trigger a lighting event.

I did a search of dawn and dusk and a majority of the posts that my search returned had to do with getting Indigo Sunrise and Sunset times to work correctly. I hope I have not overlooked other relevant posts. If I have please forgive me.

Thank you. :)

Re: Dawn and Dusk Time

PostPosted: Tue Jul 09, 2019 3:07 pm
by Dual
Wouldn’t sunrise and sunset with a time offset be sufficient?


Sent from my iPhone using Tapatalk

Re: Dawn and Dusk Time

PostPosted: Tue Jul 09, 2019 3:29 pm
by jay (support)
Here's something I found on slashdot about calculating them in Python. I've never attempted to use that particular library, but maybe it's a start.

[MODERATOR NOTE] moved to a more appropriate forum since it's not specifically about Indigo's Schedule implementation.

Re: Dawn and Dusk Time

PostPosted: Tue Jul 09, 2019 3:37 pm
by FlyingDiver
I use PyEphem to calculate sun angles so I can lower some shades as needed. Works well. I expect using that library to do dusk/dawn would be similar.

Code: Select all
import ephem

varAzimuth    = indigo.variables[717359973] # "Azimuth"
varElevation  = indigo.variables[719196174] # "Elevation"

(lat, long) = indigo.server.getLatitudeAndLongitude()

obs=ephem.Observer()
obs.lat=str(lat)
obs.long=str(long)
sun = ephem.Sun(obs)

azimuth = float(sun.az) * 57.2957795      # convert radians to degrees
elevation = float(sun.alt) * 57.2957795

indigo.variable.updateValue(varAzimuth, str(azimuth))
indigo.variable.updateValue(varElevation, str(elevation))

# indigo.server.log(u"Sun Azimuth: %s, elevation: %s" % (str(azimuth), str(elevation)))

Re: Dawn and Dusk Time

PostPosted: Wed Jul 10, 2019 6:04 am
by howartp
If there’s a calculation, I’m happy to add it to the Clock plugin.


Sent from my iPhone using Tapatalk Pro