Weather binding in Openhab2

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.

You can get weather data directly from a Netatmo station. Not that it helps you but it may help someone who reads this.

Hi, may have been asked before, but is there any way to change ALL weather data to imperial (ie US) from metric, rather than going through each channel and changing?

Using Google you could have found this link:

In there is a section “units”. Your selected provider might have this feature.

so it looks like each item needs to be changed, thanks (cfg done from papeui as dont want to mess w/ it, it finally works this way).

Having read this thread and others, and looked through the Weather Binding info on git I still cant see what I’m doing wrong and have no weather info on my UI

My weather.cfg is:

My default.items is:
//Default Items File
Number Temperature_OWM “Temperature-OWM [%.2f °C]” {weather=“locationId=home-OWM, type=temperature, property=current”}
Switch RaspberryPI_Online “RaspberryPI_Online” { channel=network:device:192_168_1_208:online }

My default.sitemap is:
// default sitemap
//format is ItemType item=ItemName label=“Description of the item shown on the webpage”
//where ItemType and ItemName must be the same as defined in default.items

sitemap default label=“My first sitemap”
Switch item=RaspberryPI_Online label="RaspberryPI_Online"
Number item=Temperature_OWM label=“Temperature-OWM [%.2f °C]”

The switch item is just to make sure the items and sitemap files were working - OK
If I swap around the order of lines in default.items nothing appears on the BasicUI suggesting that there is something wrong parsing the weather command but I just cant see it. The only other thing that seems strange is that when I ‘nano’ the default.sitemap file that the ‘Switch’ is coloured purple but the ‘Number’ isn’t

Any help appreciated

Oh one thing I see when looking at some other threads, people were asked to show addons.config


Is the fact that the binding is called weather1 (a ‘1’ onthe end) going to mean that the commands the items file should be weather1 not weather?

weather1 means it uses the 1.9 binding.
To use the 2.0 binding, simply use weather.

You mean the Yahoo weather binding (which is 2.x)
The “traditional” weather binding (which is discussed in this thread) is still 1.x

No, the items should be configured with simple weather

I believe that you should use the locationId1 in your items file (not the name home-OWM)

…or change your weather.cfg to

Hi Dim,

Thank you very much, making that change to locationId1 from home-OWM seems to be a step forward. Earlier I turned on TRACE in my logs and can see it now getting weather information from the openweather site.

However, it still doesn’t appear in the sitemap, HABmin or BasicUI. The item ‘Temperature_OWM’ is correct in both files can you see anything else wrong?

Finally I found another config file:
which has a different content (older) to my one in /etc/openhab2/services/weather.cfg should I be worried?

Try to wipe out the configuration by using the Karaf console (don’t forget to move the weather.cfg file outside the services folder)
login to karaf, then


After that, move the weather.cfg back to services and ensure, the configuration was read properly (use the first and second line in Karaf console again)