Weather options for rain data

I have used the weather and recently the wunderground binding over the last few years for my weather data. In part, I use it to calculate total rain received and expected rain to trigger if my irrigation runs or not.

It has come to my attention that wunderground isn’t going to be offering their free api any longer.

I see the yahoo weather binding but that supports temp, humidity and pressure only?

The legacy weather binding supports much more but total precipitation is only support for wunderground. From the doc example:

// new total property in 1.8, only Wunderground
Number   Precip_Total         "Precip total [%d mm]"   {weather="locationId=home, type=precipitation, property=total"}
Number   Precip_Total_Inches  "Precip total [%d in]"   {weather="locationId=home, type=precipitation, property=total, unit=inches"}

I’m already having trouble with the wunderground binding and undef’s so I was going to move back to the weather binding but it doesn’t make sense to use wunderground if it will deprecate at some point that is currently unknown.

Am I missing a good source of rain data?

I won’t get into how lame it is that wunderground leverages 1000’s of personal weather stations and now is going to charge people to access it…

Use the weather binding with the provider Forecastio (now called darkSky)
Free api

Does it support total rain data?

That’s part of my problem, the weather binding’s documentation on what is supported from each provider is virtually nill.

I thought it did but it’s only precipitation intensity.
weatherunderground api is still working for us that got an api before they withdrew the free api.

But it look like they are going to be working for a while

Yeah, I saw that post. Still doesn’t give me the warm fuzzies… I don’t trust IBM.

Well that sucks.

Though I’ve been seeing recently that the service itself has been pretty spotty anyway. About half the time I get “Fatal transport error: Read timed out” when my HTTP binding polls it (I use HTTP and parse out the data instead of the bindings). And their Android app is really starting to suck as well.

Guess it’s time to find another source.

I spent a little time looking into NOAA but it looks like we can not get the forecast percipitation from them either, just the current and past precipitation.

I use OpenWeatherMap in weather binding. Here’s what it’s sending. I believe there’s rain precipitation values larger 0 (if it’s gonna rain, but we’re lucky these days over here in Germany).

2018-06-07 17:30:23.361 [DEBUG] [nal.provider.AbstractWeatherProvider] - OPENWEATHERMAP[home]: Weather[Temperature[current=28.67,min=28.0,max=29.0,feel=30.739108113728843,dewpoint=<null>],Atmosphere[humidity=35,visibility=<null>,pressure=1014.0,pressureTrend=down,ozone=<null>,uvIndex=<null>],Clouds[percent=0],Condition[text=Klarer Himmel,lastUpdate=Thu Jun 07 17:30:23 CEST 2018,observationTime=Thu Jun 07 16:50:00 CEST 2018,id=800,icon=01d,commonId=sunny],Precipitation[rain=0.0,snow=0.0,probability=<null>,total=<null>],Wind[speed=9.359999992512002,direction=NNE,degree=20,gust=<null>,chill=<null>],Station[name=Paderborn,id=<null>,latitude=51.7191,longitude=8.7544,altitude=<null>],<null>]
2018-06-07 17:30:23.366 [DEBUG] [nal.provider.AbstractWeatherProvider] - OPENWEATHERMAP[home]: Forecast[day=0,Temperature[current=<null>,min=18.2,max=27.01,feel=<null>,dewpoint=<null>],Atmosphere[humidity=70,visibility=<null>,pressure=996.03,pressureTrend=<null>,ozone=<null>,uvIndex=<null>],Clouds[percent=20],Condition[text=Ein paar Wolken,lastUpdate=Thu Jun 07 17:30:23 CEST 2018,observationTime=Thu Jun 07 13:00:00 CEST 2018,id=801,icon=02d,commonId=partly-cloudy-day],Precipitation[rain=0.0,snow=0.0,probability=<null>,total=<null>],Wind[speed=7.9919999936064015,direction=SSE,degree=151,gust=<null>,chill=<null>],Station[name=<null>,id=<null>,latitude=<null>,longitude=<null>,altitude=<null>],<null>]
2018-06-07 17:30:23.370 [DEBUG] [nal.provider.AbstractWeatherProvider] - OPENWEATHERMAP[home]: Forecast[day=1,Temperature[current=<null>,min=17.02,max=25.54,feel=<null>,dewpoint=<null>],Atmosphere[humidity=75,visibility=<null>,pressure=995.02,pressureTrend=<null>,ozone=<null>,uvIndex=<null>],Clouds[percent=20],Condition[text=Ein paar Wolken,lastUpdate=Thu Jun 07 17:30:23 CEST 2018,observationTime=Fri Jun 08 13:00:00 CEST 2018,id=801,icon=02d,commonId=partly-cloudy-day],Precipitation[rain=0.0,snow=0.0,probability=<null>,total=<null>],Wind[speed=9.539999992368001,direction=E,degree=81,gust=<null>,chill=<null>],Station[name=<null>,id=<null>,latitude=<null>,longitude=<null>,altitude=<null>],<null>]
2018-06-07 17:30:23.374 [DEBUG] [nal.provider.AbstractWeatherProvider] - OPENWEATHERMAP[home]: Forecast[day=2,Temperature[current=<null>,min=17.86,max=25.23,feel=<null>,dewpoint=<null>],Atmosphere[humidity=75,visibility=<null>,pressure=994.32,pressureTrend=<null>,ozone=<null>,uvIndex=<null>],Clouds[percent=8],Condition[text=Klarer Himmel,lastUpdate=Thu Jun 07 17:30:23 CEST 2018,observationTime=Sat Jun 09 13:00:00 CEST 2018,id=800,icon=02d,commonId=sunny],Precipitation[rain=0.0,snow=0.0,probability=<null>,total=<null>],Wind[speed=9.5759999923392,direction=ENE,degree=58,gust=<null>,chill=<null>],Station[name=<null>,id=<null>,latitude=<null>,longitude=<null>,altitude=<null>],<null>]
2018-06-07 17:30:23.378 [DEBUG] [nal.provider.AbstractWeatherProvider] - OPENWEATHERMAP[home]: Forecast[day=3,Temperature[current=<null>,min=16.31,max=25.28,feel=<null>,dewpoint=<null>],Atmosphere[humidity=78,visibility=<null>,pressure=991.13,pressureTrend=<null>,ozone=<null>,uvIndex=<null>],Clouds[percent=68],Condition[text=Mäßiger Regen,lastUpdate=Thu Jun 07 17:30:23 CEST 2018,observationTime=Sun Jun 10 13:00:00 CEST 2018,id=501,icon=10d,commonId=few-showers],Precipitation[rain=7.77,snow=0.0,probability=<null>,total=<null>],Wind[speed=7.9559999936352,direction=SW,degree=217,gust=<null>,chill=<null>],Station[name=<null>,id=<null>,latitude=<null>,longitude=<null>,altitude=<null>],<null>]
2018-06-07 17:30:23.388 [DEBUG] [nal.provider.AbstractWeatherProvider] - OPENWEATHERMAP[home]: Forecast[day=4,Temperature[current=<null>,min=14.66,max=20.96,feel=<null>,dewpoint=<null>],Atmosphere[humidity=0,visibility=<null>,pressure=1005.66,pressureTrend=<null>,ozone=<null>,uvIndex=<null>],Clouds[percent=60],Condition[text=Starker Regen,lastUpdate=Thu Jun 07 17:30:23 CEST 2018,observationTime=Mon Jun 11 13:00:00 CEST 2018,id=502,icon=10d,commonId=rain],Precipitation[rain=21.29,snow=0.0,probability=<null>,total=<null>],Wind[speed=10.691999991446401,direction=NE,degree=49,gust=<null>,chill=<null>],Station[name=<null>,id=<null>,latitude=<null>,longitude=<null>,altitude=<null>],<null>]

