Closed gtdiehl closed 4 years ago
Investigating this I was unable to use the requests_async
or the aiohttp
libraries with Digest Authentication. The one library I did find was httpx
.
async with httpx.AsyncClient() as client:
response = await client.get("http://{}/api/v1/production/inverters"
.format(self.host),
auth=httpx.DigestAuth(self.username, self.password))
seems to address the issue were HA complains with the Detected I/O ...
message, but now I am seeing some other exceptions being thrown from httpx
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/h11/_state.py", line 249, in _fire_event_triggered_transitions
new_state = EVENT_TRIGGERED_TRANSITIONS[role][state][event_type]
KeyError: <class 'h11._events.ConnectionClosed'>
....
h11._util.RemoteProtocolError: can't handle event type ConnectionClosed when role=SERVER and state=SEND_RESPONSE
......
httpx._exceptions.ConnectionClosed: can't handle event type ConnectionClosed when role=SERVER and state=SEND_RESPONSE
With HA 0.109, inverter data collection is broken in my setup with an older Envoy device.
HA is displaying a message of
WARNING (MainThread) [homeassistant.util.async_] Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author
for Line 156 of the sensor code which callsinverters_production()
on the envoy_reader side.Changing the sync to an async call might fix the problem