Author Topic: AerisWeather forecast in Saratoga template [Resolved]  (Read 1364 times)

0 Members and 1 Guest are viewing this topic.

Offline Vasco

  • Forecaster
  • *****
  • Posts: 334
    • PWS
AerisWeather forecast in Saratoga template [Resolved]
« on: January 30, 2023, 11:42:20 AM »
Decided to try Aeris forecast to be ready for the demise of Dark Sky, but I'm not getting anything. Changed Settings.php to use Aeris, entered access ID and secret key, entered forecast area and units, but nothing. Aeris website records API hits but no json in .../cache.

Note that I do have to use a proxy for cURL, but that is/has been working fine for the DS forecast and all the other cURLs in the template.

Also, everything works OK for Aeris forecast in my PWS_Dashboard (not currently selected).

What have I forgotten?
« Last Edit: January 30, 2023, 02:59:16 PM by Vasco »
Oregon Scientific WMR200 + Weather Display in Windows 10

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: AerisWeather forecast in Saratoga template
« Reply #1 on: January 30, 2023, 02:24:59 PM »
So, a couple of issues.  Running a view source on wxforecast.php?force=1 shows
Code: [Select]
<!-- AW-forecast.php (ML) Version 1.02 - 19-Jan-2022 on PHP 7.2.1 -->
<!-- temps in C -->
<!-- autoSetTemplate using narrow aspect. -->
<!-- loading from https://api.aerisapi.com/forecasts/?p=55.8983,-3.2077&format=json&filter=daynight,precise&limit=14&client_id=pMEv1Q5BisGq9AayV4u6b&client_secret=tXT0sXdZaPyB0vnIwBcO6EY1uJtEP9JszsKQMqsq. -->
<!-- curl fetching 'https://api.aerisapi.com/forecasts/?p=55.8983,-3.2077&format=json&filter=daynight,precise&limit=14&client_id=pMEv1Q5BisGq9AayV4u6b&client_secret=tXT0sXdZaPyB0vnIwBcO6EY1uJtEP9JszsKQMqsq' -->
<!-- HTTP stats:  RC=200 dest=192.168.252.254 port=3128 (from sce=192.168.252.43)
      Times: dns=0.000 conn=0.000 pxfer=0.026 get=0.009 total=0.036 secs -->
<!-- RC=200 Connection established, bytes=27050 -->
<!-- unable to open ./cache/AW-forecast-json-0-uk2-en.txt for writing. -->
<!-- using charsetInput='UTF-8' charsetOutput='ISO-8859-1' doIconv='1' doRTL='' -->
<!-- loading English period names -->
<!-- processing JSON entries for forecast -->
<!-- rawJSON size is 27011 bytes -->
<!-- AW_prepareJSON: Success. Valid UTF-8. -->
<!-- json_decode returns  - Syntax error, malformed JSON -->
So first, the cache file isn't writable.. that likely needs a permissions fix.  I suspect the second issue is due to proxy headers being returned, but can't validate until the cache file is writable and visible from your website.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Vasco

  • Forecaster
  • *****
  • Posts: 334
    • PWS
Re: AerisWeather forecast in Saratoga template
« Reply #2 on: January 30, 2023, 02:35:03 PM »
So first, the cache file isn't writable.. that likely needs a permissions fix.

I'll check; but I get DS-forecast-json, meteoalarm, UV forecast and metarcache OK?

Quote
I suspect the second issue is due to proxy headers being returned, but can't validate until the cache file is writable and visible from your website.

Ahhh, we've seen that before. . .

EDIT: /cache has 775. . .
« Last Edit: January 30, 2023, 02:39:29 PM by Vasco »
Oregon Scientific WMR200 + Weather Display in Windows 10

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: AerisWeather forecast in Saratoga template
« Reply #3 on: January 30, 2023, 02:41:46 PM »
And, you'll need to replace
Code: [Select]
  $i = strpos($html,"\r\n\r\n");
  $headers = substr($html,0,$i-1);
  $content = substr($html,$i+4);
with
Code: [Select]
  $stuff = explode("\r\n\r\n",$html); // maybe we have more than one header due to proxy redirects
  $content = (string)array_pop($stuff); // last one is the content
  $headers = (string)array_pop($stuff); // next-to-last-one is the headers
for the two instances.  That's what we did with DS-forecast.php :)
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Vasco

  • Forecaster
  • *****
  • Posts: 334
    • PWS
Re: AerisWeather forecast in Saratoga template
« Reply #4 on: January 30, 2023, 02:44:29 PM »
That's what we did with DS-forecast.php :)

I've just found the PM of 11/8/22. . . sorry, Ken  :oops:

EDIT: That's it! Thanks, Ken.
« Last Edit: January 30, 2023, 02:58:12 PM by Vasco »
Oregon Scientific WMR200 + Weather Display in Windows 10

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: AerisWeather forecast in Saratoga template
« Reply #5 on: January 30, 2023, 02:45:39 PM »
No problem!  I'll remember to update the source with the next update to AW-forecast.php as needed.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Vasco

  • Forecaster
  • *****
  • Posts: 334
    • PWS