well, I don’t like the look of total=null

Exactly. I assumed it was the wunderground binding as it seemed to start when I switched from the legacy weather binding back in December but maybe it’s the service.

I don’t care that much other than temperature but I have to come up with something solid for forecast rain total for the next day… They make “cloud connected” rain controllers but most of them require subscriptions and my current “dumb” controller works perfectly with my mqtt rain sensor contact. Just need the intelligence to control the contact.

Just so hard to believe none of them have estimated rain total. It’s clear on their GUIs.

I’ve been looking. The key is none of the free APIs offer this. It looks like AccuWeather among other paid services offer it.

I’m shocked that NOAA doesn’t offer it. But try as I could I did not find it.

It could also be that I’m not understanding the fields offered. For example, in OpenWeatherMap they have

list.rain.3h Rain volume for last 3 hours, mm

That description doesn’t even make sense for a forecast. And when you look at the example you see

<precipitation value="5%" unit="3h" type="rain"/>

What? 5% of what? 5% chance of rain?

The NOAA API doesn’t even have precipitation in their results. However, there is a SOAP API they provide that might give more data. But it is much harder to try out SOAP so I can’t tell and all the links to the schemas for the results lead to a 404. They also seem to have another REST API (I guess the first one was a legacy one) and I’m having better luck here.

OK, there appears to be a “Liquid Precipitation Amount” (qpf) field.

So if I look for the min and max temps and the qpf for tomorrow in my city

I get

<?xml version="1.0"?>
<dwml version="1.0" xmlns:xsd="" xmlns:xsi="" xsi:noNamespaceSchemaLocation="">
    <product srsName="WGS 1984" concise-name="time-series" operational-mode="official">
      <title>NOAA's National Weather Service Forecast Data</title>
      <creation-date refresh-frequency="PT1H">2018-06-07T17:12:14Z</creation-date>
      <production-center>Meteorological Development Laboratory<sub-center>Product Generation Branch</sub-center></production-center>
      <point latitude="38.83" longitude="-104.82"/>
    <moreWeatherInformation applicable-location="point1">,-104.82</moreWeatherInformation>
    <time-layout time-coordinate="local" summarization="none">
    <time-layout time-coordinate="local" summarization="none">
    <time-layout time-coordinate="local" summarization="none">
    <parameters applicable-location="point1">
      <temperature type="maximum" units="Fahrenheit" time-layout="k-p24h-n1-1">
        <name>Daily Maximum Temperature</name>
      <temperature type="minimum" units="Fahrenheit" time-layout="k-p24h-n2-2">
        <name>Daily Minimum Temperature</name>
      <precipitation type="liquid" units="inches" time-layout="k-p6h-n4-3">
        <name>Liquid Precipitation Amount</name>

