rootnegativ1 / unifi-wifi

Home Assistant integration to change wireless passwords on UniFi Network controllers
MIT License
3 stars 0 forks source link

Improve exception handling and add configurable API timeout #13

Closed rootnegativ1 closed 9 months ago

rootnegativ1 commented 9 months ago

Add logic to raise exceptions when the HTTP status code is 400 or greater.

This is partly a hotfix for a 'quirk' in the UDM 3.2.7 firmware where occasionally the API would return {'error': {'code': 500, 'message': 'Internal Server Error'}}. Previously, this error was passed along as expected data but would cause an error when attempting to extract the X-CSRF token. This behavior seems to occur regularly, however the hard-coded 10 second timeout in async_timeout(), now asyncio.timeout(), would typically prevent the API from being able to send this response.

Additionally, an option to change the API timeout, in seconds, has been added.