Openweathermap new "One Call" API

Hi Fabien, I suffer from the same issue. I’ve resigned myself to accept that’s the API’s limitation. Would be great if I could get the rain for today, and, define at what time of the day it updates.

Maybe, I missunderstand something, but why don’t you just additionally use the “Current weather data” API.
It gives you the rain of today’s last 3h.
This should be sufficient, to calculate the total rain for today.
Joerg

Hi @Joerg_Schreiner
I dont see how to use the “Current weather” that you mentionned for my use case.
Perhaps I am not clear with my explanations : I want to know exactly the rain volume for the CURRENT day between 00h00 and 13h00 in my example. (to decide wether mower starts or not, dry ground or not)
The native API offers this, as-is (anytime for current day).
The binding offers this for PREVIOUS days only, not current day.
Until this binding limitation is resolved, I have to use the native API call in a specific http request (onecall/timemachine) and parse myself the result… in other words all the job of the binding :grinning:
That works … but I would prefer to use the binding of course.

Hi @funcat,
could you share some more details about your workaround?
I´m facing the same issue, would like to base the decision whether my automatic plant watering should be triggered on the amount of rain in the past hours.
Thanks in advance!

Hi @Alessandro
Sorry i have no access to my dev environment currently.
But I can tell you that I do a URL/HTTP request directly to openweathermap API, and I parse the result in a rule. Be carefull : when there is no rain data, the field disappears in the response (for the specified hour) > the field only appears when there is actualy rain data.
I spent so much time to understand this behavior … :upside_down_face:

Hi all,

I’m testing the “one call” API in the Openweathermap binding, and I’ve an issue with the Weather Warnings.

@cweitkamp @Wolfgang1966 @MPH1980 sorry to bother you, when you have time may I ask you to have a look at?

thank you very much, your support is really appreciated :slight_smile:

Andrea

Hi @ariela , may you describe the issue you have in detail?

@funcat and @flpaoli: Sorry, I somehow missed the conversation you had last summer. I can’t promise anything, but maybe I find some time to have a look at this issue also.

1 Like

oops … I was describing the issue, when magically (after few hours) the items start receiving the right values from openweathermap.

So, no issues for now. :slight_smile: Thanks for that
Andrea

But I have another question @Wolfgang1966 :slight_smile:

Considering the weather warnings, and type/level (that now are both included in the “event” item) is there any other option than use a transformation for having split event and level of warning?

thanks
Andrea

Hi @ariela ,

I’m afraid that trying to semantically interpret the “event” wording is more that error prone. The weather alerts come from multiple sources ( One Call API: weather data for any geographical coordinate - OpenWeatherMap ). Depending on the source wording might be different, so I think a transformation based on the specific alerts you receive is the best way to handle them. The alerts API Global Weather Alerts - OpenWeatherMap provides a more detailed response with the attributes you need but unfortunately is not available for free and not (yet?) supported by the binding.

2 Likes

Playing with some features in the sitemap, I’ve perhaps found a good compromise :slight_smile:

Let me know what you think :slight_smile:

my items:

String OpenWeatherMap_Alerts1_Event         "[%s]"                                      (gWeather)                                 { channel="openweathermap:onecall:api:local:alerts1#event" }
String OpenWeatherMap_Alerts1_Description   "[%s]"                                      (gWeather)                                 { channel="openweathermap:onecall:api:local:alerts1#description" }
DateTime OpenWeatherMap_Alerts1_Onset       "[%1$td/%1$tm - %1$tH:%1$tM]"               (gWeather)                                 { channel="openweathermap:onecall:api:local:alerts1#onset" }
DateTime OpenWeatherMap_Alerts1_Expires     "[%1$td/%1$tm - %1$tH:%1$tM]"               (gWeather)                                 { channel="openweathermap:onecall:api:local:alerts1#expires" }
String OpenWeatherMap_Alerts1_Source        "[%s]"                                      (gWeather)                                 { channel="openweathermap:onecall:api:local:alerts1#source" }
String Converted_OpenWeatherMap_Alerts1_Duration "[%s]"                                 (gWeather)

the item “Converted_OpenWeatherMap_Alerts1_Duration” is just the result of a concat rule (onset + expires).

my sitemap:

    Text item=Converted_OpenWeatherMap_Alerts1_Duration label="Moderate" icon="meteoalarm_thunder2" visibility=[OpenWeatherMap_Alerts1_Event=="Yellow Thunderstorm Warning"]
    Text item=Converted_OpenWeatherMap_Alerts1_Duration label="Severe" icon="meteoalarm_thunder3" visibility=[OpenWeatherMap_Alerts1_Event=="Orange Thunderstorm Warning"]
    Text item=Converted_OpenWeatherMap_Alerts1_Duration label="Extreme" icon="meteoalarm_thunder4" visibility=[OpenWeatherMap_Alerts1_Event=="Red Thunderstorm Warning"]

