Page 1 of 1

New OpenWeatherMap and VisualCrossing weather forecast scripts available

Posted: Tue 07 Feb 2023 10:18 pm
by saratogaWX
It's been a busy late Jan/early Feb with coding to add two more sources for international, multilingual forecasts:

OpenWeatherMap (https://openweathermap.org) and VisualCrossing (https://visualcrossing.com). Both provide limited-use free API keys available.

Both providers only give one daily icon per-day for their forecasts, (so no day/night displays).
OpenWeatherMap does provide full translations for forecast text.
VisualCrossing provides de (German), en (English), es (Spanish), fi (Finnish), fr (French), it (Italian), pt (Portuguese), ru (Russian), nl (Netherlands), sr (Serbian). Other languages will return in English.

The OpenWeatherMap script page is here and on GitHub here.
The VisualCrossing script page is here and on GitHub here.

The scripts are included in the Base-World template using the update tool with query Base-World,*.Plugin, 07-Feb-2023

Note that Base-* templates also get updated ajax-dashboard.php V1.33, wxforecast.php V1.06 and check-fetch-times.php V1.49 to support the new scripts.

For a DarkSky replacement, I'd suggest using the OpenWeatherMap one as it has the most complete translations for multilingual use.

Re: New OpenWeatherMap and VisualCrossing weather forecast scripts available

Posted: Thu 23 Feb 2023 5:02 pm
by Mapantz
Hi Ken

Great work on the scripts!

I just installed the visualcrossing version..

I've noticed the current conditions says I'm 22,000 miles away from the forecast location, it said 50,000 miles earlier.. :shock:

https://warehamwx.co.uk/visualcrossing.php

Re: New OpenWeatherMap and VisualCrossing weather forecast scripts available

Posted: Thu 23 Feb 2023 5:05 pm
by mcrossley
Mapantz wrote: Thu 23 Feb 2023 5:02 pm I've noticed the current conditions says I'm 22,000 miles away from the forecast location
Well, if you go the long way round the Earth... :lol:

Re: New OpenWeatherMap and VisualCrossing weather forecast scripts available

Posted: Thu 23 Feb 2023 6:48 pm
by saratogaWX
Looks like a bit of bad data from the VisualCrossing JSON

Code: Select all

  "stations": {
    "EGHH": {
      "distance": 22268.0,
      "latitude": 50.78,
      "longitude": -1.83,
      "useCount": 0,
      "id": "EGHH",
      "name": "EGHH",
      "quality": 32,
      "contribution": 0.0
    },
    "EGDY": {
      "distance": 50397.0,
      "latitude": 51.0,
      "longitude": -2.63,
      "useCount": 0,
      "id": "EGDY",
      "name": "EGDY",
      "quality": 50,
      "contribution": 0.0
    },
    "F0344": {
      "distance": 209.0,
      "latitude": 50.687,
      "longitude": -2.113,
      "useCount": 0,
      "id": "F0344",
      "name": "FW0344 Wareham UK",
      "quality": 0,
      "contribution": 0.0
    },

...
I couldn't find in their documentation what the unit of 'distance' is, but I suspect it is in meters .. that would make EGHH 22.3 km away (much more reasonable) :)

Re: New OpenWeatherMap and VisualCrossing weather forecast scripts available

Posted: Thu 23 Feb 2023 9:32 pm
by saratogaWX
Yep.. appears to be in meters for all displays (without any real documentation on their part). :bash:

I've updated VC-forecast.php V2.02 - 23-Feb-2023 to fix Conditions distance display for km or miles and time displays on hourly/conditions

It's on the script page , the github distribution and the update tool for the Saratoga template (Base-World,*-Plugin,23-Feb-2023)

Thanks for spotting the funny business with the distance display. :D

Re: New OpenWeatherMap and VisualCrossing weather forecast scripts available

Posted: Thu 23 Feb 2023 9:48 pm
by Mapantz
No problem!

I've just added the Pirate Weather version too.. I signed up to get an API key, but when I test it, I can't get a forecast: https://warehamwx.co.uk/pirateweather.php

Re: New OpenWeatherMap and VisualCrossing weather forecast scripts available

Posted: Thu 23 Feb 2023 10:05 pm
by saratogaWX
For Pirateweather, after you sign up for an api key, you have to 'subscribe' to the beta service.
Do a view-source of your page, you'll find a JSON return that looks like

Code: Select all

{"message":"Forbidden",
"Subscription":"Ensure that subscribe is clicked for this endpoint: https://pirateweather.net/apis/{somestuff}/Beta",
"Help":"For other issues, please contact api@alexanderrey.ca"}
copy that link to the browser you have logged into pirateweather, and paste that url and hit go. That should get the subscription for your account with pirateweather working and the API key enabled.

They're a bit odd with this extra bit needed to get an API key going.

Re: New OpenWeatherMap and VisualCrossing weather forecast scripts available

Posted: Thu 23 Feb 2023 10:12 pm
by Mapantz
Many thanks, Ken.

One more thing.. not quite sure whether it's a CSS thing my end or not..

This happens to the timeline: https://ibb.co/3hGrYrb

If I do a simple refresh, it goes back to normal. It seems to occur on a mobile screen more often than desktop.

Re: New OpenWeatherMap and VisualCrossing weather forecast scripts available

Posted: Thu 23 Feb 2023 10:19 pm
by saratogaWX
I've seen that too on occasion. It didn't hang around long enough for me to debug, but I suspect the MerryTimeline JavaScript is having a problem with the Browser DOM that gets flushed when the page is reloaded. I'll need to keep the browser tools enabled while multiple reloads are done to see if a console error is logged so further diagnosis is possible. I dislike transient phenomena with modern browsers.. :twisted:

Re: New OpenWeatherMap and VisualCrossing weather forecast scripts available

Posted: Thu 23 Feb 2023 10:25 pm
by Mapantz
:lol:

Phew! I thought something in my own CSS file was conflicting with it?! hehe

I've got the Pirate weather one working now.

The observations distance doesn't like me: "Weather conditions at 0 km from forecast point"

https://warehamwx.co.uk/pirateweather.php

Great scripts though. I use them all of the time, and many of my visitors do as well. :clap:

Re: New OpenWeatherMap and VisualCrossing weather forecast scripts available

Posted: Thu 23 Feb 2023 11:06 pm
by saratogaWX
In Pirateweather JSON, the "nearest-station" : 0 data in "flags" is used for that conditions display. That works with DarkSky (who's API this mimics).

Maybe Pirateweather just hasn't set that variable for the "currently" display and defaults to zero. Don't know, but I'll ask on the API github issues area.

Re: New OpenWeatherMap and VisualCrossing weather forecast scripts available

Posted: Fri 24 Feb 2023 5:37 pm
by saratogaWX
I heard back from the developer. The nearest-station is always zero.
At the moment PirateWeather only integrates model data and does not use station data in the API which is why that value is always zero.
I've released V2.52 of PW-forecast.php which removes the display of that in the Conditions box. Also fixed the time displays to use am/pm for US and 24hr for other units settings.

Now on scripts page, github distribution and in the update tool for the templates.

Re: New OpenWeatherMap and VisualCrossing weather forecast scripts available

Posted: Sat 03 Feb 2024 2:17 am
by JennyLeez
I just want to say thank you to all those who worked on this project especially Ken :)
Through lack of time I had ignored losing the Dark sky forecast but since I am currently trying to fix all errors php8 has caused I decided to search for a replacement and here it was..........

Just 1 comment re the API key.
Openweather insists on a subscriptions to one of their plans which entails adding ones credit card. Yes well that wasn't going to happen :)

Private Weather appears a bit messy going on Ken's words above so I ended up using Visual Crossing. No cards, no nonsense, API assigned on signing up and I have 1000 page hits a day.

Again thank you to those above :)

Cheers
Jenny