Since I have an outside temperature sensor which reports to OpenHAB, I wanted to use this sensor as a personal weather station (PWS) on Weather Underground.
The first step is to create a personal weather station: https://www.wunderground.com/weatherstation/overview.asp
You might as well need the OpenHAB HTTP Binding if you don’t have that one installed already. It can be found on https://github.com/openhab/openhab1-addons/wiki/Http-Binding
Next, create the following rule in OpenHAB:
import org.openhab.core.library.types.* import java.lang.Math rule "wu pws submit" when Time cron "0 */1 * * * ?" then var double tempval = (outdoor_temp.state as DecimalType).doubleValue tempval = tempval*9/5+32; var string temp = String::format("%.1f", tempval); var double humval = (outdoor_hum.state as DecimalType).doubleValue var string hum = String::format("%.1f", humval); var double dewval = tempval-(100-humval)/5; var string dew = String::format("%.1f", dewval); sendHttpGetRequest("https://weatherstation.wunderground.com/weatherstation/updateweatherstation.php?action=updateraw&ID=your_station_id&PASSWORD=your_password&dateutc=now&tempf="+temp+"&humidity="+hum+"&dewptf="+dew); end
As I am using Linux, I saved this file to /etc/openhab2/rules/wu_pws.rules
Make sure to change your_station_id and your_password to the details of the personal weather station you’ve created at Weather Underground.
The sensors I am using are outdoor_temp for temperature, and outdoor_hum for humidity. The dewpoint gets calculated by the script based on those two values. If you have more sensors, you can always expand the script and submit more data to the API. For possible API values, see: http://wiki.wunderground.com/index.php/PWS_-_Upload_Protocol
The scripts converts the temperature value from my sensor (Celsius) to Fahrenheit since this is the only value that the API is expecting. If you are using a sensor that reads Fahrenheit, you can remove this conversion.
Now visit the url of your personal weather station at Weather Underground and watch your own sensor data appear!
eryk February 11, 2017