Astronomy and control pages

Posted on
Fri Oct 27, 2017 12:13 pm
ctgreybeard offline
Posts: 29
Joined: Apr 08, 2007
Location: Bethel, CT, USA

Astronomy and control pages

Thanks for adding the Sunrise/Sunset info to use in control pages. I have a question about the terminology.

For each data point (Sunrise/Sunset) there are several items available. They are categorized (I guess) as "Moon Phase", "Sun Phase", "epoch", and "label". The latter two seem self explanatory but what do the first two signify? The "Moon Phase" ones seem to agree mostly with the WU data pages but the "Sun Phase" doesn't seem to agree with anything. And, for my PWS:KCTBETHE3 the minute values are close but not the same as what is on the WU page. A minute or two off but different, why would that be?

Bill W

--
Bill W

Posted on
Fri Oct 27, 2017 12:28 pm
DaveL17 offline
User avatar
Posts: 6742
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Astronomy and control pages

I chose the phases based on their relation to the Indigo-reported sunrise and sunset times for my location. I reckoned that this is what most users would expect. Regarding the difference between sun phase and moon phase, I must admit that I don't know. I believe that the sun phase is when the sun literally emerges/disappears at the horizon (which is how I personally think of sunrise and sunset), but I am no astronomer. :)

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

[My Plugins] - [My Forums]

Posted on
Fri Oct 27, 2017 12:48 pm
ctgreybeard offline
Posts: 29
Joined: Apr 08, 2007
Location: Bethel, CT, USA

Re: Astronomy and control pages

Hmmm, there is a huge difference between Sunrise Minute for the Sun and Moon phases. I suspect a bug. It looks like you're picking up the Sunset minute instead of the Sunrise for that data point.

--
Bill W

Posted on
Fri Oct 27, 2017 1:28 pm
DaveL17 offline
User avatar
Posts: 6742
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Astronomy and control pages

Nerts. You're right, there's a bug. I picked up the sunset hour for both hours and minutes (note that the individual states for hours and minutes for these values are correct--I bodged the assembly of the full time values). This is an easy fix and I will post a new release.

Code: Select all
is:  [sunsetHour]:[sunsetHour]

should be:  [sunsetHour]:[sunsetMinute]

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

[My Plugins] - [My Forums]

Posted on
Fri Oct 27, 2017 1:43 pm
ctgreybeard offline
Posts: 29
Joined: Apr 08, 2007
Location: Bethel, CT, USA

Re: Astronomy and control pages

That's not exactly what I'm seeing unless I'm misunderstanding. I do see what you are saying about the hour but I also see the minutes for Sunset moon phase, sunset sun phase and sun rise sun phase all the same value (54) while sun rise moon phase is showing 19 minutes. It just looks fishey.
Image

--
Bill W

Posted on
Fri Oct 27, 2017 1:56 pm
DaveL17 offline
User avatar
Posts: 6742
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Astronomy and control pages

Don't look at that. Look at this shiny thing I have in my hand over here...

You actually discovered two bugs. In the instance of bug #2, the [sunriseMinuteSunphase] device state was being set to the value of the [sunsetMinuteSunphase] value. This is also an easy fix. (Interestingly, this particular bug may have even been in the code since the Astronomy device was first established.) When you reported the first bug, I looked over all of the sunrise/sunset code and still didn't see that.

Thanks for the help and sorry for the hassle. Look for a update soon.

Cheers!

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

[My Plugins] - [My Forums]

Posted on
Fri Oct 27, 2017 2:25 pm
ctgreybeard offline
Posts: 29
Joined: Apr 08, 2007
Location: Bethel, CT, USA

Re: Astronomy and control pages

No sweat. It's certainly nothing critical.

But I'm still confused as the where sun_phase and moon_phase come from. I looked at the WUnderground API docs and I see that the Astronomy section puts the sunrise and sunset under moon_phase in the json return but I don't see where sun_phase is. I'm looking at https://www.wunderground.com/weather/ap ... /astronomy

--
Bill W

Posted on
Fri Oct 27, 2017 3:44 pm
DaveL17 offline
User avatar
Posts: 6742
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Astronomy and control pages

In order to see what the plugin is seeing, you need to use v11 of the Weather Underground API. Here's a return using their sample URL (adjusted for v11):

