Announcing OpenWeatherMap binding for Eclipse SmartHome / openHAB

@ngalfas I’m trying this as well and struggling with the icons. “weather-underground-icons” does not work anymore as you get now a number for the condition-id. And the icon that you get out of the image-channel is too small for HabPanel-Integration.

I do it with a MAP transformation…

f.e.: (you need to install the map transformation service in PaperUI
create openweathermap.map in folder openhab2-conf/transform

601=snow
OWM_WEATHER_CONDITION_ID_NUMBER=YOUR_IMAGE

and in your .items file you have something like this:

String owmCurrentConditionId "Current Condition ID [MAP(openweathermap.map):%s]"

EDIT:
Or another way to do it…

Here you are: Support for UV Index API

2 Likes

Hey there,

I need some help figuring out things with this binding - first off, I like this one very much, especially since Wunderground and Yahoo will stop their free API services soon.

I have a working API key for the free plan. I have figured out that I have to add the weather-and-forecast thing using

forecastHours=96, forecastDays=0

(the forecastHours something below 5*12 for the free plan and forecastDays set to zero because otherwise, I end up with @text/offline.conf-error-invalid-apikey errors.

What I am really missing is a hint on how to use forecast data beyond 24 hours. If I try to add items using a channel like openweathermap:weather-and-forecast:api:local:forecastHours48#time-stamp (extrapolating the working items for Hours12 or Hours24), I get nothing (in PaperUI, those don’t even show up in the “Local Weather and Forecast” item list on the “Control” page). In PaperUI, I see items like openweathermap:weather-and-forecast:api:local:forecastTomorrow#time-stamp advertised on the things-page of of the forecast thing, which result in having NULL/NaN data.

Are there any working examples using the free plan with forecast data for 3-5 days?

Hi, this is what i use in my items file…

// Forecast Hour48
Image					owmForecastHour48Icon			"2 Tage Vorhersage Wetterlage Icon"					    {channel="openweathermap:weather-and-forecast:api:local:forecastHours48#icon"}
String					owmForecastHour48Condition		"2 Tage Vorhersage Wetterlage [%s]"					    {channel="openweathermap:weather-and-forecast:api:local:forecastHours48#condition"}
String				    owmForecastHour48ConditionId	"2 Tage Vorhersage Wetterlage ID [%s]"				    {channel="openweathermap:weather-and-forecast:api:local:forecastHours48#condition-id"}
String				    owmForecastHour48IconId			"2 Tage Vorhersage Wetterlage Icon ID"				    {channel="openweathermap:weather-and-forecast:api:local:forecastHours48#icon-id"}
Number:Temperature		owmForecastHour48Temperature	"2 Tage Vorhersage Temperatur [%.1f %unit%]"		    {channel="openweathermap:weather-and-forecast:api:local:forecastHours48#temperature"}
Number:Pressure			owmForecastHour48Pressure		"2 Tage Vorhersage Luftdruck [%.1f %unit%]"			    {channel="openweathermap:weather-and-forecast:api:local:forecastHours48#pressure"}
Number:Dimensionless	owmForecastHour48Humidity		"2 Tage Vorhersage Luftfeuchtigkeit [%.1f %unit%]"	    {channel="openweathermap:weather-and-forecast:api:local:forecastHours48#humidity"}
Number:Speed			owmForecastHour48WindSpeed		"2 Tage Vorhersage Windgeschwindigkeit [%.1f km/h]"	    {channel="openweathermap:weather-and-forecast:api:local:forecastHours48#wind-speed"}
//Number:Dimensionless	owmForecastHour48WindDirection	"2 Tage Vorhersage Windrichtung [SCALE(wind.scale):%s]" {channel="openweathermap:weather-and-forecast:api:local:forecastHours48#wind-direction"}
Number:Angle			owmForecastHour48WindDirection2	"2 Tage Vorhersage Windrichtung [%d %unit%]" {channel="openweathermap:weather-and-forecast:api:local:forecastHours48#wind-direction"}
Number:Dimensionless	owmForecastHour48Cloudiness		"2 Tage Vorhersage Bewölkung [%.1f %unit%]"			    {channel="openweathermap:weather-and-forecast:api:local:forecastHours48#cloudiness"}
Number:Length			owmForecastHour48Rain			"2 Tage Vorhersage Regen [%.1f %unit%]"				    {channel="openweathermap:weather-and-forecast:api:local:forecastHours48#rain"}
Number:Length			owmForecastHour48Snow			"2 Tage Vorhersage Schneefall [%.1f %unit%]"		    {channel="openweathermap:weather-and-forecast:api:local:forecastHours48#snow"}
DateTime    owmForecastHour48Timestamp	"2 Tage Vorhersage Zeit [%1$tA, %1$td.%1$tm.%1$tY %1$tH:%1$tM]"			{channel="openweathermap:weather-and-forecast:api:local:forecastHours48#time-stamp"}

sometimes you have to wait a couple of minutes to get the first data… but works perfectly here…

hope this helps

1 Like
1 Like

I have the same problem as @JoeSey

I installed the binding in OH 2.4 stable, using free openweathermap account.

Things file:

Bridge openweathermap:weather-api:api "OpenWeatherMap Account" [apikey="my_api_key", refreshInterval=10, language="nl"] {
    Thing weather-and-forecast local "Local Weather And Forecast" [location="xxxxx,yyyyy", forecastHours=72, forecastDays=0]
}

In PaperUI, I see forecast channels 3hrs, 6hrs etc. But no channel beyond 24h.

To confirm that this is not related to PaperUI, I looked via the REST api:
http://openhabianpi:8080/rest/things/openweathermap:weather-and-forecast:api:local. I found channels like

openweathermap:weather-and-forecast:api:local:forecastHours24

, but for example no channels with “forecastHours27”, “forecastHours30” etc.

During my experimentation yesterday I believe I saw the channels momentarily, but then they seem to have disappeared after I made an edit to the .things file. Unfortunately I didn’t keep track of my changes. Now I waited about 24hrs to see if they would pop up, but they didn’t.

Any ideas?

1 Like

OK, I solved it by restarting the binding via Karaf:

First I activated debug logging:

openhab> log:set DEBUG org.eclipse.smarthome.binding.openweathermap

Then I found the bundle number and restarted the binding:

youropenhab> bundle:list
<SNIP>
242 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome OpenWeatherMap Binding
openhab> bundle:restart 242

Logging shows that channels and channel groups are created

2019-01-05 11:34:02.794 [me.event.ThingUpdatedEvent] - Thing 'openweathermap:weather-and-forecast:api:local' has been updated.
2019-01-05 11:34:02.897 [hingStatusInfoChangedEvent] - 'openweathermap:weather-api:api' changed from INITIALIZING to UNKNOWN
2019-01-05 11:34:02.916 [hingStatusInfoChangedEvent] - 'openweathermap:weather-api:api' changed from UNINITIALIZED (HANDLER_MISSING_ERROR) to INITIALIZING
==> /var/log/openhab2/openhab.log <==
2019-01-05 11:34:03.055 [DEBUG] [nWeatherMapWeatherAndForecastHandler] - Initialize OpenWeatherMapWeatherAndForecastHandler handler 'openweathermap:weather-and-forecast:api:local'.
2019-01-05 11:34:03.076 [DEBUG] [nWeatherMapWeatherAndForecastHandler] - Rebuilding thing 'openweathermap:weather-and-forecast:api:local'.
2019-01-05 11:34:03.078 [DEBUG] [nWeatherMapWeatherAndForecastHandler] - Rebuilding hourly forecast channel groups.
2019-01-05 11:34:03.080 [DEBUG] [andler.AbstractOpenWeatherMapHandler] - Building channel group 'forecastHours27' for thing 'openweathermap:weather-and-forecast:api:local'.
==> /var/log/openhab2/events.log <==
2019-01-05 11:34:03.107 [hingStatusInfoChangedEvent] - 'openweathermap:weather-and-forecast:api:local' changed from UNINITIALIZED (HANDLER_MISSING_ERROR) to INITIALIZING
2019-01-05 11:34:03.115 [hingStatusInfoChangedEvent] - 'openweathermap:weather-and-forecast:api:local' changed from INITIALIZING to UNKNOWN
==> /var/log/openhab2/openhab.log <==
2019-01-05 11:34:03.136 [DEBUG] [andler.AbstractOpenWeatherMapHandler] - Building channel group 'forecastHours30' for thing 'openweathermap:weather-and-forecast:api:local'.
2019-01-05 11:34:03.170 [DEBUG] [andler.AbstractOpenWeatherMapHandler] - Building channel group 'forecastHours33' for thing 'openweathermap:weather-and-forecast:api:local'.
2019-01-05 11:34:03.251 [DEBUG] [andler.AbstractOpenWeatherMapHandler] - Building channel group 'forecastHours36' for thing 'openweathermap:weather-and-forecast:api:local'.

etc etc etc
1 Like

The binding itself works fine for me on 2.4.0, the log however shows the following errors after a restart. Always for 27#time-stamp, the data is coming fine.

2019-01-06 11:17:51.179 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method ‘ThingHandler.initialize()’ on ‘org.eclipse.smarthome.binding.openweathermap.int
ernal.handler.OpenWeatherMapWeatherAndForecastHandler@9f31238’: Duplicate channels openweathermap:weather-and-forecast:cf7c8411:local:forecastHours27#time-stamp
java.lang.IllegalArgumentException: Duplicate channels openweathermap:weather-and-forecast:cf7c8411:local:forecastHours27#time-stamp
at org.eclipse.smarthome.core.thing.util.ThingHelper.ensureUniqueChannels(ThingHelper.java:159) ~[?:?]
at org.eclipse.smarthome.core.thing.util.ThingHelper.ensureUniqueChannels(ThingHelper.java:151) ~[?:?]
at org.eclipse.smarthome.core.thing.util.ThingHelper.ensureUniqueChannels(ThingHelper.java:147) ~[?:?]
at org.eclipse.smarthome.core.thing.binding.builder.ThingBuilder.withChannel(ThingBuilder.java:74) ~[?:?]
at org.eclipse.smarthome.binding.openweathermap.internal.handler.OpenWeatherMapWeatherAndForecastHandler.initialize(OpenWeatherMapWeatherAndForecastHandler.java:153) ~[?:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]
at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:153) [102:org.eclipse.smarthome.core:0.10.0.oh240]
at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:53) [102:org.eclipse.smarthome.core:0.10.0.oh240]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
at java.lang.Thread.run(Thread.java:748) [?:?]
2019-01-06 11:17:51.216 [ERROR] [core.thing.internal.ThingManagerImpl] - Exception occurred while initializing handler of thing ‘openweathermap:weather-and-forecast:cf7c8411:local’: Duplicate
channels openweathermap:weather-and-forecast:cf7c8411:local:forecastHours27#time-stamp
java.lang.IllegalArgumentException: Duplicate channels openweathermap:weather-and-forecast:cf7c8411:local:forecastHours27#time-stamp
at org.eclipse.smarthome.core.thing.util.ThingHelper.ensureUniqueChannels(ThingHelper.java:159) ~[?:?]
at org.eclipse.smarthome.core.thing.util.ThingHelper.ensureUniqueChannels(ThingHelper.java:151) ~[?:?]
at org.eclipse.smarthome.core.thing.util.ThingHelper.ensureUniqueChannels(ThingHelper.java:147) ~[?:?]
at org.eclipse.smarthome.core.thing.binding.builder.ThingBuilder.withChannel(ThingBuilder.java:74) ~[?:?]
at org.eclipse.smarthome.binding.openweathermap.internal.handler.OpenWeatherMapWeatherAndForecastHandler.initialize(OpenWeatherMapWeatherAndForecastHandler.java:153) ~[?:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]
at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:153) [102:org.eclipse.smarthome.core:0.10.0.oh240]
at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:53) [102:org.eclipse.smarthome.core:0.10.0.oh240]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
at java.lang.Thread.run(Thread.java:748) [?:?]

