Weather binding in Openhab2

Do you have any item that uses the location “myhome”?

I have items in my myhome.items that looks like below:

Number Weather_Temperature “Outside Temperature [%.1f °C]” (Weather, Weather_Chart) {weather=“locationId=myhome, type=temperature, property=current”}

I have corresponding items in my sitemap config.

Just got an idea. May it be so that you need to have other items (not from the weather binding) that also use the same location and sitemap? I have so far tried mostly with only having Weather binding installed. I have the gut feeling that the Weather binding may read files and configs in the wrong order when running in OH2 compared to OH1. This may force it to disable itselfs before it gets to the file with the right settings.

I also have the problem with ghost "locationId"s and so far the only way I have found to remove the old "locationId"s is to make a clean install of OH2.

To remove “ghost” stuff from OH2:

For example (for the weather binding):

config:list "("

Then, OH2 will re-read your /etc/openhab2/services/weather.cfg flat config file and load up the correct info (no need to do a clean install)


Thanks for the pointers Dim. Will try it out next time I see the ghosting.

Another thing regarding the Weather binding. When installing the Weather binding on a clean OpenHab2 installation (on Windows 10 64 bit) I get a warning in the log file:

14:23:46.393 [WARN ] [.weather.internal.bus.WeatherBinding] - Unable to find any configuration settings for weather binding. Check openhab.cfg.

This makes me suspect that the Weather binding is not liking OH2 that much.

On installation it creates the file “openhab\conf\services\weather.cfg”. Once modification is done to the weather.cfg a file named “weather.config” is places in “userdata\config\org\openhab” containing just the active lines. Is this just a backup or is it used by OH2 or the bindings in some way?

Wow, those command really deserve to go into the karaf console docu:

Managed to get my weatherbinding working by following this thread:

Seams most of my problems was due to problems with the .items file.

Is there a known problem? That the min and max temperature is not shown in WUnderground? For OpenWeatherMap i get a result…

Number Weather_Temp_Max			"Tages Maximum [%.2f °C]"		<temperature_hot> 	(gWeather, gWeather_Chart) {weather="locationId=home, type=temperature, property=max"}

Number Weather_Temp_Min			"Tages Minimum [%.2f °C]"		<temperature_cold> 	(gWeather, gWeather_Chart) {weather="locationId=home, type=temperature, property=min"}

# location configuration, you can specify multiple locations, Germany
#location.home.woeid=      (required for Yahoo provider)

Wunderground provides min and max only at the forecast.

off_topic: For German language you must use DL instead of DE. See the api.

Number Temp_Max0 "Temp_Max0 [%.2f °C]" (grp_Weather) {weather="locationId=s, forecast=0, type=temperature, property=max"}

1 Like

Hi guys please help me out:
my weather.cfg: (I used both Yahoo and OpenWeatherMap):

# The apikey for the different weather providers, at least one must be specified
# Note: Hamweather requires two apikeys: client_id=apikey, client_secret=apikey2

# location configuration, you can specify multiple locations
#location.<locationId1>.latitude=   (not required for Yahoo provider)
#location.<locationId1>.longitude=  (not required for Yahoo provider)
location.home.woeid=xx     (required for Yahoo provider)
location.home.updateInterval=10  (not required for Yahoo provider)  (not required for Yahoo provider)      (required for Yahoo provider)


String      Condition_Id    "Weather is [%s]"(Weather)       { weather="locationId=work, type=condition, property=id" }
Number   Temperature_test       "Temperature [%.2f °C]"
{weather="locationId=work, type=temperature, property=current"}
Number   	Humidity_test   "Humidity [%d %%]"	{weather="locationId=work, type=atmosphere, property=humidity"}
Number   	Pressure_test   "Pressure [%.2f mb]" {weather="locationId=work, type=atmosphere, property=pressure"}

I tried to alter the locationId between “home” and “work” but none of that works although I reboot the system soooo many time. The only result I received is “-” on my OH2 sitemap :frowning:
Please help me out! Very frustrating with weather binding in Oh2. In the past when I used this binding with OH1.8.3 everything worked quite smoothly!

You obscured your id as well as the used woeid and Locations. Additionally you Show the “(required for Yahoo provider)”, do you have that in the file as well? Either remove it or mark it as a comment!

