Is Daylight Not Dark?

Posted on
Tue Nov 03, 2020 4:39 am
Hackencrash offline
User avatar
Posts: 246
Joined: Dec 16, 2015
Location: UK

Is Daylight Not Dark?

Is Daylight the opposite of Dark or is it some random minutes after sunrise and before sunset depending on season?

I am trying to perfect a better set of light level variables based on an outside luminance sensor. Lights, blinds and curtains can then be fine-tuned for a better experience. For instance, winter months or miserable weather makes it darker and causes difficulties when just relying on sunrise and sunset values alone.

However, I need a backup plan should my luminance sensor fail, so I would like to understand the actual logic behind the Daylight and Dark variables, and if they are different, how would I trigger on the Dark variable that does not appear in the variables list?

:)

Posted on
Tue Nov 03, 2020 4:57 am
autolog offline
Posts: 3988
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: Is Daylight Not Dark?

To my knowledge, there is only one readOnly variable: isDaylight which can be true (daytime) or false (nighttime)? :)

Posted on
Tue Nov 03, 2020 5:05 am
Hackencrash offline
User avatar
Posts: 246
Joined: Dec 16, 2015
Location: UK

Re: Is Daylight Not Dark?

Thanks Jon. So do you know how isDaylight is calculated?

Posted on
Tue Nov 03, 2020 5:42 am
autolog offline
Posts: 3988
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: Is Daylight Not Dark?

Hackencrash wrote:
Thanks Jon. So do you know how isDaylight is calculated?

Not specifically but it is based on the sunset and sunrise at your location that Indigo calculates.

You specify your location in the Sunset & Sunrise tab in Indigo's preferences.

There are also two Indigo server commands for returning the sunset and sunrise times, see here: Server Properties and Commands (indigo.server.*) :)

Posted on
Tue Nov 03, 2020 11:23 am
Hackencrash offline
User avatar
Posts: 246
Joined: Dec 16, 2015
Location: UK

Re: Is Daylight Not Dark?

Ah OK thanks Jon.

To summarise, the isDaylight variable is true on or after Sunrise and false on or after Sunset.

I thought it would be a bit too much to ask to take into account the variation in light intensity that results from the angle at which the sun’s rays hit the Earth depending on time of year! (although there are charts for this) :D

I can see a plug-in coming, no I can’t! I think I’ll stick to my luminance sensor and use isDaylight as a failsafe :)

Thanks again

Posted on
Tue Nov 03, 2020 1:04 pm
DaveL17 offline
User avatar
Posts: 6742
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Is Daylight Not Dark?

I believe someone actually took a stab at this at one point. You might find something in the forums.

Found it: https://www.indigodomo.com/pluginstore/110/

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Tue Nov 03, 2020 1:06 pm
Hackencrash offline
User avatar
Posts: 246
Joined: Dec 16, 2015
Location: UK

Re: Is Daylight Not Dark?

OMG this looks exactly what I was after!

Thanks DaveL17 :)

Posted on
Tue Nov 03, 2020 1:09 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Is Daylight Not Dark?

I wrote this code a while back. Requires install of the ephem library (pip install ephem).

Code: Select all
import ephem

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

(latitude, longitude) = indigo.server.getLatitudeAndLongitude()

obs=ephem.Observer()
obs.lat=str(latitude)
obs.long=str(longitude)
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"Latitude: {}, Longitude: {}".format(latitude, longitude))
#indigo.server.log(u"Sun Azimuth: {}, elevation: {}".format(azimuth, elevation))


I use it to close a specific shade in my house when the sun elevation gets below a certain threshold, and the azimuth is within a certain range. If I don't the sun shines over my shoulder and reflects off my main computer screen. ;)

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Tue Nov 03, 2020 1:16 pm
Hackencrash offline
User avatar
Posts: 246
Joined: Dec 16, 2015
Location: UK

Re: Is Daylight Not Dark?

Alright so I need to create two Indigo variables with different ID's to yours and the Azimuth is the left and right stuff and Elevation being the up and down stuff. I'm going to give this a go!

Thanks!
:D

Posted on
Tue Nov 03, 2020 1:17 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Is Daylight Not Dark?

I run that script in an Indigo scheduler action every 10 minutes (I think). Then I have a trigger that fires when the elevation field goes below a certain value to close the shade.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests