Skip to content

Wunderground Update Receiver Binding ​

Many personal weather stations or similar devices are only capable of submitting measurements to the wunderground.com update site.

This binding enables acting as a receiver of updates from devices that post measurements to https://rtupdate.wunderground.com/weatherstation/updateweatherstation.php. If the hostname is configurable - as on weather stations based on the Fine Offset Electronics WH2600-IP - this is simple, otherwise you have to set up dns such that it resolves the above hostname to your server, without preventing the server from resolving the proper ip if you want to forward the request.

The server thus listens at http(s)://<your-openHAB-server>:<openHAB-port>/weatherstation/updateweatherstation.php and the device needs to be pointed at this address. If you can't configure the device itself to submit to an alternate hostname you would need to set up a dns server that resolves rtupdate.wunderground.com to the IP-address of your server and provide it as the DHCP dns-server to the device. Make sure not to use this dns server instance for any other DHCP clients.

The request is in itself simple to parse, so by redirecting it to your openHAB server you can intercept the values and use them to control items in your home. E.g. use measured wind-speed to close an awning or turn on the sprinkler system after some time without rain. This binding allows you to mix and match products from various manufacturers that otherwise have a closed system.

If you wish to pass the measurements on to rtupdate.wunderground.com, you can use a simple rule that triggers on the wundergroundupdatereceiver:wundergroundUpdateReceiver:<channel-id>:metadata#last-query-trigger to do so. It can also be used to submit the same measurements to multiple weather services via multiple rules.

Supported Things ​

Any device that sends weather measurement updates to the wunderground.com update URLs is supported. Multiple devices submitting to the same wunderground account ID can be aggregated. It is easiest to use with devices that have a configurable target address, but can be made to work with any internet-connected device, that gets its dns server via DHCP or where the DNS server can be set.

Discovery ​

The binding starts listening at the above-mentioned URI as soon as it is initialized. Any request with an unregistered stationId is recorded and if auto-discovery is enabled appears in the inbox, otherwise can be registered when a manual scan is initiated. For each request parameter a channel is generated, based on a list of known parameters from https://support.weather.com/s/article/PWS-Upload-Protocol?language=en_US and other observed parameters from various devices. If you have a device that submits a parameter that is unknown in the current version of the binding please feel free to submit an issue to have it added.

While discovery is active, either in the background or during a manual scan, any request parameters that don't have a channel associated with them are added to the Thing's channels. This supports using multiple devices that submit measurements to the same station ID. The Thing is the wunderground account, not the individual devices submitting measurements.

Thing Configuration ​

The only configurable value is the station id, which should match the one configured on the device. If you don't plan on submitting measurements to wunderground.com, it can be any unique non-empty string value, otherwise it must be the actual station ID.

Channels ​

Each measurement type the wunderground.com update service accepts has a channel. The channels must be named exactly as the request parameter they receive. I.e. the wind speed channel must be named windspeedmph as that is the request parameter name defined by Wunderground in their API. Illegal channel id characters are converted to -. For example, AqPM2.5 has a channel named AqPM2-5. The channel name set up in the binding should be considered an id with no semantic content other than pointing to the wunderground API. Additionally there is a receipt timestamp and a trigger channel.

Request parameters are mapped to one of the following channel-types ​

Normal channel-types ​

Request parameterChannel type idTypeLabelDescriptionGroup
winddirwind-directionNumber:AngleCurrent Wind DirectionCurrent wind directionWind
windspeedmphwind-speedNumber:SpeedCurrent Wind SpeedCurrent wind speed, using software specific time period.Wind
windgustmphwind-gust-speedNumber:SpeedCurrent Gust SpeedCurrent wind gust speed, using software specific time period.Wind
windgustdirwind-gust-directionNumber:AngleGust DirectionCurrent wind gust direction expressed as an angle using software specific time period.Wind
tempftemperatureNumber:TemperatureOutdoor TemperatureCurrent outdoor temperatureTemperature
indoortempfindoor-temperatureNumber:TemperatureIndoor TemperatureIndoor temperature.Temperature
raininrainNumber:LengthHourly RainRain over the past hour.Rain
dailyraininrain-dailyNumber:LengthDaily RainRain since the start of the day.Rain
solarradiationsolarradiationNumber:IntensitySolar RadiationSolar radiationSun
UVuvNumber:DimensionlessUV IndexUV index.Sun
humidityhumidityNumber:DimensionlessHumidityHumidity in %.Humidity
indoorhumidityindoor-humidityNumber:DimensionlessIndoor HumidityIndoor humidity in %.Humidity
barominbarometric-pressureNumber:PressureBarometric PressureBarometric pressure.Pressure

Advanced channel-types ​

Request parameterChannel type idTypeLabelDescriptionGroup
windspdmph_avg2mwind-speed-avg-2minNumber:SpeedWind Speed 2min Average2 minute average wind speed.Wind
winddir_avg2mwind-direction-avg-2minNumber:AngleWind Direction 2min Average2 minute average wind direction.Wind
windgustmph_10mwind-gust-speed-10minNumber:SpeedGust Speed 10min Average10 minute average gust speed.Wind
windgustdir_10mwind-gust-direction-10minNumber:AngleGust Direction 10min Average10 minute average gust direction.Wind
windchillfwind-chillNumber:TemperatureWind ChillThe apparent wind chill temperature.Temperature
soiltempfsoil-temperatureNumber:TemperatureSoil TemperatureSoil temperature.Temperature
weeklyraininrain-weeklyNumber:LengthWeekly RainRain since the start of this week.Rain
monthlyraininrain-monthlyNumber:LengthMonthly RainRain since the start if this month.Rain
yearlyraininrain-yearlyNumber:LengthYearly RainRain since the start of this year.Rain
weathermetarStringMETAR Weather ReportMETAR formatted weather reportSun_Clouds
cloudscloudsStringCloud CoverMETAR style cloud cover.Sun_Clouds
visibilityvisibilityNumber:LengthVisibilityVisibility.Sun_Clouds
dewptfdew-pointNumber:TemperatureDew PointOutdoor dew point.Humidity
soilmoisturesoil-moistureNumber:DimensionlessSoil MoistureSoil moisture in %.Moisture
leafwetnessleafwetnessNumber:DimensionlessLeaf WetnessLeaf wetness in %.Moisture
AqNOnitric-oxideNumber:DimensionlessNitric OxideNitric Oxide ppm.Pollution
AqNO2Tnitrogen-dioxide-measuredNumber:DimensionlessNitrogen DioxideNitrogen Dioxide, true measure ppb.Pollution
AqNO2nitrogen-dioxide-nox-noNumber:DimensionlessNO2 X computedNO2 computed, NOx-NO ppb.Pollution
AqNO2Ynitrogen-dioxide-noy-noNumber:DimensionlessNO2 Y computed, NOy-NO ppbNO2 computed, NOy-NO ppb.Pollution
AqNOXnitrogen-oxidesNumber:DimensionlessNitrogen OxidesNitrogen Oxides ppb.Pollution
AqNOYtotal-reactive-nitrogenNumber:DimensionlessTotal Reactive NitrogenTotal reactive nitrogen.Pollution
AqNO3no3-ionNumber:DensityNO3 ionNO3 ion (nitrate, not adjusted for ammonium ion) µG/m3.Pollution
AqSO4so4-ionNumber:DensitySO4 ionSO4 ion (sulfate, not adjusted for ammonium ion) µG/m3.Pollution
AqSO2sulfur-dioxideNumber:DimensionlessSulfur DioxideSulfur Dioxide, conventional ppb.Pollution
AqSO2Tsulfur-dioxide-trace-levelsNumber:DimensionlessSulfur Dioxide Trace LevelsSulfur Dioxide, trace levels ppb.Pollution
AqCOcarbon-monoxideNumber:DimensionlessCarbon MonoxideCarbon Monoxide, conventional ppm.Pollution
AqCOTcarbon-monoxide-trace-levelsNumber:DimensionlessCarbon Monoxide Trace LevelsCarbon Monoxide, trace levels ppb.Pollution
AqECelemental-carbonNumber:DensityElemental CarbonElemental Carbon, PM2.5 µG/m3.Pollution
AqOCorganic-carbonNumber:DensityOrganic CarbonOrganic Carbon, not adjusted for oxygen and hydrogen, PM2.5 µG/m3.Pollution
AqBCblack-carbonNumber:DensityBlack CarbonBlack Carbon at 880 nm, µG/m3.Pollution
AqUV-AETHaethalometerNumber:DensitySecond Channel of Aethalometersecond channel of Aethalometer at 370 nm, µG/m3.Pollution
AqPM2.5pm2_5-massNumber:DensityPM2.5 MassPM2.5 mass, µG/m3.Pollution
AqPM10pm10-massNumber:DensityPM10 MassPM10 mass, µG/m3.Pollution
AqOZONEozoneNumber:DimensionlessOzoneOzone, ppb.Pollution

Metadata channel-types ​

Request parameterChannel type idTypeLabelDescriptionGroup
dateutcdateutcStringLast UpdatedThe date and time of the last update in UTC as submitted by the device. This can be 'now'.Metadata
softwaretypesoftwaretypeStringSoftware TypeA software type string from the deviceMetadata
rtfreqrealtime-frequencyNumberRealtime FrequencyHow often does the device submit measurementsMetadata
lowbattsystem:low-batterySwitchLow BatteryLow battery warning with possible values on (low battery) and off (battery ok)Metadata

Synthetic channel-types. These are programmatically added ​

Channel type idTypeChannel typeLabelDescriptionGroup
dateutc-datetimedateutc-datetimestateLast Updated as DateTimeThe date and time of the last update in UTC as submitted by the device converted to a DateTime value. In case of 'now', the current time is used.Metadata
last-received-datetimeDateTimestateLast ReceivedThe date and time of the last update.Metadata
last-query-stateStringstateThe last queryThe query part of the last request from the deviceMetadata
last-query-triggerStringtriggerThe last queryThe query part of the last request from the deviceMetadata

The trigger channel's payload is the last querystring, so the following dsl rule script would send the measurements on to wunderground.com:

rules
val requestQuery = receivedEvent
sendHttpGetRequest("https://rtupdate.wunderground.com/weatherstation/updateweatherstation.php?" + requestQuery)

The PASSWORD, action and realtime parameters are ignored, as they are wunderground technical constants, that devices must send. The ID parameter is used to identify the correct Thing the request pertains to, i.e. the stationId configuration value.

As described by the wunderground specification a device can submit multiple values for the outdoor temperature, soil temperature, soil moisture and leaf wetness channels by inserting an index number into the name of the request parameter, fx. tempf can be temp1f, temp2f, etc. This is supported by the discovery mechanism, creating a channel for each of the values.

Examples ​

Thing file ​

Configuration using Thing and item files is not the recommended method, as you have to manually replicate the configuration discovery produces. Channels must be named as the request parameters in the channel type table, otherwise the binding will not be able to update with values from requests. So the request parameter names submitted by your particular device(s) need to be found before being able to write appropriate thing files. You need to intercept a request from your devices(s) using something like wireshark. Both thing and item files must be created manually to produce a result practically identical to the one produced through automatic discovery.

Assuming you have intercepted a request such as https://rtupdate.wunderground.com/weatherstation/updateweatherstation.php?ID=MYSTATIONID&PASSWORD=XXXXXX&windspeedmph=3.11&dateutc=2021-02-07%2014:04:03&softwaretype=WH2600%20V2.2.8&action=updateraw&realtime=1&rtfreq=5, you can configure a Thing to intercept the request thus:

dsl
Thing wundergroundupdatereceiver:wundergroundUpdateReceiver:ATHINGID "Foo" [stationId="MYSTATIONID"] {
    Channels:
        Type wind-speed : windspeedmph []
        Type dateutc : dateutc []
        Type softwaretype : softwaretype []
        Type realtime-frequency : rtfreq []
        Type dateutc-datetime : dateutc-datetime []
        Type last-received-datetime : last-received-datetime []
        Type last-query-state : last-query-state []
        Type last-query-trigger : last-query-trigger []
}

