An existing Python script that dumps serial smart meter data to InfluxDB every second is my starting point. The scripts stays running via a socat
pipe. I managed to extend that script with a thread to gather metering data and post that information to the addstatus API every 5 minutes using requests.post
.
A lot of exceptions can occur. The requests call may timeout, PVoutput API may return an error message.
PVoutput documentation contains nice and practical curl
examples, that is nice for oneshot runs. Though I prefer to stay with Pythons requests.post and keep the script running in its loop.
PVoutput API documentation has loads of exceptions, ranging from Bad request 400 (in 11 subtypes for addstatus), 401’s, 403’s and 405’s.
Are there suggestions for timeout and retry values?
And are there suggestions for which errors to retry?
I think:
405 = retry
403. Exceeded number requests per hour = retry
403 other = don’t retry
401 = don’t retry
400 = don’t retry
Can someone point me to a good python pvoutput example that handles requests.post
timeouts, error statuses and retries correctly?