naofireblade / homebridge-weather-plus

A comprehensive weather plugin for homebridge.
MIT License
311 stars 61 forks source link

OpenWeatherMap always shows 'Invalid API key' #244

Closed mj-jackson closed 1 year ago

mj-jackson commented 1 year ago

Just installed Homebridge on a new Raspberry Pi 4 B. Everything is up2date. I installed and configured homebridge-weather-plus as described in the doc. But I cannot get a connection to OpenWeatherMap (Free). I tried a lot different configurations but none worked for me. Here is my example now (very dumped down, disabled all there is to disable, hidden everything there is to hide).

{
            "units": "si",
            "interval": 60,
            "stations": [
                {
                    "nameNow": "Dahoam",
                    "service": "openweathermap",
                    "key": "MyApiKey", // also tried adding a new one, didn't work
                    "locationCity": "Munich", // also tried "Munich, DE", also tried long/lat
                    "language": "de",
                    "compatibility": "home", // also tried Apple Home /w Eve
                    "conditionCategory": "simple",
                    "now": false,
                    "extraHumidity": false,
                    "hidden": [
                        "Air Pressure",
                        "Cloud Cover",
                        "Condition",
                        "Condition Category",
                        "Dew Point",
                        "Forecast Day",
                        "Humidity",
                        "Observation Station",
                        "Observation Time",
                        "Ozone",
                        "Rain",
                        "Rain 1h",
                        "Rain Day",
                        "Rain Chance",
                        "Snow",
                        "Solar Radiation",
                        "Sunrise Time",
                        "Sunset Time",
                        "Temperature Min",
                        "Temperature Apparent",
                        "UV Index",
                        "Visibility",
                        "Wind Direction",
                        "Wind Speed",
                        "Wind Speed Max"
                    ]
                }
            ],
            "platform": "WeatherPlus"
        }

Also used the example config: https://github.com/naofireblade/homebridge-weather-plus#example (with OWM)

Did I miss something?

benzman81 commented 1 year ago

same here @mj-jackson did you solve it?

mj-jackson commented 1 year ago

After a very brief research I found that this plugin uses the data/2.5/onecall api endpoint of open weather map. By the looks of it this endpoint has been discontinued and replaced by the new version data/3.0/onecall. And this endpoint needs a separate subscription to work.

So in theory this plugin should be working as indented (or maybe needs to use the new endpoint, not sure if there is a redirect in place), but the subscriptions needs to be upgraded. (1000 API calls are still free with the needed subscription). https://openweathermap.org/api/one-call-3

For the time being I uninstalled this plugin, installed another one but will most likely create my own.

missflash commented 1 year ago

Same problem to me. Are there any other solutions or update plan?

gNeeUs commented 1 year ago