Getting better.

So with the XSLT

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="" xmlns:foo="" xmlns:bar="">
   <xsl:template match="/">
      <xsl:value-of select="sum(/dwml/data//precipitationvalue)"/>

You can get the sum of the precipitation amounts for tomorrow.

However, this is assuming that the four entries correspond with the start/end times from the corresponding time-layout section of the XML.

I like NOAA since it is the source for a lot of these other services anyway and since it is government provided data, it is unlikely to go away anytime soon.

OK, I’ve been busy with other things.

I’m looking at using the DarkSky API. It exposes hourly average precipitation for the next 48 hours. I can therefore just add 24 of them together at midnight to get the forecast total for the next 24 hours.

I have the http binding pulling the json. I cast it into a text item. I then created a rule that has 24 variables with jsonpath to hold each hour. I can spit them out via loginfo and they are correct (but seemingly strings).

This is where I’m stupidly stuck… I cannot for the life of me find a way to add them together. No matter what I do, it seems they are still strings and therefor at best I can concatenate them together.

weatherjson contains the api’s json response from the http binding.

var raw = weatherjson.state.toString
var Number one = transform("JSONPATH", "$[0].precipProbability", raw)
var Number two = transform("JSONPATH", "$[1].precipProbability", raw)
var Number total = one + two
logInfo("test", total)

It errors out saying could not invoke method: org.eclipse.smarthome.model.script.lib.NumberExtensions.operator_plus(java.lang.Number,java.lang.Number) on instance: null

I assume this is because they are still strings. I’m beating my head against the table here. I’m not finding a lot on variables on the forums, just on items. I would rather not cast 24 items when the variables would do.

I understand they will withdraw the free api to “enhance our relationship with our users”

Try putting “as Number” at the end of the two transform lines

Unfortunately I have tried that already.

I didn’t outline all of the things I have tried as it would be a large post to say the least.

Did you add some logging to see if you are getting the right values in your number variables?


If I put:

logInfo(“Test”, one)

I will get a “0” which is correct. I assume it is a string though.

JSONPATH will always return a String. You must convert the String to a Number.

var Number one = new BigDecimal(transform("JSONPATH", "$[0].precipProbability", raw))

This will generate an error if the result of the transform is not precicely a number. There can be no units (e.g. in, F), there can be no extraneous white space.

Yes, I made this assumption… it’s the converting I just can’t seem to get right.

I tried var Number one = new decimaltype… previously and that didn’t work. I just tried BigDecimal just like you have it and I get a different error. In VSCode, it doesn’t like BigDecimal either. Says it is undefined.

	logInfo("Test", "Rule Triggered")
	val raw = weatherjson.state.toString
	var Number one = new BigDecimal(transform("JSONPATH", "$[0].precipProbability", raw))
	var Number two = new BigDecimal(transform("JSONPATH", "$[1].precipProbability", raw))
	logInfo("test", one)
	logInfo("test", two)
	var Number total = one + two
	logInfo("test", total)

Error: Rule ‘test’: An error occurred during the script execution: null

I found that if I comment out the last four lines, same error so it must be caught on the BigDecimal part.

Wait, I figured it out… well… Rich figured it out… as usual:

I needed Float::parseFloat:

	logInfo("Test", "Rule Triggered")
	val raw = weatherjson.state.toString
	var Number one = Float::parseFloat(transform("JSONPATH", "$[0].precipProbability", raw))
	var Number two = Float::parseFloat(transform("JSONPATH", "$[1].precipProbability", raw))
	logInfo("test", one.toString)
	logInfo("test", two.toString)
	var Number total = one + two
	logInfo("test", total.toString)

spit out:

2018-06-18 16:47:29.998 [INFO ] [.eclipse.smarthome.model.script.Test] - Rule Triggered
2018-06-18 16:47:30.004 [INFO ] [.eclipse.smarthome.model.script.test] - 0.02
2018-06-18 16:47:30.005 [INFO ] [.eclipse.smarthome.model.script.test] - 0.06
2018-06-18 16:47:30.008 [INFO ] [.eclipse.smarthome.model.script.test] - 0.08

Exactly what I wanted.

I was hoping to avoid the conversion to a primitive. But it looks like it manages to convert the primitives back to a Number object with the addition so you are good to go.

I’m surprised BigDecimal isn’t available as all the Numbers used in the Rules DSL are BigDecimals. Not the worse inconsistency in the Rules DSL but still annoying.