The pattern for a given channel is Type <channel type id> : <request parameter> [] from the channel types table. Casing of the request parameter is significant. None of the current channels take config.

Item file ​

dsl
Number:Speed WuBinding_WeatherStation_WindSpeed "Current Wind Speed [%.2f %unit%]" <wind> { channel="wundergroundupdatereceiver:wundergroundUpdateReceiver:ATHINGID:windspeedmph" }
DateTime WuBinding_LastReceived "Last Received Time [%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS]" <time> { channel="wundergroundupdatereceiver:wundergroundUpdateReceiver:ATHINGID:last-received-datetime" }

The binding tries to post received values as the item types described in the channel types table, so attaching a channel that takes a given type to an item of a different type has undefined behaviour.

Rule examples ​

You can use the trigger channel to create a rule to calculate additional values. Create a new manual Item with a meaningful id, fx. WundergroundUpdateReceiverBinging_HeatIndex with a Number type. Create a rule that triggers when the trigger channel is updated and the following DSL:

rules
    if ( (WH2k6_OutdoorTemperature.state != NULL) && (WH2k6_OutdoorTemperature.state != UNDEF) &&
         (WH2k6_Humidity.state != NULL)           && (WH2k6_Humidity.state != UNDEF)
       )
    {
        val Double tempf    = (WH2k6_OutdoorTemperature.state as QuantityType<Number>).toUnit("°F").doubleValue
        val Double humidity = (WH2k6_Humidity.state           as QuantityType<Number>).toUnit("%").doubleValue

        // https://www.wpc.ncep.noaa.gov/html/heatindex_equation.shtml
        if ( tempf>=80.0 ) {
            var Double heatindex = -42.379 + 2.04901523*tempf + 10.14333127*humidity - 0.22475541*tempf*humidity - 0.00683783*tempf*tempf - 0.05481717*humidity*humidity + 0.00122874*tempf*tempf*humidity + 0.00085282*tempf*humidity*humidity - 0.00000199*tempf*tempf*humidity*humidity;

            if ( (humidity <= 13.0) && (tempf >= 80.0) && (tempf <= 112.0) ) {
                heatindex = heatindex - ((13.0 - humidity)/4.0) * (Math::sqrt(17.0-Math::abs(tempf-95.0)/17.0));
            } else if ( (humidity >= 85.0) && (tempf >= 80.0) && (tempf <= 87.0) )  {
                heatindex = heatindex + ((humidity - 85.0)/10.0)*((87.0-tempf)/5.0);
            }
            WundergroundUpdateReceiverBinging_HeatIndex.postUpdate(heatindex + "°F")
        } else {
            WundergroundUpdateReceiverBinging_HeatIndex.postUpdate(UNDEF)
        }
    }

You would then have to trigger another rule to submit the original request with any calculated values appended.

You can also define a transformation to fx. get a cardinal direction (N, S, W, E):

javascript
(function(s){
  if ( (s == "NULL") || (s == "UNDEF") )
  {
      return undefined;
  }
  else
  {
    var dir = ["N ⬇️", "NNO ⬇️", "NO ↙️", "ONO ⬅️", "O ⬅️", "OSO ⬅️", "SO ↖️", "SSO ⬆️", "S ⬆️", "SSW ⬆️", "SW ↗️", "WSW ➡️", "W ➡️", "WNW ➡️", "NW ↘️", "NNW ⬇️"];   var wind          = parseInt(s.split(" ")[0]);
    var winddiroffset = (wind + (360.0/32.0)) % 360.0;
    var winddiridx    = Math.floor(winddiroffset / (360.0/16.0));
    var winddir       = dir[winddiridx];

    return winddir + ' ('+ wind +'°)';
  }
})(input)

The examples were kindly provided by MikeTheTux.