jclarke0000 / MMM-DarkSkyForecast

Magic Mirror module to display weather information using the Dark Sky API
84 stars 64 forks source link

Add Pirate weather api #36

Open EM1138 opened 1 year ago

EM1138 commented 1 year ago

I discovered that Pirate Weather has created an API designed to be a drop in replacement/ alternative to the Dark Sky API. Could you add this to DarkSkyForecast? Using apiBase: "https://api.pirateweather.net" and my Pirate weather API key in the default weather app for weatherProvider: "darksky" does work. Please see https://pirateweather.net/getting-started for more info. Thank you.

dankerthrone commented 1 year ago

Hi, so you did get this to work? Would you mind sharing your config?

So far, I've adapted the node_helper.js to point to https://api.pirateweather.net/ like you suggested and then configured the module like I normally would. However, that doesn't work for me :-/

Any advice is greatly appreciated.

EM1138 commented 1 year ago

I only changed the config for the default weather module. module: "weather", disabled: false, position: "top_right", config: { weatherProvider: "darksky", apiBase: 'https://api.pirateweather.net/', type: "current", weatherEndpoint: "forecast", lat: MyLat, lon: MyLon, apiKey: PirateWeatherAPI, roundTemp: true, colored: true, fade: false, showHumidity: true
} },

dankerthrone commented 1 year ago

Alright, so for anyone else wanting to use this module with the pirateweather api it's actually really easy. I don't even know enough about coding to implement my solution with a pull request or however one would go about this, but I was able to patch my own system so that this module worked again.

Most of the work is getting the API set up.

Here's what I did:

Reinstall the module from scratch:

cd MagicMirror/modules

rm -r MMM-DarkSkyForecast

git clone https://github.com/jclarke0000/MMM-DarkSkyForecast.git

cd MMM-DarkSkyForecast

npm install

Get Pirateweather API

The Pirateweather dev @alexander0042 has meant for the Pirateweather API to be a drop-in replacement for Dark Sky, so we really don't need to a whole lot. However, signing up for an account at https://pirateweather.net/ is not all - you should read the documentation! Also, don't generate an API-key for the dev version, use "beta" instead to generate an API key for api.pirateweather.net. Then also activate it - luckily the dashboard has a test function built in. However, it generates a test URL that messes up your location. Test it using this template:

https://api.pirateweather.net/forecast/APIKEY/55.03,16.06?units=si

You should get a result. Now, all that's left is telling the module to use a different API. This is done via

Editing node_helper.js

In Line 44, replace "https://api.darksky.net/forecast/" with "https://api.pirateweather.net/forecast/" In your main MM config.js, edit the config to include this module like you want it and paste your API-Key.

Now do

pm2 restart mm

And it should work.

ericjohncarlson commented 1 year ago

@dankerthrone Thanks for the directions there, this worked great for me. It looks like the PirateWeather "beta" is now over, so can just subscribe to the standard API. The only data missing is the longer-form text-based "summary" that was such a nice addition from DarkSky. This is reduced to just "Clear" "Cloudy". However, the rest of the data mapped perfectly and we'll give it a shot.

Pity about the DarkSky API. Was a great source of accurate weather information and a really nice addition to MM.

tcsabina commented 1 year ago

Thanks @dankerthrone for the detailed instructions how to make this work with 'Pirate-weather'. I had some issues login in to 'pirate-weather.apiable.io' after registering using Firefox. But at the end I've managed to login with Edge, and was able to register the free tier.

TATUMTOT commented 1 year ago

@dankerthrone THANK YOU SO MUCH.