therealryanbonham / badnest

25 stars 27 forks source link

Merge json error #7

Closed therealryanbonham closed 4 years ago

therealryanbonham commented 4 years ago

From: https://github.com/badguy99/badnest/tree/json_error

When the JSON error was being seen, the requests post (r = self._session.post) was getting a 502 response with the following text:

502 Server Error

Error: Server Error

The server encountered a temporary error and could not complete your request.

Please try again in 30 seconds.

added code to catch the exception, retry after 30 seconds if a 502 status code was return to requests. Also added extra debugging if other status codes were returned.

With the fix, I now get the following, rather than exception and traceback in my logs:

2020-05-09 21:03:30 ERROR (SyncWorker_9) [custom_components.badnest.api] Expecting value: line 1 column 1 (char 0) 2020-05-09 21:03:31 ERROR (SyncWorker_9) [custom_components.badnest.api] Error 502, Failed to update, retrying in 30s 2020-05-09 21:03:37 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.downstairs_protect_co_status is taking over 10 seconds 2020-05-09 21:03:51 WARNING (MainThread) [homeassistant.components.sensor] Updating badnest sensor took longer than the scheduled update interval 0:00:30

fixes: #88