Unfortunately the quality of data in the free hourly forecast is at least for my location (Bratislava, Slovakia) miserable. I tried to write a rule collecting min and max temperature of the following three days, got weird numbers and started to investigate. I checked on their webpage and the data is inconsistent there as well - e.g. for tomorrow the daily forecast shows -6.1 °C max, -6.7 °C min, the hourly data however contain -3.1 / -10.3. Huh. Two usually reliable sources show -2/-4 and -1/-5, let’s see what the reality is but I highly doubt the -10.

I’m getting an error when trying to install this binding

[ERROR] [core.karaf.internal.FeatureInstaller] - Failed installing 'openhab- 
binding-openweathermap': Error: Resource mvn:org.apache.karaf.jaas/org.apache.karaf.jaas.modules/4.2.1 does not 
contain a manifest

The duplicate channel bug is fixed in the snapshots

Hi Noam,

How did you try to install the binding? Which OH2 version do you use?

Anyone know how to convert the temperature to Fahrenheit? I tried adding units=“imperial” at the end of the thing configuration, but does not seem to help:

Thing weather-and-forecast local "Local Weather And Forecast" [location="42.99, -71.14", forecastHours=0, forecastDays=7, units="imperial" ]

I’ve searched on the OpenWeather site and it reads to get fahrenheit, add units=imperial to the API call, but I am not sure where to add this. I figured on the Thing configuration would be the place, but alas, no. It also did not work not having imperial in quotes.

Thanks,

~John

i’M USING OPENHAB 2.4

installed from the paper ui addon

I have the same question. Not sure how to convert to Fahrenheit.

OpenHAB can do it for you. Just use Fahrenheit in your label. Have a look at https://www.openhab.org/docs/concepts/units-of-measurement.html#numberitem-linked-to-quantitytype-channel

1 Like

Thanks Dominik (@dominikkv), that resolved my issue!

~John

Speaking of API - the openHAB API, not the OWM API:
If I want to add a new location using the API, is there an easy way where I just provide the basic details from the Model Schema for POST /things, or do I have to fill in all the channels manually?
I’m hoping to avoid doing that, because that needs to be updated every time the channel list is changed or updated.

Can that be rephrased as - set up a forecast Thing with all its channels & Items, then later adjust the location of that predefined forecast Thing via REST ?

Thing weather-and-forecast mysterylocation "Local Weather And Forecast" [location=

If it’s just a single, simple API call, yes, that might work. Right now I don’t see a way to avoid manual channel creation, but I might be missing something. Hence my question.