in this way you have enough flexibility how the “event” wording is done from the specific source of your Country.

The result is not that bad :slight_smile:

edit: I’m using a orange/red/purple scheme for my icons, as the yellow is not visible enough

I’m sorry, but it seems the issue stands.

Not sure what I’m missing but I have always a UNDEF value for each item. But if I try to check via a normal http request (like: https://api.openweathermap.org/data/2.5/onecall?lat=45.465051&lon=9.094615&&appid=xxxxxxxxxx) I can see now data in eg. alerts.0.event (Yellow Thunderstorm Warning).

Here my items:

String OpenWeatherMap_Alerts1_Event         "[%s]"                                      (gWeather)                                 { channel="openweathermap:onecall:api:local:alerts1#event" }
String OpenWeatherMap_Alerts1_Description   "[%s]"                                      (gWeather)                                 { channel="openweathermap:onecall:api:local:alerts1#description" }
DateTime OpenWeatherMap_Alerts1_Onset       "[%1$td/%1$tm - %1$tH:%1$tM]"               (gWeather)                                 { channel="openweathermap:onecall:api:local:alerts1#onset" }
DateTime OpenWeatherMap_Alerts1_Expires     "[%1$td/%1$tm - %1$tH:%1$tM]"               (gWeather)                                 { channel="openweathermap:onecall:api:local:alerts1#expires" }
String OpenWeatherMap_Alerts1_Source        "[%s]" 

here my things file:

Bridge openweathermap:weather-api:api "OpenWeatherMap Account" @ "Accounts" [apikey="xxxxxxxxxxxxxxxxxxxxx", refreshInterval=10, language="en"] {
    Thing onecall local "Weather And Forecast - Local" @ "Outdoor" [location="45.465051,9.094615", forecastHours=24, forecastDays=6, numberOfAlerts=5]
}

What I’m missing? :frowning:
Andrea

Now I see the first warning correctly, and matching what I can see with a HTTP request (yellow thunderstorm warning).

But, with the HTTP request I can see also the second warning … that is not visible via binding (yellow rain warning).

of course the second group of items is identical

String OpenWeatherMap_Alerts2_Event         "[%s]"                                      (gWeather)                                 { channel="openweathermap:onecall:api:local:alerts2#event" }
String OpenWeatherMap_Alerts2_Description   "[%s]"                                      (gWeather)                                 { channel="openweathermap:onecall:api:local:alerts2#description" }
DateTime OpenWeatherMap_Alerts2_Onset       "[%1$td/%1$tm - %1$tH:%1$tM]"               (gWeather)                                 { channel="openweathermap:onecall:api:local:alerts2#onset" }
DateTime OpenWeatherMap_Alerts2_Expires     "[%1$td/%1$tm - %1$tH:%1$tM]"               (gWeather)                                 { channel="openweathermap:onecall:api:local:alerts2#expires" }
String OpenWeatherMap_Alerts2_Source        "[%s]"                                      (gWeather)                                 { channel="openweathermap:onecall:api:local:alerts2#source" }
String Converted_OpenWeatherMap_Alerts2_Duration "[%s]"                                 (gWeather)

@ariela
I had a quick look at the code and probably found the issue.
In the following if statement it should be alerts.size() >= count instead. Otherwise, I think, the last alert in the API response is always ignored (or not updated, respectively).

@Wolfgang1966 what do you think?

2 Likes

I submitted a PR that should fix the issue

EDIT: seems it was just quick enough to make it into OH 3.3 M5 :wink:

2 Likes

Thank you guy :slight_smile: appreciated

Andrea

@boehan unfortunately it seems not fixed yet on 3.3.M5. Now there is a warning in openweathermap, but this is not reflected in the binding :frowning:

Andrea

Hmm… I will check in the evening, but I’m actually not sure if the fix really made it into the M5 release. Even though it is listed in the release notes, I can’t find it in the build summary. @Kai could you please confirm if the release notes for M5 are correct and #12697 made it into the release?

@ariela you could try to install the fixed binding manually → JAR file: JFrog

I’ll do and back to you as soon as I’ll see other warnings here

I can confirm that the release notes are NOT correct as I have just checked the listed changes on our Jenkins at openhab-milestone 3.3.0.M5 (#51) Changes [Jenkins] and this PR does not turn up there. It must have been merged slightly after the add-ons build started and just before I compiled the release notes. :frowning:
I have now corrected the release notes and have to ask for your patience as the fix will then only be in M6.

1 Like