Re: AerisWeather forecast in Saratoga template
« Reply #6 on: January 30, 2023, 03:00:23 PM »
No problem!  I'll remember. . .

Wish I could say the same  :lol:
Oregon Scientific WMR200 + Weather Display in Windows 10

Offline Vasco

  • Forecaster
  • *****
  • Posts: 334
    • PWS
Re: AerisWeather forecast in Saratoga template [Resolved]
« Reply #7 on: March 10, 2023, 01:18:36 PM »
Just been doing some updating, so I thought I would modify the new forecast scripts for my cURL proxy problems - just in case. Pleasantly surprised to find the $stuff mod already included in OWM-forecast.php  :-) . . . but not in PW and VC. I presume I would need to do them too?


 
Oregon Scientific WMR200 + Weather Display in Windows 10

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: AerisWeather forecast in Saratoga template [Resolved]
« Reply #8 on: March 10, 2023, 02:31:52 PM »
Yes, sorry.. forgot to retrofit those into the basic DW-forecast script adapted for PirateWeather and VisualCrossing displays.  For some reason, the OWM request ALWAYS had an internal redirect to the actual data, so had to apply the $stuff mod to make it work.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Vasco

  • Forecaster
  • *****
  • Posts: 334
    • PWS
Re: AerisWeather forecast in Saratoga template [Resolved]
« Reply #9 on: March 24, 2023, 06:50:36 PM »
Just switched over from Dark Sky to Aeris but no forecast for Edinburgh  :-(

The changes have been made in Settings.php. . . what have I forgotten?
Oregon Scientific WMR200 + Weather Display in Windows 10

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: AerisWeather forecast in Saratoga template [Resolved]
« Reply #10 on: March 24, 2023, 06:58:29 PM »
Just switched over from Dark Sky to Aeris but no forecast for Edinburgh  :-(

The changes have been made in Settings.php. . . what have I forgotten?

Looks like you fixed it.. your homepage and wxforecast.php both show forecast info from Aerisweather.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Vasco

  • Forecaster
  • *****
  • Posts: 334
    • PWS
Re: AerisWeather forecast in Saratoga template [Resolved]
« Reply #11 on: March 24, 2023, 07:08:42 PM »
I was expecting a box for Edinburgh at the top of Forecast details. . . and why only updated at 19:00?
Oregon Scientific WMR200 + Weather Display in Windows 10

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: AerisWeather forecast in Saratoga template [Resolved]
« Reply #12 on: March 24, 2023, 07:18:50 PM »
Aerisweather doesn't provide a specific value in the JSON for 'Updated'.  The script uses the timestamp in the first period (first forecast) as the Updated .. it's what was available.

What do you mean when you say 'a box for Edinburgh'?  If you mean the drop-down selection list box, then you have to have 2 or more locations enabled in Settings.php
Code: [Select]
$SITE['AWforecasts'] = array(
// Location|lat,long  (separated by | characters)
'Edinburgh, UK|55.8983,-3.2077',
//'Saratoga, CA, USA|37.27465,-122.02295',
//'Auckland, NZ|-36.910,174.771', // Awhitu, Waiuku New Zealand
//'Assen, NL|53.02277,6.59037',
//'Blankenburg, DE|51.8089941,10.9080649',
//'Carcassonne, FR|43.2077801,2.2790407',
//'Braniewo, PL|54.3793635,19.7853585',
);
and you only have one location active
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Vasco

  • Forecaster
  • *****
  • Posts: 334
    • PWS
Re: AerisWeather forecast in Saratoga template [Resolved]
« Reply #13 on: March 24, 2023, 07:32:14 PM »
What do you mean when you say 'a box for Edinburgh'?

Attached DS forecast details.
Oregon Scientific WMR200 + Weather Display in Windows 10

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: AerisWeather forecast in Saratoga template [Resolved]
« Reply #14 on: March 24, 2023, 07:59:52 PM »
Ahh...  Neither WU/TWC (WC-forecast.php) nor AerisWeather (AW-forecast.php) provide a local conditions info to format.

DarkSky (DS-forecast.php), PirateWeather (PW-forecast.php), OpenWeatherMap (OWM-forecast.php) and VisualCrossing (VC-forecast.php) do provide a conditions box (which may be based on a 'nearby' METAR station for PW, OWM, VC)

The PirateWeather, OpenWeatherMap and VisualCrossing scripts are all in the Base-World distribution.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Vasco

  • Forecaster
  • *****
  • Posts: 334
    • PWS
Re: AerisWeather forecast in Saratoga template [Resolved]
« Reply #15 on: March 24, 2023, 08:16:07 PM »
Thanks, Ken  :-)

I changed my PWS Dashboard too, and that was an eye-opener. . .

We are so conditioned to past usage that we forget you guys can only work with what is available. Sorry  ;)
Oregon Scientific WMR200 + Weather Display in Windows 10