Announcing OpenWeatherMap binding for Eclipse SmartHome / openHAB

weather
openweathermap
Tags: #<Tag:0x00007f51e44d5ef8> #<Tag:0x00007f51e44d5cf0>

(Andreas) #203

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.


(Rossko57) #204

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=


(Andreas) #205

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.


(Last of the Ronnies) #206

Hi Christoph,
Thanks for your work on this project. Would you mind updating the github page to modify the “demo.things” so that the example uses the capital B in bridge?

bridge openweathermap:weather-api:api "OpenWeatherMap Account"...

should be:

Bridge openweathermap:weather-api:api "OpenWeatherMap Account"...

Otherwise it presents me with the tricky error:


==> /var/log/openhab2/openhab.log <==
2019-01-14 21:40:51.691 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'openweather.things' has errors, therefore ignoring it: [1,22]: missing EOF at ':'

Thanks once again, R.


(Vincent Regaud) #207

It has been done
The docs are updated


(Rossko57) #208

I had a play with the interactive REST API, I do not believe location is editable. Maybe that’s a useful enhancement to ask for.


(Andreas) #209

Looks like I did not describe the problem enough in detail:

Assume you have the bridge setup, and now want to create a new binding for a location, using the Rest API.
The way I see it I need to create a single JSON object with unique UID, bridgeUID, thingTypeUID, configuration, and many many channels (“Station Id”, “Station Name”, “Location”, “Observation Time”, “Weather Condition”, “Weather Condition Id”, “Icon”, “Outdoor Temperature”, “Barometric Pressure”, “Atmospheric Humidity”, “Wind Speed”, “Wind Direction”, “Gust Speed”, “Cloudiness”, “Rain”, “Snow”, “Forecast Time”, “Forecasted Weather Condition”, “Weather Condition Id”, “Condition Icon”, “Forecasted Temperature”, “Forecasted Pressure”, “Forecasted Humidity”, “Forecasted Wind Speed”, “Forecasted Wind Direction”, “Forecasted Gust Speed”, “Forecasted Cloudiness”, “Forecasted Rain”, “Forecasted Snow”) - each channel filled in with the proper details again (uid, channelTypeUID, itemType, label, description, …) and a few more.

You see, that’s quite cumbersome, errorprone, and not really safe if something changes in this list in the future.

I was hoping for a way where I just submit the top level information and get all the channels created and filled and linked in automatically.


(Edward Moyse) #210

Super naive question I’m sure (sorry!) but since it seems like this has been in for a while, why don’t I see this under Add-ons -> Bindings in Paper UI for openHAB 2.4.0 Build #1406? If I search for weather I get:

  • Weather Binding
  • WeatherUnderground Binding
  • Yahoo Weather Binding

(Vincent Regaud) #211

You add ons have been upgraded…
Yahoo was removed in 2.4

Did you do this?

Are you on openhabian? or what platform?


(Edward Moyse) #212

I don’t have include legacy switched on, but yes I’m on openhabian.

I don’t know how I still had yahoo-weather if it was removed in 2.4 - I don’t see it in addons.cfg. :frowning:


(Vincent Regaud) #213

If you had it installed previously it will stay there. It’s just not available anymore.

On openhabian, run the config tool and make sure that the addons are updated


(Last of the Ronnies) #214

Hi Vincent,
This page still has the incorrect example:

Things

demo.things

bridge openweathermap:weather-api:api "OpenWeatherMap Account" [apikey="AAA", refreshInterval=30, language="de"] {
    Thing weather-and-forecast local "Local Weather And Forecast" [location="XXX,YYY", forecastHours=0, forecastDays=7]
    Thing weather-and-forecast miami "Weather And Forecast In Miami" [location="25.782403,-80.264563", forecastHours=24, forecastDays=0]
}

Perhaps you could check it again? Thanks,


(Andreas) #215

Well, cancel that. Creating the “openweathermap:weather-api” thing takes care of this.
Thought it is more complicated …


(Matt) #216

