Send data to Weather Underground

Dear all,

i have a weather station and this send the data over mqtt to my HomeAssistant server who store this in InfluxDB.
I catch this data in Node-Red and with functions I create a global variable with all this data.

I have to send this data to Wether Underground website. I try to use this module https://www.npmjs.com/package/wunderground-pws but seem this not work so good because it don't send all the data, I don't know why.... I also try to contact the developer but this don't help me...

This is the function i use to send the date with this module:

var PWS = global.get('PWS');
var pws = new PWS('', '');

pws.setObservations({
tempf: global.get("tempf"),
baromin: global.get("baromin"),
dewptf: global.get("dewptf"),
humidity: global.get("humidity")
});

pws.sendObservations(function(err, success){
// executed after callback
});

So must to find another solution, and I'am thinking about a php import string offer by weather underground but I don't know how to use it.
Here is the explanation http://wiki.wunderground.com/index.php/PWS_-_Upload_Protocol
and this is the exemple of the string:
https://weatherstation.wunderground.com/weatherstation/updateweatherstation.php?ID=XXXXXX&PASSWORD=XXXXXX&dateutc=2000-01-01+10%3A32%3A35&winddir=230&windspeedmph=12&windgustmph=12&tempf=70&rainin=0&baromin=29.1&dewptf=68.2&humidity=90&weather=&clouds=&softwaretype=vws%20versionxx&action=updateraw

of course i have to use only my data not all.
How I can use this method? Can someone use this?

If I read the info of the node you linked to it describes getting data from weather underground not putting data into weather underground.

You can use the import string you found you would need to concatenate the string together ( try googling javascript variable add string) and then pass that result to the http request node as the url

Give it a go if you get stuck come back and someone should be able to help you

1 Like

Sorry there was an error in the link, this is the correct:
https://www.npmjs.com/package/wunderground-pws

OK but now you’ve edited your original article it makes my comments look odd (it originally pointed to the node-red node)

But the second part is still valid which is probably easier than using ib the npm library

If you want to use a npm library in a nodered function you would need to include it in your settings.js file as described in the docs

Yes I know the setting.js is correctly configured bus the module still don’t do the job very well. Somtime skip some value somtime the value is the same, I don’t understand why.

By the way i try to make a string and make it work. I think this is the best way.

Thanks ukmoose,

with this string function and change node + http request it works fine.

var str = 'https://weatherstation.wunderground.com/weatherstation/updateweatherstation.php?ID=xxxxx&PASSWORD=xxxxx'
str += '&dateutc=now';
str += '&tempf=';
str += flow.get("tempf");
str += '&baromin=';
str += flow.get("baromin");
str += '&dewptf=';
str += flow.get("dewptf");
str += '&humidity=';
str += flow.get("humidity");
str += '&action=updateraw';
msg.payload = str
return msg;

Whenever I find myself trying to build strings from msg/flow/global variables, I like to use the template node. Using the “mustache” variable syntax, your string could be simplified to something like this (no function code needed):

https://weatherstation.wunderground.com/weatherstation/updateweatherstation.php?ID=xxxxx&PASSWORD=xxxxx&dateutc=now&tempf={{flow.tempf}}&baromin={{flow.baromin}}&dewptf={{flow.dewptf}}&humidity={{flow.humidity}}&action=updateraw
2 Likes

I am trying to use the wunderground-pws function lib.

I insert the 2 config lines on settings.js

Blockquote
// ------------ added by glf -------------
var PWS = require('wunderground-pws');
var pws = new PWS('', '***');

i restart nodered

i insert the following function node

pws.setObservations({
tempc: 4.2,
humidity: 48.9
});
pws.sendObservations(function(err, success){
// executed after callback
});
return msg;

And i get

"ReferenceError: pws is not defined (line 1, col 1)"

am i looking to the wrong settings.js? :slight_smile:

This thread was about using the underground node. Not rolling your own function.
It would better if you started a new thread.