OpenHAB - Weather binding configuration example

Read carefully the official Weather Binding documentation.

ATTENTION! This is an OpenHAB 1 binding, it works but requires some workarounds.

With OpenWeatherMap service the forecasts do not work anymore.

On OpenWeatherMap web site they declare that with the free plan there are also the 5 days forecasts but after the registration they are set to 0.

Reading on forum you can discover that the forecasts (day by day selectable) are only the 16 days one. Switching from beta to final version the 1 day forecast is no more included in free plan.

The OpenHAB binding still uses the old APIs that are no more included.

5gg{city ID}

16gg{city name},{country code}&cnt={cnt}

It's no more possible to specify a single day but only the full 5-day period.

After some tests with OpenWeatherMap service I switched to Wundergound service. It's easy. After creating a new account on another service provider you can find/change the new name on all items configured or comment the old one and use the same name on the new configuration without changing anything else.

In services/weather.cfg


Using the HTML panel example on the Weather Binding documentation requires some tricks, learned by the OpenHAB community, because in OH2 the folder used to publish web pages changed from the one of OH1.

The weather-data example explained on the example must be moved on /etc/openhab2/html (the old html content folder) and a symbolic link must be created in /var/lib/openhab2/webapps (the new path):

cd /var/lib/openhab2/webapps/
ln -s /etc/openhab2/html/weather-data/ weather-data

Some icons contained in images must be copied:

sunny.png -> clear.png
mostly-cloudy-day.png -> mostly-cloudy.png
partly-cloudy-day.png -> partly-cloudy.png

in order to be compatible with all the weather services that also provide the icon names in forecast. Some services supplies a link to their own icons instead.

To modify the log level by hand you can edit the file:


To show in a single string two values, for example wind speed and direction, a rule is needed:

in weather.items

Number  Wind_Speed  " [%.2f km/h]"    (Weather)   {weather="locationId=roma, type=wind, property=speed"}
String  Wind_Direction  " [%s]"       (Weather)   {weather="locationId=roma, type=wind, property=direction"}
String  Wind    "Vento [%s]"    

A new Wind item has been created with no references. It's used to concat the two strings in a single one:

rule "concat"
  Item Wind_Speed received update or
  Item Wind_Direction received update
  Wind.postUpdate(Wind_Speed.state.toString + " km/h  " + Wind_Direction.state.toString)

In sitemap

Text item=Wind

Recently a new, OH2.2 compatible WeatherUnderground Binding is available. It uses the new things system and is easier to config.

Instead of using the text file editing example shown in the documentation, it's much better to leave the paper UI creating the things and use those to declare the items

ONLY when the service is ONLINE you can use the things, linking them to your items. The service is ONLINE when configured with the correct API WeatherUnderground key

After linking the channels to the item as explained on the binding documentation:

String   Station            "Stazione [%s]"                                 <home>          (Weather)   {channel="weatherunderground:weather:Roma:current#location"}
Number   Temperature        "Temperatura Esterna [%.1f °C]"                 <temperature>   (Weather)   {channel="weatherunderground:weather:Roma:current#temperature"}
Number   Temp_Min           "Temperatura min [%.1f °C]"                     <temperature>   (Weather)   {channel="weatherunderground:weather:Roma:current#minTemperature"}
Number   Temp_Max           "Temperatura max [%.1f °C]"                     <temperature>   (Weather)   {channel="weatherunderground:weather:Roma:current#maxTemperature"}

Number   Temp_Feel          "Temperatura Percepita [%.1f °C]"               <temperature>   (Weather)   {channel="weatherunderground:weather:Roma:current#feelingTemperature"}
Number   Temp_Dewpoint      "Punto di rugiada [%.1f °C]"                    <water>         (Weather)   {channel="weatherunderground:weather:Roma:current#dewPoint"}

Number   Humidity           "Umidità [%d %%]"                               <humidity>      (Weather)   {channel="weatherunderground:weather:Roma:current#relativeHumidity"}
Number   Pressure           "Pressione [%d mBar]"                           <pressure>      (Weather)   {channel="weatherunderground:weather:Roma:current#pressure"}
Number   Visibility         "Visibilità [%.2f km]"                          <zoom>          (Weather)   {channel="weatherunderground:weather:Roma:current#visibility"}
Number   UV_Index           "Indice UV"                                     <sun>           (Weather)   {channel="weatherunderground:weather:Roma:current#UVIndex"}
Number   SolarRadiation     "Irradiazione [%.1f W/m2]"                      <sun>           (Weather)   {channel="weatherunderground:weather:Roma:current#solarRadiation"}