Thank you for this. My wunderground API key I’ve had for years finally got shut off. So migrating over to Open Weather Map for this data.

FYI when I added the account and local things through paper UI, it would not connect and kept saying invalid API key. When I created a thing file with the same information, it worked fine immediately.


(Victor) #217

I have a strange issue.
When I look at the temperature of my city at: https://openweathermap.org it says, let say -6 C

But in the PaperUI under Controls it says -12 C. The temps are always off.

Is this a bug? I can see that the PaperUI is using the same Station ID/Name as on the openweatherMap website but still displays the wrong temperature in openHAB.


(kjunker) #218

Hi Christoph. Great binding, I’m using it with @5iver’s daily forecast and it is a great replacement for Wunderground and at the right time! I have a question about the 1h vs. 3h precipitation (snow/rain). When I hit the rest api for my location, I see a 1h reading (“snow”:{“1h”:0.1}) which means I get station data and not model data. I see in the binding code a call for weatherData.getSnow().get3h() which I assume is looks for the “3h” in the JSON for snow data. Am I reading this correctly? If I add a weatherData.getSnow().get1h() method looking for “1h” would this allow me to return “1h” reading for precipitation?


(Christoph Weitkamp) #219

Hi @kjunker,

Yes, that is correct. The binding tries to read the “3h” property and currently ignores the “1h” property.

Yes, it should work like that. It will be a nice litte improvement if we check both values. Will you submit a PR for it? Will be appreciated. Thanks.


(Olivier Biot) #220

I’d like to create a forecast graph in my sitemap from the 3-hour forecast data spanning 72 hours of forecast window.

How could this be achieved?


(Hans Van Damme) #221

I wanted to do a similar thing, but using Grafana. I solved it with database views.

First, I created a view on each item table, picking up the latest entry and applying a time shift, for example for the snow prediction:

CREATE DEFINER = 'openhab'@'localhost' VIEW Snow30 AS SELECT  30 AS `hours`,  ADDDATE(  NOW(), INTERVAL 30 HOUR) AS `forecastdate`,  `Item560`.`Value` AS `Value`FROM `Item560`ORDER BY `Item560`.`Time` DESC LIMIT 1;
CREATE DEFINER = 'openhab'@'localhost' VIEW Snow66 AS SELECT  66 AS `hours`,  ADDDATE(  NOW(), INTERVAL 66 HOUR) AS `forecastdate`,  `Item559`.`Value` AS `Value`FROM `Item559`ORDER BY `Item559`.`Time` DESC LIMIT 1;
CREATE DEFINER = 'openhab'@'localhost' VIEW Snow18 AS SELECT  18 AS `hours`,  ADDDATE(  NOW(), INTERVAL 18 HOUR) AS `forecastdate`,  `Item558`.`Value` AS `Value`FROM `Item558`ORDER BY `Item558`.`Time` DESC LIMIT 1;
CREATE DEFINER = 'openhab'@'localhost' VIEW Snow39 AS SELECT  39 AS `hours`,  ADDDATE(  NOW(), INTERVAL 39 HOUR) AS `forecastdate`,  `Item557`.`Value` AS `Value`FROM `Item557`ORDER BY `Item557`.`Time` DESC LIMIT 1;
CREATE DEFINER = 'openhab'@'localhost' VIEW Snow57 AS SELECT  57 AS `hours`,  ADDDATE(  NOW(), INTERVAL 57 HOUR) AS `forecastdate`,  `Item556`.`Value` AS `Value`FROM `Item556`ORDER BY `Item556`.`Time` DESC LIMIT 1;
CREATE DEFINER = 'openhab'@'localhost' VIEW Snow54 AS SELECT  54 AS `hours`,  ADDDATE(  NOW(), INTERVAL 54 HOUR) AS `forecastdate`,  `Item555`.`Value` AS `Value`FROM `Item555`ORDER BY `Item555`.`Time` DESC LIMIT 1;
CREATE DEFINER = 'openhab'@'localhost' VIEW Snow21 AS SELECT  21 AS `hours`,  ADDDATE(  NOW(), INTERVAL 21 HOUR) AS `forecastdate`,  `Item554`.`Value` AS `Value`FROM `Item554`ORDER BY `Item554`.`Time` DESC LIMIT 1;
CREATE DEFINER = 'openhab'@'localhost' VIEW Snow27 AS SELECT  27 AS `hours`,  ADDDATE(  NOW(), INTERVAL 27 HOUR) AS `forecastdate`,  `Item553`.`Value` AS `Value`FROM `Item553`ORDER BY `Item553`.`Time` DESC LIMIT 1;
CREATE DEFINER = 'openhab'@'localhost' VIEW Snow42 AS SELECT  42 AS `hours`,  ADDDATE(  NOW(), INTERVAL 42 HOUR) AS `forecastdate`,  `Item552`.`Value` AS `Value`FROM `Item552`ORDER BY `Item552`.`Time` DESC LIMIT 1;
CREATE DEFINER = 'openhab'@'localhost' VIEW Snow33 AS SELECT  33 AS `hours`,  ADDDATE(  NOW(), INTERVAL 33 HOUR) AS `forecastdate`,  `Item551`.`Value` AS `Value`FROM `Item551`ORDER BY `Item551`.`Time` DESC LIMIT 1;
CREATE DEFINER = 'openhab'@'localhost' VIEW Snow45 AS SELECT  45 AS `hours`,  ADDDATE(  NOW(), INTERVAL 45 HOUR) AS `forecastdate`,  `Item550`.`Value` AS `Value`FROM `Item550`ORDER BY `Item550`.`Time` DESC LIMIT 1;
CREATE DEFINER = 'openhab'@'localhost' VIEW Snow69 AS SELECT  69 AS `hours`,  ADDDATE(  NOW(), INTERVAL 69 HOUR) AS `forecastdate`,  `Item549`.`Value` AS `Value`FROM `Item549`ORDER BY `Item549`.`Time` DESC LIMIT 1;
CREATE DEFINER = 'openhab'@'localhost' VIEW Snow15 AS SELECT  15 AS `hours`,  ADDDATE(  NOW(), INTERVAL 15 HOUR) AS `forecastdate`,  `Item548`.`Value` AS `Value`FROM `Item548`ORDER BY `Item548`.`Time` DESC LIMIT 1;
CREATE DEFINER = 'openhab'@'localhost' VIEW Snow48 AS SELECT  48 AS `hours`,  ADDDATE(  NOW(), INTERVAL 48 HOUR) AS `forecastdate`,  `Item547`.`Value` AS `Value`FROM `Item547`ORDER BY `Item547`.`Time` DESC LIMIT 1;
CREATE DEFINER = 'openhab'@'localhost' VIEW Snow63 AS SELECT  63 AS `hours`,  ADDDATE(  NOW(), INTERVAL 63 HOUR) AS `forecastdate`,  `Item546`.`Value` AS `Value`FROM `Item546`ORDER BY `Item546`.`Time` DESC LIMIT 1;
CREATE DEFINER = 'openhab'@'localhost' VIEW Snow24 AS SELECT  24 AS `hours`,  ADDDATE(  NOW(), INTERVAL 24 HOUR) AS `forecastdate`,  `Item545`.`Value` AS `Value`FROM `Item545`ORDER BY `Item545`.`Time` DESC LIMIT 1;
CREATE DEFINER = 'openhab'@'localhost' VIEW Snow60 AS SELECT  60 AS `hours`,  ADDDATE(  NOW(), INTERVAL 60 HOUR) AS `forecastdate`,  `Item544`.`Value` AS `Value`FROM `Item544`ORDER BY `Item544`.`Time` DESC LIMIT 1;
CREATE DEFINER = 'openhab'@'localhost' VIEW Snow36 AS SELECT  36 AS `hours`,  ADDDATE(  NOW(), INTERVAL 36 HOUR) AS `forecastdate`,  `Item543`.`Value` AS `Value`FROM `Item543`ORDER BY `Item543`.`Time` DESC LIMIT 1;
CREATE DEFINER = 'openhab'@'localhost' VIEW Snow51 AS SELECT  51 AS `hours`,  ADDDATE(  NOW(), INTERVAL 51 HOUR) AS `forecastdate`,  `Item542`.`Value` AS `Value`FROM `Item542`ORDER BY `Item542`.`Time` DESC LIMIT 1;
CREATE DEFINER = 'openhab'@'localhost' VIEW Snow3 AS SELECT  3 AS `hours`,  ADDDATE(  NOW(), INTERVAL 3 HOUR) AS `forecastdate`,  `Item541`.`Value` AS `Value`FROM `Item541`ORDER BY `Item541`.`Time` DESC LIMIT 1;
CREATE DEFINER = 'openhab'@'localhost' VIEW Snow9 AS SELECT  9 AS `hours`,  ADDDATE(  NOW(), INTERVAL 9 HOUR) AS `forecastdate`,  `Item540`.`Value` AS `Value`FROM `Item540`ORDER BY `Item540`.`Time` DESC LIMIT 1;
CREATE DEFINER = 'openhab'@'localhost' VIEW Snow12 AS SELECT  12 AS `hours`,  ADDDATE(  NOW(), INTERVAL 12 HOUR) AS `forecastdate`,  `Item539`.`Value` AS `Value`FROM `Item539`ORDER BY `Item539`.`Time` DESC LIMIT 1;
CREATE DEFINER = 'openhab'@'localhost' VIEW Snow6 AS SELECT  6 AS `hours`,  ADDDATE(  NOW(), INTERVAL 6 HOUR) AS `forecastdate`,  `Item538`.`Value` AS `Value`FROM `Item538`ORDER BY `Item538`.`Time` DESC LIMIT 1;
CREATE DEFINER = 'openhab'@'localhost' VIEW Snow0 AS SELECT  0 AS `hours`,  ADDDATE(  NOW(), INTERVAL 0 HOUR) AS `forecastdate`,  `Item537`.`Value` AS `Value`FROM `Item537`ORDER BY `Item537`.`Time` DESC LIMIT 1;

