WeatherCompany binding (WeatherUnderground replacement for PWS data uploaders only!)

Hi Mark,
I installed the weather company Observations and I works together with my weather station at home. My problem is the unit. Wunderground sent the values in Fahrenheit.
My log:
2020-07-18 08:12:52.683 [vent.ItemStateChangedEvent] - Temperatur_Outside changed from 57.0 to 62.6
My item:
Number Temperatur_Outside "Aussentemperatur [%.1f C]" <temperature> (EG_Wohnzimmer) [ "CurrentTemperature" ] {channel='weathercompany:weather-observations:ff55d7d5:currentTemperature'}

I want the value in Celsius. Do you have a solution?
Found the mistake:" Number:Temperatur" instead of "Number!

Yep. That’s it!

Just dropping this here for anyone interested to use as a base for their own tinkering, or improving via pull requests. Hope it’s useful to someone besides myself.

2 Likes

Very nice!

Thanks @watou

Looks great!

Hi Mark,
I installed the weather company binding. In the thing Weather Company Forecast all Items 
Wind Speed show an incorrect value (today 1.0 km/h).
The correct value according to the website is higher (around 4.0 km/h today).
Do you have a solution?
Many thanks,
Gisela

You’ve not provided much information to help me understand the issue, let alone find the solution. The binding displays the information it receives from the Weather Company API. I have no idea what web site you’re referring to.

In the Paper UI the value for the item “wind speed” shows 1 km/h:

But the correct value i my Weather Company API is more than 1 km/h:

Why is the value in the item “wind speed” wrong? All other items show the correct values from the API.

I’m not sure why you keep saying it’s wrong. If you put the binding in debug mode, you’ll be able to see what’s being returned by the Weather Company API. If the binding is showing something different than that, then please post the debug log, the item definition, and the value of the item from the karaf console or event log. You’ll want to look at the Wind Speed values from the Day0 (today) day and night dayparts.

Note that the value returned from the WC API might be in Imperial units, so you may need to convert the units.

Assuming they match, I have a couple of other thoughts:

  • It looks like you’re showing a screen snip from the Weather Underground web site. I’m not certain that the API and the Weather Underground UI are guaranteed to match.

  • Also, you appear to be looking at the Weather Underground hourly forecast, versus the Weather Company API, which is a twice a day forecast. I can’t imagine how those could match other than by pure coincidence.

  • Lastly, I have no idea what IBM may be doing behind the scenes with these different assets they acquired (Weather Underground, The Weather Company, and potentially others). What I do know is that things took a turn for the worse with Weather Underground following the IBM acquisition. :roll_eyes:

Configuration of the WindSpeed Items:

Number:Speed WCF_Day0_Day_WindSpeed “WindSpeed [%.0f %unit%]” { channel=“weathercompany:weather-forecast:xxx:forecastDay0Day#windSpeed” }
Number:Speed WCF_Day0_Night_WindSpeed “WindSpeed [%.0f %unit%]” { channel=“weathercompany:weather-forecast:xxx:forecastDay0Night#windSpeed” }

Values WindSpeed in de API (https://api.weather.com/v3/wx/forecast/daily/5day?geocode=
):

{“dayOfWeek”:[“Samstag”,“Sonntag”,“Montag”,“Dienstag”,“Mittwoch”,“Donnerstag”],
“windSpeed”:[null,6,7,7,6,6,6,5,7,7,6,5],“wxPhraseLong”:[null,“ZunĂ€chst bedeckt/SpĂ€ter aufklarend”,“Bedeckt”,“Bedeckt”,“Wolkig”,“SpĂ€ter leichter Regen”,“Leichter Regen”,“Schauer”,“Schauer”,“ZunĂ€chst Schauer”,“Stark bewölkt”,“Stark bewölkt”],“wxPhraseShort”:[null,“”,“”,“”,“”,“”,“”,“”,“”,“”,“”,“”]}]}

Values from event.log:

2020-10-31 19:19:12.707 [thome.event.ItemStateEvent] - WCF_Day0_Night_WindSpeed updated to 2.0 km/h

2020-10-31 19:24:14.607 [thome.event.ItemStateEvent] - WeatherCompanyForecast_ForecastDay1Day_WindSpeed updated to 3.0 km/h