1 Like

This looks like a sample .cfg file. Could you show us your actual file (you can change the coordinates to only 1 or 2 decimals of you like for privacy).

Any way, the text “(not required for Yahoo provider)” shouldn’t be in the file.

1 Like

Oh How stupid I am
Indeed it was because of the (not require…) part
I got it done now
However it seems that android app can not display the weather webview
any idea?

I overcame that by displaying a picture of the webview.
However, if you only Show the values of the linked channels (like actual temp, actual weather, …) without the Icons, there is no need for a webview!

OK you mean like:

Image url="/weather?locationId=home&layout=example&iconset=colorful" height=5 refresh=1000

Unfortunately I can’t see the image

No, it’s not that easy!
You Need to have a seperate Software that takes a “screenshot” of your webview, saves it and you display that image.
Sounds to complicated, just show the item states with no (weather-)icons.

After hour of searching I figure this out, I’m really happy to share, explanation is below, I hope this would help someone:

  1. sudo apt-get install xvfb (googling if you do not know what is it)
  2. sudo apt-get install python-qt4
  3. copy this code:
#! /usr/bin/python
import sys
import time
import os
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtWebKit import *
from shutil import copyfile

class Screenshot(QWebView):
    def __init__(self): = QApplication(sys.argv)
        self._loaded = False

    def capture(self, url, output_file):
        # set to webpage size
        frame =
        # render image
        image = QImage(, QImage.Format_ARGB32)
        painter = QPainter(image)
       # print 'saving', output_file

    def wait_load(self, delay=0):
        # process app events until page loaded
        while not self._loaded:
        self._loaded = False

    def _loadFinished(self, result):
        self._loaded = True

s = Screenshot()
s.capture('http://localhost:8080/weather?locationId=home&layout=example&iconset=colorful', filename)

and save under /etc/openhab2/scripts. Then:

sudo chmod a+rwx /etc/openhab2/scripts/

to get rid of the error “permission denied” (just for sure)
You might want to know that s.capture is used for capturing image from your weather webpage

  1. Create the rule:
rule "Periodically update weather-data"
   Time cron Time cron "0 */5 * * * ?" or
   System started
        val String results = executeCommandLine("sudo xvfb-run python /etc/openhab2/scripts/", 300000) 

After the line:

 val String results = executeCommandLine("sudo xvfb-run python /etc/openhab2/scripts/", 300000) 

your website.png (the screenshot image from weather webpage) will be stored under the root directory (the place on the terminal interface when you power up your system), I’m using raspberry pi 3 so you can see my source directory is /home/pi. Change this to adapt your system. This is very important because the website.png is saved under the root directory by default due to the command executeCommandLine(“sudo xvfb-run python /etc/openhab2/scripts/”, 300000) is executed under the root directory.

And the lines:


just merely cut the website.png from destination to source directory, you can change these lines if you know any command can directly cut a file to a desiring path. In my case, I couldn’t find out that command so I had to do this. It’s quite clumsy but it did work after all!
Furthermore, you might want to change the destination path to satisfy yourself.
Personally, I’d like to put website.png under /etc/openhab2/html

In sitemap:

Image url="http://localhost:8080/static/website.png" refresh=10000

The only problem remaining is the resolution of the image is too large, anyway to resize it down ? I do not want to use python code anymore to resize the image, you know, it’s quite complicated and slow to do this way
@opus I hope you can share yours and suggest how can I improve mine, thanks very much

I’ve just installed a weather station and have it sending data to wunderground, which is all working OK there.

My weather.cfg uses the exact same lat/long that is used for the station at wunderground, but i can’t get my own weather station to be the weather station that openhab2 uses … is there any way to force it, please?

Without real deep into it, in my understanding the weather binding of OH is build to GET data. I do believe that there is no way to force which weather station is used by the provider. As a matter of fact, the provider might decide to not use all stations that are reporting to him in his publicated weather reports.

I’ve discovered that wunderground doesn’t seem to be making the data from my station available via its API, so have emailed wunderground to ask what I can do to get it.

I haven’t heard back from wunderground, but I’m now getting the data from my weather station back into openhab - so I guess there was a delay in that part becoming live.