Catch more Hue errors (#32275)
This commit is contained in:
parent
ecd076c5e4
commit
5a56d0ec1d
3 changed files with 18 additions and 5 deletions
|
@ -1,6 +1,7 @@
|
|||
"""Code to handle a Hue bridge."""
|
||||
import asyncio
|
||||
from functools import partial
|
||||
import logging
|
||||
|
||||
from aiohttp import client_exceptions
|
||||
import aiohue
|
||||
|
@ -24,7 +25,8 @@ SCENE_SCHEMA = vol.Schema(
|
|||
{vol.Required(ATTR_GROUP_NAME): cv.string, vol.Required(ATTR_SCENE_NAME): cv.string}
|
||||
)
|
||||
# How long should we sleep if the hub is busy
|
||||
HUB_BUSY_SLEEP = 0.01
|
||||
HUB_BUSY_SLEEP = 0.5
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class HueBridge:
|
||||
|
@ -123,9 +125,14 @@ class HueBridge:
|
|||
except (
|
||||
client_exceptions.ClientOSError,
|
||||
client_exceptions.ClientResponseError,
|
||||
client_exceptions.ServerDisconnectedError,
|
||||
) as err:
|
||||
if tries == 3 or (
|
||||
# We only retry if it's a server error. So raise on all 4XX errors.
|
||||
if tries == 3:
|
||||
_LOGGER.error("Request failed %s times, giving up.", tries)
|
||||
raise
|
||||
|
||||
# We only retry if it's a server error. So raise on all 4XX errors.
|
||||
if (
|
||||
isinstance(err, client_exceptions.ClientResponseError)
|
||||
and err.status < 500
|
||||
):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue