As I read some meteorological data to my HA instance from outside of my flat, I decided to create a “virtual” weatherstation and upload the values to Weatherunderground. For now it’s only temperature, humidity and air-pressure.
Therefore I created a REST command in configuration.yaml like this (http GET composed as instructed from WU):
rest_command:
wureport:
url: "https://weatherstation.wunderground.com/weatherstation/updateweatherstation.php?ID=mystationid&PASSWORD=mypassword&dateutc=now&tempf={{states.sensor.tempout.state}}&baromin={{states.sensor.pressout.state}}&humidity={{states.sensor.humout.state}}&softwaretype=pws%20ver1.0&action=updateraw"
I tested the command many times in Developer tools and it always ran and uploaded actual data succesfully.
Then I created an automation, which calls this command every 5 minutes. And it works OK in cca 80% (10 out of 12 times per hour), but in 20% I randomly (but sometimes even 3 times in a row) get an error in my log and the data isn’t uploaded:
WARNING (MainThread) [homeassistant.components.rest_command] Error. Url: https://weatherstation......updateraw. Status code 401. Payload: None
The http link in error log looks correct and contains actual measured data (no false readings etc) and if I copy it to my browser and run it, the upload is successful and immediate.
Error 401 is presumably connected with false authentication, which doesn’t really make sense to me, as in most cases it works OK with the same data.
Is anyone doing something similar and has a hint on how to deal with it? Is there anything else I can set in my rest command to make it succesful? Or how to identify such case and try to execute REST command once again on failure?