jesserizzo / envoy_reader

MIT License
37 stars 26 forks source link

Add retries when gathering Inverter data #59

Closed gtdiehl closed 3 years ago

gtdiehl commented 3 years ago

It seems after moving from requests-async to the httpx library, gathering inverter data sometimes fails.

The httpx documentation says The protocol was violated by the server. While I've seen a reference to this occurring when the endpoint is overwelmed. In my case, I don't think it is the latter, as I was not seeing this issue when using the requests-async library.

In any case, I have added a retry mechanism when getting inverter data. If after 3 retries we still get the same httpx.RemoteProtocolError, than the library will raise the exception. When using the library in Home Assistant the retry will hopefully minimize the values sometimes bouncing from a value to 0/None/Unavaiable back to a value. On my Envoy running firmware D3.15.7, the Protocol error does not occur on the second retry.

gtdiehl commented 3 years ago

Fix #58