2020-10-31 19:24:14.707 [thome.event.ItemStateEvent] - WeatherCompanyForecast_ForecastDay1Night_WindSpeed updated to 3.0 km/h

2020-10-31 19:24:14.833 [thome.event.ItemStateEvent] - WeatherCompanyForecast_ForecastDay2Day_WindSpeed updated to 2.0 km/h

2020-10-31 19:24:14.965 [thome.event.ItemStateEvent] - WeatherCompanyForecast_ForecastDay2Night_WindSpeed updated to 2.0 km/h

2020-10-31 19:24:15.060 [thome.event.ItemStateEvent] - WeatherCompanyForecast_ForecastDay3Day_WindSpeed updated to 2.0 km/h

2020-10-31 19:24:15.163 [thome.event.ItemStateEvent] - WeatherCompanyForecast_ForecastDay3Night_WindSpeed updated to 2.0 km/h

2020-10-31 19:24:15.269 [thome.event.ItemStateEvent] - WeatherCompanyForecast_ForecastDay4Day_WindSpeed updated to 3.0 km/h

2020-10-31 19:24:15.368 [thome.event.ItemStateEvent] - WeatherCompanyForecast_ForecastDay4Night_WindSpeed updated to 3.0 km/h

Note: the first log item (named WCF_
) is configured in my items text-file the other items in the log with name beginning WeatherCompanyForecast_
 are configured directly in de Paper UI.

Please don‘t use screenshots but post your config and logs using code fences.

Thanks for posting the detail. I think I see what’s wrong.

The speed values returned from the API are in meters per second. However, the binding is updating the state using the returned value, but with the units kilometers per hour. I think that explains why the API response is 6 and your item value is 2.

Can you change your item definition from [%.0f %unit%] to [%.3f %unit%]? I expect a wind speed of 6 would result in the item value of 1.667. If so, that that would confirm it.

So, whatever wind speed value is being returned by the API, the item would be that value divided by 3.6.

Now the item value is: 2.000 km/h instead of 5 km/h

Log: 2020-11-01 21:15:12.634 [thome.event.ItemStateEvent] - WCF_Day0_Night_WindSpeed updated to 2.000 km/h

API: “windSpeed”:[null,5,6,6,6,5,8,7,7,6,5,5]

Hmm. That’s not what I expected.

Just to be clear, these values are in meters per second.

I built a new version of the binding that properly sets the wind speed units to meters per second instead of kph. Can you uninstall the version you’re running, then put this version in your addons directory?

https://github.com/mhilbush/openhab-binding-releases/blob/master/weathercompany/org.openhab.binding.weathercompany-2.5.10-SNAPSHOT.jar?raw=true

Thank you very much for the quick fix!

Well, I’m not 100% sure that will fix the issue.

Let me know what you’re seeing in the event log. It should be the same as the value you see in the API response, and the units should be meters per second.

Here the datas from today:

Log:
2020-11-02 09:12:47.352 [DEBUG] [andler.WeatherCompanyForecastHandler] - Parsing daypartsObject: [{“windSpeed”:[2.0,2.0,3.0,2.0,4.0,3.0,3.0,2.0,2.0,1.0,2.0,2.0]}]

API:
{“windSpeed”:[6,5,7,6,8,7,7,6,5,4,4,5]}]}

Items in Paper-UI:
Daytime Weather Forecast for Today
WindSpeed 7.2 km/h

Night-time Weather Forecast for Tonight
WindSpeed 7.2 km/h

I think its not yet fixed.

I need these three bits of information. Thanks.

  1. The Wind Speed item definitions for Day 0 Day and Night

  2. Put the binding in TRACE mode, then post the complete response returned by the API, as well as the URL that the binding executed (please XXXXX out your API key).

  3. The entries from the event log for the Wind Speed item updates.

Also, please post the binding version from the console (i.e. list -s | grep weathercompany)

On my test system, which I just changed from Imperial to Metric, I see the following:

Item definition

Number:Speed WC_Day0_Day_WindSpeed "Wind Speed [%.1f km/h]" <wind> { channel="weathercompany:weather-forecast:myaccount:local:forecastDay0Day#windSpeed" }

