HTTP GET request weather station update

Hi,

Hope everyone is well.

I am trying to update Weather Underground using an HTTP GET request via Node Red, with sensor data contain in the HTTP address:

http:/weatherstation.wunderground.com/weatherstation/updateweatherstation.php?ID=XXXX&PASSWORD=XXXX&dateutc=now&winddir=XXX&windspeedmph=XXX&airpressure=XXX&tempc=XXX&humidity=XXX&dewptc=XXX&action=updateraw

The various sensors are as follows:

Wind Speed
Air Pressure
Temperature
Humidity
Dew Point

This data is displayed in Home Assistant, as sensor entities from Node Red. The setup is as per the below:

[{"id":"720ab126.608a6","type":"tab","label":"Weather Meter","disabled":false,"info":""},{"id":"6bff04c3.1d096c","type":"csv","z":"720ab126.608a6","name":"","sep":",","hdrin":false,"hdrout":"none","multi":"one","ret":"\\n","temp":"NODE,DIR,SPEED,PRESS,TEMP,RH,DEWPOINT,VOLT","skip":"0","strings":false,"include_empty_strings":false,"include_null_values":false,"x":210,"y":300,"wires":[["68100633.dfa9c8"]]},{"id":"68100633.dfa9c8","type":"split","z":"720ab126.608a6","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":340,"y":300,"wires":[["d9c14757.617bd8"]]},{"id":"d9c14757.617bd8","type":"switch","z":"720ab126.608a6","name":"","property":"parts.key","propertyType":"msg","rules":[{"t":"eq","v":"NODE","vt":"str"},{"t":"eq","v":"DIR","vt":"str"},{"t":"eq","v":"SPEED","vt":"str"},{"t":"eq","v":"PRESS","vt":"str"},{"t":"eq","v":"TEMP","vt":"str"},{"t":"eq","v":"RH","vt":"str"},{"t":"eq","v":"DEWPOINT","vt":"str"},{"t":"eq","v":"VOLT","vt":"str"}],"checkall":"true","repair":false,"outputs":8,"x":490,"y":300,"wires":[[],["4d7c233a.fb1b5c"],["3c4d1d1c.1621f2"],["36e6b8ce.bbd9b8"],["a1d3ffc.48e15"],["c073d016.b79fe"],["61b63dad.b9e4b4"],["eb0f2b22.eb6668"]]},{"id":"4c2d8b30.068334","type":"udp in","z":"720ab126.608a6","name":"","iface":"","port":"2559","ipv":"udp4","multicast":"false","group":"","datatype":"utf8","x":60,"y":300,"wires":[["6bff04c3.1d096c"]]},{"id":"27d9d361.a0263c","type":"ha-entity","z":"720ab126.608a6","name":"External Wind Speed","server":"eabe397b.2e7ab8","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"external wind speed"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"Mph"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":920,"y":240,"wires":[[]]},{"id":"51b22e6d.0ae55","type":"ha-entity","z":"720ab126.608a6","name":"External Air Pressure","server":"eabe397b.2e7ab8","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"external air pressure"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"mbar"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":920,"y":280,"wires":[[]]},{"id":"7b7526c1.4a9d68","type":"ha-entity","z":"720ab126.608a6","name":"External Temperature","server":"eabe397b.2e7ab8","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"external temperature"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"°C"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":920,"y":320,"wires":[[]]},{"id":"5364900b.3b29e","type":"ha-entity","z":"720ab126.608a6","name":"External Humidity","server":"eabe397b.2e7ab8","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"external humidity"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"%"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":910,"y":360,"wires":[[]]},{"id":"25b0ae57.beb3d2","type":"ha-entity","z":"720ab126.608a6","name":"External Dew Point","server":"eabe397b.2e7ab8","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"external dew point"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"°C"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":910,"y":400,"wires":[[]]},{"id":"68bf2d8c.1ea8d4","type":"ha-entity","z":"720ab126.608a6","name":"External Station Voltage","server":"eabe397b.2e7ab8","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"external station voltage"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"Vdc"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":930,"y":440,"wires":[[]]},{"id":"4d7c233a.fb1b5c","type":"delay","z":"720ab126.608a6","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"10","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":720,"y":200,"wires":[["c1523db1.25f98"]]},{"id":"3c4d1d1c.1621f2","type":"delay","z":"720ab126.608a6","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"4","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":720,"y":240,"wires":[["27d9d361.a0263c"]]},{"id":"36e6b8ce.bbd9b8","type":"delay","z":"720ab126.608a6","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"15","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":720,"y":280,"wires":[["51b22e6d.0ae55"]]},{"id":"a1d3ffc.48e15","type":"delay","z":"720ab126.608a6","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"15","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":720,"y":320,"wires":[["7b7526c1.4a9d68"]]},{"id":"c073d016.b79fe","type":"delay","z":"720ab126.608a6","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"15","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":720,"y":360,"wires":[["5364900b.3b29e"]]},{"id":"eb0f2b22.eb6668","type":"delay","z":"720ab126.608a6","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"15","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":720,"y":440,"wires":[["68bf2d8c.1ea8d4"]]},{"id":"61b63dad.b9e4b4","type":"delay","z":"720ab126.608a6","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"15","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":720,"y":400,"wires":[["25b0ae57.beb3d2"]]},{"id":"c1523db1.25f98","type":"ha-entity","z":"720ab126.608a6","name":"External Wind Direction","server":"eabe397b.2e7ab8","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"external wind direction"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":""}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":930,"y":200,"wires":[[]]},{"id":"eabe397b.2e7ab8","type":"server","name":"Home Assistant","addon":true}]

