OpenWeatherMap-Alerts-Weather-Driver

I have just added the virtual device for the OpenWeatherMap driver. I have had an API key for awhile (don't recall but probably several years). I have the key set to 2.5 and I am getting data into the device. In looking through the logs I do not see any errors in the return data messages. So I believe the interface to OpenWeahterMap and the key are working correctly.

However, the data being returned is not the correct data for my location. In looking through the logs I see that it appears the longitude and latitude being returned in the message are not correct for my location. I am not sure why the coordinates appear to be incorrect.

I see the option to override the Hubitats Long and Lat, but I did not see how to define these once turned on. In addition, I am not sure why my Long and Lat would be wrong for my Hubitat.

Does anybody have any ideas on how to correct this issue?

I run 2.5 and mine is working perfectly and has for ... months?! I always read the OWM posts - and lots of troubles seem to be around the 2.5 vs 3.0 api at the OWM server side. Not saying this is related...
I do not 'override' hub. but there was a time when the hub location wasn't really correct. Take the values from your hub info long /lat and plug em into a webpage to see where you're truly pulling from. Initially, my hub long lat was wrong and I had a few refreshes till it got correct. that was a bout a year ago.

1 Like

I just looked at my Long and Lat in my Hubitat and indeed they are wrong. I don't recall as I have had this hub for a couple of years, do you enter those manually when setting up the hub? In any case I can override those values and that should correct my problem.

Update: I went into Hubitat settings and corrected the Long and Lat with the correct values. However those changes did not get updated for the OpenWeatherMap device. I may need to delete and recreate the device for those changes to work. However, I did turn on "Override Hub's Location Coordinates" in the device and once saved it added the fields to override the Lat and Long. I then entered the correct coordinates and all is working. Thanks jshimota for the info in putting me on the right direction.

1 Like

After about 4 hours, a lot of reading, and pure determination, based on the fact I dont like being beaten by IT, I finally managed to get it working, but it was a hard hard slog!!!

It wasn't clear to me that I needed to make a payment of zero to OpenWeather to get the API working.
It wasn't clear if I needed to use the API with the OpenWeather http, long and lat in the virtual device preferences API key field or just the actual API code.

It wasn't obvious that nothing would show in the virtual device tile if there was nothing in the virtual device current states section.

Nor was it obvious that I needed to put the URL field in the dashboard tile background image link,

I am sure this is all obvious to people who are old hats with Hubitat but for newbies like me, this stuff really needs to be put into a written set of clear easy to follow instructions.

Its a great add-on once its working but compared to Home Assistants weather API which is child's play by comparison, this was hard work.

3 Likes

@user4935 might you have time to put in a document the steps that you took please? I am currently in the shoes you were in attempting to figure out how to implement this as a Hubitat noob.
Greatly appreciate any assistance

As best as I can remember:-

  1. Goto: https://openweathermap.org/ and click API in the top menu bar.

  2. Choose One Call API 3.0 and sign up for the service. You will need to input a payment card such as a credit or debit card however you will not pay anything for 1000 API calls per day or under.

  3. Click your account name in the top menu bar then select My API Keys. You should have at least one API key. This will be required later on.

  4. Download and install the openweathermap alerts driver code from this URL: https://raw.githubusercontent.com/HubitatCommunity/OpenWeatherMap-Alerts-Weather-Driver/master/OpenWeatherMap-Alerts%20Weather%20Driver.groovy You just copy and paste the code in the Drivers Code section in the normal way, i.e click the New Driver button, paste the code into the space provided then click save. If you have package manager search for the driver and install using that method instead.

  5. Go to habitat devices and create a new virtual weather device. Click "Add Device" then "Virtual". Give it a name such as VirtualWeatherMapDevice then for type, open the list and select and click OpenWeatherMap-Alerts- Weather Driver. then click save device.

  6. Now you need to configure the device. In the very first preferences box titled "Type OpenWeatherMap.Org API Key Here * you need to paste the API key that you have in Members that you saw in step 3.

  7. The second box slider in the virtual device preferences page needs to be to the right so that 3.0 is on. Put in your Town or City in the third box. In box 4 & 5 I chose a setting of 1 hour. In box 7 it should be set to 1. In box 8 change the display unit to your preferred setting, C or F.

  8. Change box 12 to your preferred date format. In Box 17 Alternative Icon Location paste https://tinyurl.com/icnqz/ then click the Save Preferences button.

  9. If you scroll back to the top, under Current States you should see weather information including some graphics under the section where it says threedayfcstTile: If not something isnt working so double check what you have done and make sure your OpenWeatherMap status says says Active. Try a new API key just in case there is an issue with the original.

  10. When your virtual driver is showing weather data you can create a dashboard tile. The tile will need to be quite large to display the three day forecast. When creating your tile for Pick A Device choose Open Weather Map Virtual Device and for Pick A Template choose Attribute. Under Options in the Pick An Attribute list choose threedayfcstTile.

This what the tile looks like in my master dashboard:-

Hope that helps.

2 Likes

You are much better off using Hubitat Package Manager to install. That way, the update doesn't have to be done manually when there is a new version. Just search for " OpenWeatherMap-Alerts Weather Driver" within Hubitat Package Manager

1 Like

Yes, a very good point. I didn't have package manager when I installed the weather driver so I just did it manually. Instructions edited to suit.

Thanks, really appreciate this

1 Like

Just search for "OpenWeather" and save yourself some typing.

1 Like

for some reason it isn't working for me
I created account, I pasted my key on hubitat on this driver, tried with both api version toggle etc
is not getting any data, the virtual device remains blank
i really can't imagine what i could be doing wrong, seems pretty straight forward to me

if there are any logs in the HE console -> logs, that may help someone to provide insight.

have noticed the link is wrong, https://api.openweathermap.org/data/2.5/onecall needs to be replaced with https://api.openweathermap.org/data/2.5/weather in the driver code and now it starts fetching some data but the info received is wrong.
I noticed this by looking at the example the website gives you
i'm trying to compare the links and see what's wrong the in GET call

it seems the driver completely ignores the API version and unit system, so i changed in the driver to always ask for 2.5 API and metric system, in the logs the response from weather seems correct now but looking at the virtual device is not fetching this data correctly

dev:16362023-04-28 10:06:50.631errorjava.lang.NullPointerException: Cannot invoke method getAt() on null object on line 543 (method pollOWMHandler)

dev:16362023-04-28 10:06:50.616infoOpenWeatherMap.org Weather Driver - INFO: getCondCode Inputs: 999, true; Result: unknown

dev:16362023-04-28 10:06:50.612infoOpenWeatherMap.org Weather Driver - INFO: getCondCode Inputs: 999, true; Result: unknown

dev:16362023-04-28 10:06:50.598infoOpenWeatherMap.org Weather Driver - INFO: OpenWeatherMap Data: [visibility:10000, timezone:10800, main:[temp:11.54, temp_min:9.58, humidity:61, pressure:1022, feels_like:10.34, temp_max:12.45], clouds:[all:20], sys:[country:RO, sunrise:1682652053, sunset:1682702631, id:2013022, type:2], dt:1682665244, coord:[lon:23.7637, lat:44.3312], weather:[[icon:02d, description:few clouds, main:Clouds, id:801]], name:Craioviţa, cod:200, id:680329, base:stations, wind:[deg:70, speed:1.54]]

dev:16362023-04-28 10:06:50.589infoOpenWeatherMap.org Weather Driver - INFO: Polling OpenWeatherMap.org

dev:16362023-04-28 10:06:50.248infoOpenWeatherMap.org Weather Driver - INFO: Poll OpenWeatherMap.org: [uri:https://api.openweathermap.org/data/2.5/weather?lat=44.331223&lon=23.763721&exclude=minutely,hourly&mode=json&units=metric&appid=censored, timeout:20]

dev:16362023-04-28 10:06:36.099infoOpenWeatherMap.org Weather Driver - INFO: estimateLux results: condition: 999 | condition factor: 0.9966666666666667 | condition text: using cloud cover from API| lux: 5327

dev:16362023-04-28 10:06:36.083infoOpenWeatherMap.org Weather Driver - INFO: Calling UpdateLux(true)

on default driver i get

OpenWeatherMap.org Weather Driver - WARNING: 401:Unauthorized

because of the wrong call link with onecall instead of weather

If you don't have a legacy key, you cannot use 2.5

the driver needs onecall, and if you need a key you need a 3.0 key.

It sounds like you are not getting a 3.0 onecall key, and this is your ongoing problem

The instructions are clear you have to have a onecall key (they don't give 2.5 out any more), they do still provide 3.0 onecall key.

2 Likes

so does this mean i can't use it because they don't use onecall anymore?
the example link from the website always uses weather in link instead of onecall and version 2.5
or maybe the driver can be updated to support the latest type of link?

If you re-read the instructions, you need to get a onecall key. If you don't have one, get a 3.0 one. If you don't use much for calls it ends up free.

is it possible to get the onecall key without adding any card or something or is only paid ?
I don't see how to get it
they say is free for limited requests but I don't see how can I generate it

You do have to put in a cc.. go to your cc provider and create a virtual card, use that.

they won't charge if you use a small number, which you would never exceed with this integration...

1 Like

ok, that did it, now is working, thanks