Returned from the API (as seen in log with TRACE mode enabled). These values are in meters per second (yes, it’s pretty windy today).

"windSpeed":[10,5,6,0,2,1,3,1,1,0,1,0]

In event log

2020-11-02 10:06:47.738 [INFO ] [marthome.event.ItemStateChangedEvent] - Item 'WC_Day0_Day_WindSpeed' changed from 35.99994240006911596313921474304011 km/h to 36.0 km/h

Conversion factor from m/s to km/h is 3.6, so this looks correct to me.

Here the information you need and I can get:

  1. items definition

Number:Speed WCF_Day0_Day_WindSpeed “WindSpeed [%.3f %unit%]” { channel=“weathercompany:weather-forecast:0624b450:forecastDay0Day#windSpeed” }

Number:Speed WCF_Day0_Night_WindSpeed “WindSpeed [%.3f %unit%]” { channel=“weathercompany:weather-forecast:0624b450:forecastDay0Night#windSpeed” }

  1. API response
    Response:

2020-11-02 19:45:47.233 [DEBUG] [andler.WeatherCompanyForecastHandler] - Parsing daypartsObject: [{“cloudCover”:[null,91.0,97.0,97.0,95.0,96.0,92.0,74.0,49.0,35.0,21.0,42.0],“dayOrNight”:[null,“N”,“D”,“N”,“D”,“N”,“D”,“N”,“D”,“N”,“D”,“N”],“daypartName”:[null,“Heute Abend”,“Morgen”,“Morgen Abend”,“Mittwoch”,“Mittwochnacht”,“Donnerstag”,“Donnerstagnacht”,“Freitag”,“Freitagnacht”,“Samstag”,“Samstagnacht”],“iconCode”:[null,11.0,12.0,11.0,11.0,26.0,26.0,27.0,30.0,29.0,34.0,29.0],“iconCodeExtend”:[null,1201.0,1200.0,1100.0,1100.0,2600.0,2600.0,2700.0,3000.0,2900.0,3400.0,2900.0],“narrative”:[null,“Leichter Regen. Tiefsttemperatur 12C. Wind aus WSW und wechselhaft. Regenrisiko 90 %.”,“Regen. Höchsttemperatur 13C. Wind aus NW mit 2 bis 4 m/s. Regenrisiko 90 %. Niederschlag ca. 6 mm.”,“Schauer. Tiefsttemperatur 6C. Wind aus NW und wechselhaft. Regenrisiko 70 %.”,“Schauer. Höchsttemperatur 7C. Wind aus NO mit 2 bis 4 m/s. Regenrisiko 60 %.”,“Bedeckt. Tiefsttemperatur 5C. Wind aus NNO mit 2 bis 4 m/s.”,“Bedeckt. Höchsttemperatur 8C. Wind aus NO mit 2 bis 4 m/s.”,“Meistens bedeckt. Tiefsttemperatur 5C. Wind aus NNO und wechselhaft.”,“Teilweise bedeckt. Höchsttemperatur 11C. Wind aus O und wechselhaft.”,“Teilweise bedeckt. Tiefsttemperatur 5C. Wind aus SSW und wechselhaft.”,“Meistens klar. Höchsttemperatur 14C. Wind aus SSW und wechselhaft.”,“Teilweise bedeckt. Tiefsttemperatur 6C. Wind aus SW und wechselhaft.”],“precipChance”:[null,90.0,90.0,70.0,60.0,20.0,20.0,20.0,20.0,10.0,10.0,10.0],“precipType”:[null,“rain”,“rain”,“rain”,“rain”,“rain”,“rain”,“rain”,“rain”,“rain”,“rain”,“rain”],“qpf”:[null,2.7,5.86,2.47,1.83,0.0,0.0,0.0,0.0,0.0,0.0,0.0],“qpfSnow”:[null,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],“qualifierCode”:[null,null,null,null,null,null,null,null,null,null,null,null],“qualifierPhrase”:[null,null,null,null,null,null,null,null,null,null,null,null],“relativeHumidity”:[null,85.0,93.0,92.0,91.0,96.0,90.0,93.0,86.0,90.0,77.0,82.0],“snowRange”:[null,“”,“”,“”,“”,“”,“”,“”,“”,“”,“”,“”],“temperature”:[null,12.0,13.0,6.0,7.0,5.0,8.0,5.0,11.0,5.0,14.0,6.0],“temperatureHeatIndex”:[null,16.0,12.0,9.0,7.0,7.0,8.0,8.0,10.0,7.0,13.0,8.0],“temperatureWindChill”:[null,13.0,8.0,6.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,5.0],“thunderCategory”:[null,null,null,null,null,null,null,null,null,null,null,null],“thunderIndex”:[null,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],“uvDescription”:[null,“Niedrig”,“Niedrig”,“Niedrig”,“Niedrig”,“Niedrig”,“Niedrig”,“Niedrig”,“Niedrig”,“Niedrig”,“Niedrig”,“Niedrig”],“uvIndex”:[null,0.0,1.0,0.0,1.0,0.0,1.0,0.0,2.0,0.0,2.0,0.0],“windDirection”:[null,254.0,309.0,306.0,38.0,28.0,49.0,19.0,93.0,210.0,200.0,216.0],“windDirectionCardinal”:[null,“WSW”,“NW”,“NW”,“NO”,“NNO”,“NO”,“NNO”,“O”,“SSW”,“SSW”,“SW”],“windPhrase”:[null,“Wind aus WSW und wechselhaft.”,“Wind aus NW mit 2 bis 4 m/s.”,“Wind aus NW und wechselhaft.”,“Wind aus NO mit 2 bis 4 m/s.”,“Wind aus NNO mit 2 bis 4 m/s.”,“Wind aus NO mit 2 bis 4 m/s.”,“Wind aus NNO und wechselhaft.”,“Wind aus O und wechselhaft.”,“Wind aus SSW und wechselhaft.”,“Wind aus SSW und wechselhaft.”,“Wind aus SW und wechselhaft.”],“windSpeed”:[null,2.0,3.0,2.0,4.0,3.0,3.0,2.0,2.0,1.0,2.0,1.0],“wxPhraseLong”:[null,“Leichter Regen”,“Regen”,“Schauer”,“Schauer”,“Bedeckt”,“Bedeckt”,“Stark bewölkt”,“Wolkig”,“Wolkig”,“Meist sonnig”,“Wolkig”],“wxPhraseShort”:[null,“”,“”,“”,“”,“”,“”,“”,“”,“”,“”,“”]}]

URL:

Forecast URL is https://api.weather.com/v3/wx/forecast/daily/5day?format=json&language=de-DE&apiKey=XXXXXXXXXXXXXXXXXXXXX&units=s&geocode=47.114,8.0935

How can I get this?

This is my logger and my appender

WeatherCompany Logger
log4j2.logger.WeatherCompany.name = org.openhab.binding.weathercompany
log4j2.logger.WeatherCompany.level = TRACE
log4j2.logger.WeatherCompany.additivity = false
log4j2.logger.WeatherCompany.appenderRefs = WeatherCompany
log4j2.logger.WeatherCompany.appenderRef.WeatherCompany.ref = WeatherCompany

WeatherCompany File Appender - WeatherCompany.log
log4j2.appender.WeatherCompany.name = WeatherCompany
log4j2.appender.WeatherCompany.type = RollingRandomAccessFile
log4j2.appender.WeatherCompany.fileName = ${openhab.logdir}/WeatherCompany.log
log4j2.appender.WeatherCompany.filePattern = ${openhab.logdir}/WeatherCompany.log.%i
log4j2.appender.WeatherCompany.immediateFlush = true
log4j2.appender.WeatherCompany.append = true
log4j2.appender.WeatherCompany.layout.type = PatternLayout
log4j2.appender.WeatherCompany.layout.pattern = %d{yyyy-MM-dd HH:mm:ss.SSS} [%-5.5p] [%-36.36c] - %m%n
log4j2.appender.WeatherCompany.policies.type = Policies
log4j2.appender.WeatherCompany.policies.size.type = SizeBasedTriggeringPolicy
log4j2.appender.WeatherCompany.policies.size.size = 10MB
log4j2.appender.WeatherCompany.strategy.type = DefaultRolloverStrategy
log4j2.appender.WeatherCompany.strategy.max = 10

How can I get this on openhabian?