String   Condition          "Condizioni [%s]"                               <sun_clouds>    (Weather)   {channel="weatherunderground:weather:Roma:current#conditions"}
String   Condition_ID       "Condition id [%s]"                             <sun_clouds>    (Weather)   {channel="weatherunderground:weather:Roma:current#conditions"}
DateTime ObservationTime    "Obs [%1$td.%1$tm.%1$tY %1$tH:%1$tM]"           <time>          (Weather)   {channel="weatherunderground:weather:Roma:current#observationTime"}
Number   Rain               "Pioggia [%.2f mm/h]"                           <rain>          (Weather)   {channel="weatherunderground:weather:Roma:current#precipitationHour"}
Number   Precip_Probability "Precip % [%d %%]"                              <rain>          (Weather)   {channel="weatherunderground:weather:Roma:forecastToday#probaPrecipitation"}
Number   Precip_Total       "Precip totali [%d mm]"                         <rain>          (Weather)   {channel="weatherunderground:weather:Roma:forecastToday#precipitationDay"}
Number   Wind_Speed         "Velocità del vento [%.2f km/h]"                <wind>          (Weather)   {channel="weatherunderground:weather:Roma:current#windSpeed"}
String   Wind_Direction     "Direzione del vento [%s]"                      <wind>          (Weather)   {channel="weatherunderground:weather:Roma:current#windDirection"}
String   Wind               "Vento [%s]"                                    <wind>
Image    Weather_Icon                                                                       (Weather)   {channel="weatherunderground:weather:Roma:current#icon"}

DateTime ObservationTime0   "Previsioni [(%1$tA)]"                          <time>          (Weather)   {channel="weatherunderground:weather:Roma:forecastToday#forecastTime"}
Number   Temp_Min0          "Temperatura min [%.2f °C]"                     <temperature>   (Weather)   {channel="weatherunderground:weather:Roma:forecastToday#minTemperature"}
Number   Temp_Max0          "Temperatura max [%.2f °C]"                     <temperature>   (Weather)   {channel="weatherunderground:weather:Roma:forecastToday#maxTemperature"}
String   Condition0         "Condizioni [%s]"                               <sun_clouds>    (Weather)   {channel="weatherunderground:weather:Roma:forecastToday#conditions"}
String   Condition_ID0      "Condizioni id [%s]"                            <sun_clouds>    (Weather)   {channel="weatherunderground:weather:Roma:forecastToday#conditions"}

DateTime ObservationTime1   "Previsioni [(%1$tA)]"                          <time>          (Weather)   {channel="weatherunderground:weather:Roma:forecastTomorrow#forecastTime"}
Number   Temp_Min1          "Temperatura min [%.2f °C]"                     <temperature>   (Weather)   {channel="weatherunderground:weather:Roma:forecastTomorrow#minTemperature"}
Number   Temp_Max1          "Temperatura max [%.2f °C]"                     <temperature>   (Weather)   {channel="weatherunderground:weather:Roma:forecastTomorrow#maxTemperature"}
String   Condition1         "Condizioni [%s]"                               <sun_clouds>    (Weather)   {channel="weatherunderground:weather:Roma:forecastTomorrow#conditions"}
String   Condition_ID1      "Condizioni id [%s]"                            <sun_clouds>    (Weather)   {channel="weatherunderground:weather:Roma:forecastTomorrow#conditions"}

DateTime ObservationTime2   "Previsioni [(%1$tA)]"                          <time>          (Weather)   {channel="weatherunderground:weather:Roma:forecastDay2#forecastTime"}
Number   Temp_Min2          "Temperatura min [%.2f °C]"                     <temperature>   (Weather)   {channel="weatherunderground:weather:Roma:forecastDay2#minTemperature"}
Number   Temp_Max2          "Temperatura max [%.2f °C]"                     <temperature>   (Weather)   {channel="weatherunderground:weather:Roma:forecastDay2#maxTemperature"}
String   Condition2         "Condizioni [%s]"                               <sun_clouds>    (Weather)   {channel="weatherunderground:weather:Roma:forecastDay2#conditions"}
String   Condition_ID2      "Condizioni id [%s]"                            <sun_clouds>    (Weather)   {channel="weatherunderground:weather:Roma:forecastDay2#conditions"}