I would say, in conclusion: Dark Sky is closed, Weather Underground only for those lucky enough to maintain their own weather station, and OpenWeather no longer works due to API snafu. For all intents and purposes this wonderful Weather Plus plugin for Homebridge does not work anymore :-(

Unless anyone has any other explanation or solution, which I’m really hoping for. I do not care to subscribe to the new One Call API 3.0, even though it's supposedly free, it still requires payment information.

gNeeUs commented 1 year ago

Unfortunately, after "upgrading" my API key at openweathermap.org to One Call API 3.0 format (it's still Free up to 1000 calls daily), this plugin still does not work. The error message at startup of Homebridge is as follows:

[9/17/2022, 1:17:21 PM] [WeatherPlus] Error retrieving weather report [9/17/2022, 1:17:21 PM] [WeatherPlus] undefined [9/17/2022, 1:17:21 PM] [WeatherPlus] { cod: 401, message: 'Invalid API key. Please see http://openweathermap.org/faq#error401 for more info.' }

I'm afraid that until the plugin is updated with compatibility for new API keys from openweather, it will fail for users with a key that was obtained just recently. The aforementioned homebridge-ws plugin was recently updated and it is confirmed working (hint).

Faasteer commented 1 year ago

Same problem here. Is there a chance it will be fixed sometime? I'm really wanting to try this plugin. :(

exorsyst commented 1 year ago

Same issue for me as well using the free tier on OWM. Such a shame as the deadline for DarkSky is fast approaching :(

bragg2012 commented 1 year ago

Think I got this working by editing the api file for openweathermap. On my pi this file is located at

/var/lib/homebridge/node_modules/homebridge-weather-plus/apis/openweathermap.js

yours may differ depending on your homebridge set up/system.

I edited line 70 (may differ depending on platform) and swapped the 2.5 to 3.0 and my API key then worked. Since iOS16 the data doesn’t show very well so best to configure this as an eve accessory and add it there for any automations etc so you can get the full data out of the accessory that is added. Hope this helps!

Faasteer commented 1 year ago

Think I got this working by editing the api file for openweathermap. On my pi this file is located at ar/lib/homebridge/node_modules/homebridge-weather-plus/apis/openweathermap.js yours may differ depending on your homebridge set up/system.

I edited line 70 and swapped the 2.5 to 3.0 and my API key then worked. Since iOS16 the data doesn’t show very well so best to configure this as an eve accessory and add it there for any automations etc so you can get the full data out of the accessory that is added. Hope this helps!

You are absolutely right - thank you! This fix has resolved the issue and now the plugin is working again. It's a shame that Apple broke displaying this type of data in iOS16, but the sensors are there and automation can be set up.

By the way, the lines are different in the Synology HB version, but just look for "2.5" (without quotes).

gNeeUs commented 1 year ago

Think I got this working by editing the api file for openweathermap. On my pi this file is located at

/var/lib/homebridge/node_modules/homebridge-weather-plus/apis/openweathermap.js

yours may differ depending on your homebridge set up/system.

I edited line 70 (may differ depending on platform) and swapped the 2.5 to 3.0 and my API key then worked. Since iOS16 the data doesn’t show very well so best to configure this as an eve accessory and add it there for any automations etc so you can get the full data out of the accessory that is added. Hope this helps!

SPLENDID bragg2012! I also can confirm this fixes the API issue. I run Homebridge on a Windows computer and found the configuration file at _C:\Users\USERPROFILE\AppData\Roaming\npm\nodemodules\homebridge-weather-plus\apis\openweathermap.js (where USERPROFILE is the profile of the original Homebridge installation). I have no editor displaying line numbers, but it can be updated with Notepad. In this file I found two occurrences of the API version and it seems important to only change the first one under "getWeatherData(callback)". The second under "getLocationGeo(callback)" should be left alone at 2.5, otherwise it will still create a "404" error at Homebridge startup.

As to display in the iOS Home app, this plugin seems to only expose Temperature (although I'm not sure why there are 3 instances of temperature?) and Humidity, and with Automation it shows a number of unlabeled and useless proximity sensors.

While the Eve app makes far more settings available as "Triggers" (example Wind Speed, UV Index, etc.) I cannot get those to show as accessories by name in the At a Glance screen nor in the list of Rooms as the screenshots of this plugin indicate (unless I'm ignorant and I'm overlooking something).

Either way, I'm happy I can use the many new Triggers from Eve (and likewise as Accessory from the Controller for Homekit app) and I will start putting those to good use.

Thanks for your effort!

missflash commented 1 year ago

Think I got this working by editing the api file for openweathermap. On my pi this file is located at

/var/lib/homebridge/node_modules/homebridge-weather-plus/apis/openweathermap.js

yours may differ depending on your homebridge set up/system.

I edited line 70 (may differ depending on platform) and swapped the 2.5 to 3.0 and my API key then worked. Since iOS16 the data doesn’t show very well so best to configure this as an eve accessory and add it there for any automations etc so you can get the full data out of the accessory that is added. Hope this helps!

Thank you for your great suggestion. In my case, line 237 and 268 need to be modified. (Synology DSM7.1, Docker environments)

NikVandewouwer commented 1 year ago

Allthough this fix is merged and I have v3.2.6 installed I still get an error about invalid API key

[11/17/2022, 9:04:46 AM] [homebridge-weather-plus] Error retrieving weather report
[11/17/2022, 9:04:46 AM] [homebridge-weather-plus] undefined
[11/17/2022, 9:04:46 AM] [homebridge-weather-plus] {
  cod: 401,
  message: 'Invalid API key. Please see https://openweathermap.org/faq#error401 for more info.'
}
kh0r commented 1 year ago

The fix is not yet released in a package. To install the most recent version open up the terminal in homebridge ("top right vertical ellipsis menu"->terminal) and install it from source: npm i --save naofireblade/homebridge-weather-plus

Don't forget to add the "One Call API 3.0" subscription, you should stay well within the free plans limits when using it only for this plugin

sanchezdelreal commented 1 year ago

This error persists. I have no way or knowledge to change to new api ¿detailed instructions? [05/12/2022, 12:21:11] [WeatherPlus] Error retrieving weather report [05/12/2022, 12:21:11] [WeatherPlus] undefined [05/12/2022, 12:21:11] [WeatherPlus] { cod: 401, message: 'Invalid API key. Please see https://openweathermap.org/faq#error401 for more info.' }

davidjbradshaw commented 1 year ago

@sanchezdelreal in the homebridge UI, select the three dot menu in the top right of the screen.

Select Terminal.

Type npm i --save naofireblade/homebridge-weather-plus

Press the Enter key.

Wait till it has finished doing things.

Restart HomeBridge.

naofireblade commented 1 year ago

Fixed in v3.2.7

dppeak commented 1 year ago

This is still happening with the latest v3.2.7.

Do we have to subscribe to the One Call API 3.0? It's no longer free as they're charging 0.0015 per call or 0.15 per 100 calls.

dppeak commented 1 year ago

Rolling back to v3.2.6 resolves the error.

naofireblade commented 1 year ago

As stated in the readme you need to subscribe to the onecallapi 3.0 but 1000 calls per day are still free.

kh0r commented 1 year ago

Do we have to subscribe to the One Call API 3.0? It's no longer free as they're charging 0.0015 per call or 0.15 per 100 calls.

The first 1000 calls per day are free: https://openweathermap.org/price

Which imho perfectly covers personal usage like for this plugin: You can query the API every 5 minutes and would only get 288 calls per day (60/5*24)

naofireblade commented 1 year ago

You can even limit your api calls to 1000 on the owm website so you can never have to pay anything

dppeak commented 1 year ago

Thanks for the clarification. The line item in the billing didn't show the free for first 1000. All working now on the latest version. Thanks for a great plugin!