Then I made a union view to pull each record of the above views in one query:

Create DEFINER = 'openhab'@'localhost' VIEW SnowForecast AS
select hours, forecastdate, Value from Snow0 union
select hours, forecastdate, Value from Snow3 union
select hours, forecastdate, Value from Snow6 union
select hours, forecastdate, Value from Snow9 union
select hours, forecastdate, Value from Snow12 union
select hours, forecastdate, Value from Snow15 union
select hours, forecastdate, Value from Snow18 union
select hours, forecastdate, Value from Snow21 union
select hours, forecastdate, Value from Snow24 union
select hours, forecastdate, Value from Snow27 union
select hours, forecastdate, Value from Snow30 union
select hours, forecastdate, Value from Snow33 union
select hours, forecastdate, Value from Snow36 union
select hours, forecastdate, Value from Snow39 union
select hours, forecastdate, Value from Snow42 union
select hours, forecastdate, Value from Snow45 union
select hours, forecastdate, Value from Snow48 union
select hours, forecastdate, Value from Snow51 union
select hours, forecastdate, Value from Snow54 union
select hours, forecastdate, Value from Snow57 union
select hours, forecastdate, Value from Snow60 union
select hours, forecastdate, Value from Snow63 union
select hours, forecastdate, Value from Snow66 union
select hours, forecastdate, Value from Snow69

I did the same for rain and temperature, and use these three as data sources for a Grafana chart. Unfortunately we are not expecting rain or snow in the coming days, so my chart is pretty boring right now:


(Olivier Biot) #222

I see. You’re using MySQL views to generate the data set to graph through Grafana.

At the moment I’m experimenting with InfluxDB and hence I’m still sorting my way into getting the same result. Persisting all forecast data is already a first precondition that I can easily satisfy. Once I have my first forecast data stored, I’ll then be able to experiment in Grafana.