What i need to do is take the various values, and add these to the HTTP address - as an example, the switch output for “temperature” updates the “tempc=XXX” part. The data would need to update every 60 seconds.

Any ideas? This is the first time i have done something like this.

Thanks.

I believe using a Home Assistant rest sensor will be easier.

1 Like

Not sure what are your exact sensor names are, but I do it this way with my sensors (using REST command and templates):

rest_command:
  wunderreport:
    url: 'https://weatherstation.wunderground.com/weatherstation/updateweatherstation.php?ID=MYID&PASSWORD=MYTOKEN&dateutc=now&tempf={{ states.sensor.wutempf.state }}&baromin={{ states.sensor.wubaromin.state }}&humidity={{ states.sensor.wuhumidity.state }}&dewptf={{ states.sensor.wudewptf.state }}&winddir={{ states.sensor.wuwinddir.state }}&windspeedmph={{ states.sensor.wuwindspeedmph.state }}&windgustmph={{ states.sensor.wuwindgustmph.state }}&softwaretype=rpi%20version1.0.5&action=updateraw'

I then just call this REST command in an interval based automation (every 3 minutes).

If you decide to do it the same way, please let me know, if it works. For me it does, but last few days I get quite some “timeout” errors in my log and I’m not sure, what is causing it (Wunderground slow response or something within HA).

1 Like

Thanks,

rest_command:
  wunderreport:
    url: 'https://weatherstation.wunderground.com/weatherstation/updateweatherstation.php?ID=XXXX&PASSWORD=XXXX&dateutc=now&tempc={{ states.sensor.external_temperature.state }}&baromin={{ states.sensor.external_air_pressure.state }}&humidity={{ states.sensor.external_humidity.state }}&dewptc={{ states.sensor.external_dew_point.state }}&winddir={{ states.sensor.external_wind_direction.state }}&windspeedmph={{ states.sensor.external_wind_speed.state }}&softwaretype=rpi%20version1.0.5&action=updateraw'
     

This worked! However, the temperature and dewpoint didnt report back? I changed the F to a C as i am in the UK. I think it may be the way the data is held within the sensor (+003.9) so will try and find a way to round these numbers down.

I also notice WUG is reporting Km/h and not Mph?

Thanks.

I believe all WU data must be reported in imperial units, therefore “tempc” won’t work, only “tempf” and speedmph instead speedkmh also. I’m using metric system also and I had to convert my data from metric to imperial first.
On the other hand, the website shows units as you defined them in your profile, regardless of the reported data, if that’s what you ment by “WUG is reporting km/h”.

This is correct and a big help. This is what fixed the issue for me, and the solution is now working as expected.

I have also integrated the Met Office.

I have noticed time outs, and set the call rate to 15 minutes. I will keep an eye on it.

What could be causing the issue?

Thanks.

Have no idea what causes timeouts, but setting a different call rate didn’t help in my case… also timeouts were somewhat sporadic, sometimes they happpened many times in a row (call rate 5 minutes), but then there weren’t any for hours.
Makes me think it has something to do with DNS, as I found out, that I can get rid of them by changing the first part of my URL, so it calls an IP address directly instead of “https://weatherstation.wunderground.com”.
However, this is not really a solution, as it forces you to change from SSL connection to an insecure http,…

Hi,

Same issue here. I have the same (sporadic) issues in the log. I think their server rejects the call if it’s sent before a fixed period, but I believe that’s 3-5 mins - I have mine set at 6 minutes.

You said the IP address worked, so would suggest a DNS issue, or perhaps they sit behind a cloud flare type service who are trying to prevent bots from attacking their servers?

Could be, but I’ve seen a station in my vicinity reporting every 30 seconds without issues… so I was guessing I have some issues localy, either in HA itself or in Docker (I run HA on Raspberry in Docker, so Docker may be the issue, as I noticed this error roughly the same time as the latest Docker update to 20.10.6 took place).
What type of install are you using?

I am using Home Assistant OS - most recent version