+1 vote
asked by (5k points)
closed by

The open-source software that ThingPulse provides for its devices relies on weather data pulled from Weather Underground. The standard setup process involves creating a Wunderground API key. The usage was free for up to 500 requests per day or 10 requests per minute.

In the evening of May 15th The Weather Company, a subsidiary of IBM, announced that it will no longer provide free weather API keys. There was no prior announcement and the change became effective immediately. It is unclear for how long existing keys will still be valid. As not even the tens of thousand of weather station owners who deliver their data to Wunderground for free will get a key to read their data back the uproar in the community is big.

For you this means that unless you already obtained a key from Wunderground you can not use the ready-made software for your ThingPulse device. We are very sorry, and furious, about this development but our hands are tied. The promise to our customers is that we will be working hard and not rest until we can offer an adequate alternative integration. We started working on a new service integration on May 19th.

closed with the note: pinning
commented by (2.7k points)
I'm focussing on Open Weather, which apart from Astronomy data it seems to have everything needed.

Calculating Moon Phase and illumination can be done relatively easily and needs is a rough LAT/LON.
commented by (5k points)
By "Open Weather" you mean OpenWeatherMap, right?

We're also looking at existing code (elsewhere) for moon phase calculation. Which library do you use?
commented by (2.7k points)
Yes Openweathermap. Moon Phase can be calculated with:
int Moon_phase(int year,int month,int day)
 {
     /*k
       Calculates the moon phase (0-7), accurate to 1 segment.
       0 = > new moon.
       4 => Full moon.
     */
     
     int g, e;

     if (month == 1) --day;
     else if (month == 2) day += 30;
     else // m >= 3
     {
         day += 28 + (month-2)*3059/100;

         // adjust for leap years
         if (!(year & 3)) ++day;
         if ((year%100) == 0) --day;
     }
     
     g = (year-1900)%19 + 1;
     e = (11*g + 18) % 30;
     if ((e == 25 && g > 11) || e == 24) e++;
     return ((((e + day)*6+11)%177)/22 & 7);
 }
commented by (5k points)
Yep, but we haven't made up our mind yet as for what to do about moon rise/set times.
commented by (2.7k points)
reshown by
The function above returns 0-7 for the 8 standard moon phases, I think you could drop the % illumination, although I have a function for that.

There are plenty of Moon Rise/Set calculators around, so I think the whole Astronomy section can be replaced with one function returning Phase Name, %illumination and  Rise/Set times all it needs is current date and Lat/Lon can be set for major cities or get the User to enter those as part of the setup.
commented by (5k points)
"There are plenty of Moon Rise/Set calculators around" - we're testing some of those. If there's one that you _know_ works reliably would you mind sharing a link.

"Lat/Lon can be set for major cities or get the User to enter those as part of the setup" - I don't think we need either as OpenWeatherMap for example returns those in the 'coord' property for a given city.
commented by (2.7k points)
Calculating Moon Rise/Set times is proving to be quite hard to do, I'm currently working through the NOAA example (long-hand) but  their algorithms use degrees and not radians and there are a lot of calculations to do, my problem currently is working out what parameters need to be in degrees and radians.

I have not found a library yet.

I can now draw a moon without any images, uses Pythagoras to draw the white and black areas. Needs x,y d,m,y and hemisphere.

Openweathermap supplies time-stamps in Unix time, so I've had to add a new time function to convert that.

As I don't use a streaming JSON decoder, I can only get the first 21 hours of forecast runs out of memory on an ESP32. WU is so much easier, but I'm liking OWM the more I use it.   

I have my code converted now - well just moon rise/set to add back.
commented by (2.7k points)
Calculating moon rise/set times is not an exact science it seems and requires a series of approximations and then iterations to converge on a final but estimated answer.

I think I'm going to drop moon rise/set times and just display the moon phase, there are few people who want to know exactly when the moon rises/sets, well apart for religious needs.

I have notice that Openweather data in this region is actually my weather station data upload that I supply to WU and I was not expecting that, so now I'm wondering where else my data is going to! I already know it feeds the UK MET Office but I don't mind that, nonetheless interesting for me. It's probably being sold-on many times over...
commented by (2.7k points)
These servers provide the data:
http://aa.usno.navy.mil/data/docs/api.php#phase
Try this:

http://api.usno.navy.mil/rstt/oneday?date=5/24/2018&loc=Los Angeles, CA

Won't past in correctly for full address in link

Welcome to ThingPulse Q&A, where you can ask questions and receive answers from other members of the community.

https://thingpulse.com

...