DateTime ObservationTime3   "Previsioni [(%1$tA)]"                          <time>          (Weather)   {channel="weatherunderground:weather:Roma:forecastDay3#forecastTime"}
Number   Temp_Min3          "Temperatura min [%.2f °C]"                     <temperature>   (Weather)   {channel="weatherunderground:weather:Roma:forecastDay3#minTemperature"}
Number   Temp_Max3          "Temperatura max [%.2f °C]"                     <temperature>   (Weather)   {channel="weatherunderground:weather:Roma:forecastDay3#maxTemperature"}
String   Condition3         "Condizioni [%s]"                               <sun_clouds>    (Weather)   {channel="weatherunderground:weather:Roma:forecastDay3#conditions"}
String   Condition_ID3      "Condizioni id [%s]"                            <sun_clouds>    (Weather)   {channel="weatherunderground:weather:Roma:forecastDay3#conditions"}

DateTime ObservationTime4   "Previsioni [(%1$tA)]"                          <time>          (Weather)   {channel="weatherunderground:weather:Roma:forecastDay4#forecastTime"}
Number   Temp_Min4          "Temperatura min [%.2f °C]"                     <temperature>   (Weather)   {channel="weatherunderground:weather:Roma:forecastDay4#minTemperature"}
Number   Temp_Max4          "Temperatura max [%.2f °C]"                     <temperature>   (Weather)   {channel="weatherunderground:weather:Roma:forecastDay4#maxTemperature"}
String   Condition4         "Condizioni [%s]"                               <sun_clouds>    (Weather)   {channel="weatherunderground:weather:Roma:forecastDay4#conditions"}
String   Condition_ID4      "Condizioni id [%s]"                            <sun_clouds>    (Weather)   {channel="weatherunderground:weather:Roma:forecastDay4#conditions"}

DateTime ObservationTime5   "Previsioni [(%1$tA)]"                          <time>          (Weather)   {channel="weatherunderground:weather:Roma:forecastDay5#forecastTime"}
Number   Temp_Min5          "Temperatura min [%.2f °C]"                     <temperature>   (Weather)   {channel="weatherunderground:weather:Roma:forecastDay5#minTemperature"}
Number   Temp_Max5          "Temperatura max [%.2f °C]"                     <temperature>   (Weather)   {channel="weatherunderground:weather:Roma:forecastDay5#maxTemperature"}
String   Condition5         "Condizioni [%s]"                               <sun_clouds>    (Weather)   {channel="weatherunderground:weather:Roma:forecastDay5#conditions"}
String   Condition_ID5      "Condizioni id [%s]"                            <sun_clouds>    (Weather)   {channel="weatherunderground:weather:Roma:forecastDay5#conditions"}

DateTime ObservationTime6   "Previsioni [(%1$tA)]"                          <time>          (Weather)   {channel="weatherunderground:weather:Roma:forecastDay6#forecastTime"}
Number   Temp_Min6          "Temperatura min [%.2f °C]"                     <temperature>   (Weather)   {channel="weatherunderground:weather:Roma:forecastDay6#minTemperature"}
Number   Temp_Max6          "Temperatura max [%.2f °C]"                     <temperature>   (Weather)   {channel="weatherunderground:weather:Roma:forecastDay6#maxTemperature"}
String   Condition6         "Condizioni [%s]"                               <sun_clouds>    (Weather)   {channel="weatherunderground:weather:Roma:forecastDay6#conditions"}
String   Condition_ID6      "Condizioni id [%s]"                            <sun_clouds>    (Weather)   {channel="weatherunderground:weather:Roma:forecastDay6#conditions"}

You can use the items defining them in sitemap to be displayed on a Basic UI:

or Classic UI, as well on the mobile app:

The data can of course be integrated with local measurement, as explained in this article and displayed on an habpanel as in this article

Guido Ottaviani (Author/Designer/Developer for electronics-firmware-robotics)
He deals with electronic design and embedded system firmware for Robotics and industrial and civil applications, as well as technical disclosure on the internet. - -

Le attività del TanzoLab si svolgono ogni mercoledi sera, salvo casi speciali, dalle ore 18:30 presso i locali della Acme Systems srl e consistono in:

  • Talk monotematici a cura di professionisti in vari settori tecnologici
  • Workshop pratici su elettronica embedded, produzione e informatica
  • Progettazione e realizzazione di nuovi prodotti embedded per l'IT

Le attività vengono coordinate tramite questo sito, in cui vengono pubblicati tutti i lavori svolti o in via di sviluppo, e tramite un gruppo Telegram con cui per interagire direttamente via chat con gli altri membri.