Some things prevented me from being able to use the integration properly. I follow debug logs and exceptions back to the code and fixed stuff until it worked.
Here are summary of changes:
There was a missing slash in the Generic OpenAI backend's Chat Completions endpoint. Looks like it was just missed so i added it the same as the Completions endpoint.
Code was catching aiohttp.ClientTimeout as an exception when trying the POST requests, but that is for configuring timeouts and doesn't inherit from an exception base class. I imported asyncio and used asyncio.ClientTimeout as per the documentation.
Also, for this once exception was caught and was not from timeout, response was sometimes unbound too, so I bound it before the request so logging didn't throw exception for unbound variable.
Sometimes the function for getting the area from an area ID returns None. I added check for this, so area is only added if it really exists. Not sure why this happens, probably something to do with munted HA configuration but this way is more robust at least.
Not sure how much of this follows your style or pragmatic code preferences, let me know if you want anything changed!
Some things prevented me from being able to use the integration properly. I follow debug logs and exceptions back to the code and fixed stuff until it worked.
Here are summary of changes:
aiohttp.ClientTimeout
as an exception when trying the POST requests, but that is for configuring timeouts and doesn't inherit from an exception base class. I importedasyncio
and usedasyncio.ClientTimeout
as per the documentation.Not sure how much of this follows your style or pragmatic code preferences, let me know if you want anything changed!