Code: Select all
{
  "response": {
  "version":"0.1",
  "termsofService":"http://www.wunderground.com/weather/api/d/terms.html",
  "features": {
  "astronomy": 1
  }
   }
      ,   "moon_phase": {
      "percentIlluminated":"50",
      "ageOfMoon":"7",
      "phaseofMoon":"Waxing Crescent",
      "hemisphere":"South",
      "current_time": {
      "hour":"8",
      "minute":"40"
      },
      "sunrise": {
      "hour":"5",
      "minute":"59"
      },
      "sunset": {
      "hour":"19",
      "minute":"19"
      },
      "moonrise": {
      "hour":"12",
      "minute":"13"
      },
      "moonset": {
      "hour":"1",
      "minute":"32"
      }
   },
   "sun_phase": {
      "sunrise": {
      "hour":"5",
      "minute":"59"
      },
      "sunset": {
      "hour":"19",
      "minute":"19"
      }
   }
}


If you want to explore yourself, use the example URL at the bottom of the docs page you were looking at, and change 'astronomy' to 'astronomy_v11'. Unfortunately, the API docs are not always terribly complete. :(

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

[My Plugins] - [My Forums]

Posted on
Fri Oct 27, 2017 4:38 pm
ctgreybeard offline
Posts: 29
Joined: Apr 08, 2007
Location: Bethel, CT, USA

Re: Astronomy and control pages

Ah! It looks like they realized that putting sun rise and set under "moon" didn't make much sense and added sun_phase with the sun data but had to leave it under moon also for backward compatibility.

Thanks, I'll watch out for the fixes but what I have is fine for my own development.

Bill

--
Bill W

Posted on
Sat Oct 28, 2017 2:15 pm
ctgreybeard offline
Posts: 29
Joined: Apr 08, 2007
Location: Bethel, CT, USA

Re: Astronomy and control pages

6.0.02 fixes it all. Thanks! :D

--
Bill W

Posted on
Sat Oct 28, 2017 2:32 pm
DaveL17 offline
User avatar
Posts: 6742
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Astronomy and control pages

ctgreybeard wrote:
6.0.02 fixes it all. Thanks! :D

Glad to hear it. Thanks for reporting back!

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

[My Plugins] - [My Forums]

Posted on
Sun Oct 29, 2017 12:58 am
haavarda offline
User avatar
Posts: 702
Joined: Aug 18, 2012
Location: Norway

Re: Astronomy and control pages

Hi Dave.
I have been looking at simplifying my setup lately. Removing unused plugins /devices etc.
Today I i am using the cynical weather plugin to calculate sun position, and close / open my shades accordingly. Any chance that this functionality could be incorporated in your plugin? In the Cynical plugin the sun position is reported as an angle towards a heading.

Håvard

Håvard

Posted on
Sun Oct 29, 2017 4:40 am
DaveL17 offline
User avatar
Posts: 6742
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Astronomy and control pages

Hi Håvard - I don't think that the WUnderground API has sun position data available. That said, given the proper inputs it could be included with the WUnderground astronomy device. Let's take the conversation private and see what the options are.

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

[My Plugins] - [My Forums]

Posted on
Sun Oct 29, 2017 5:51 am
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Astronomy and control pages

haavarda wrote:
Hi Dave.
I have been looking at simplifying my setup lately. Removing unused plugins /devices etc.
Today I i am using the cynical weather plugin to calculate sun position, and close / open my shades accordingly. Any chance that this functionality could be incorporated in your plugin? In the Cynical plugin the sun position is reported as an angle towards a heading.

Håvard


If the only reason you're using that plugin is for the sun position, you could replace it with this script which I run in a scheduled event (every minute, as I recall).

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))

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

Posted on
Sun Oct 29, 2017 10:27 am
haavarda offline
User avatar
Posts: 702
Joined: Aug 18, 2012
Location: Norway

Re: Astronomy and control pages

FlyingDiver wrote:
haavarda wrote:
Hi Dave.
I have been looking at simplifying my setup lately. Removing unused plugins /devices etc.
Today I i am using the cynical weather plugin to calculate sun position, and close / open my shades accordingly. Any chance that this functionality could be incorporated in your plugin? In the Cynical plugin the sun position is reported as an angle towards a heading.

Håvard


If the only reason you're using that plugin is for the sun position, you could replace it with this script which I run in a scheduled event (every minute, as I recall).

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))


This looks promising, but what is ephem? And how do I install that?

Håvard

Who is online

Users browsing this forum: No registered users and 2 guests