Protect Doorbird platform from failing when individual doorbird fails (#29374)

* Wrap connection attempt by try/except block so an individual downed doorbird does not fail the whole platform

* Fixed lint warning

* Disable too-broad-exception pylint warning since the whole point of this is to catch all exceptions and log them while letting processing continue; I don't disable a lint warning lightly, but this is the entire intent of this PR.

* Fixed name of pylint warning to broad-except

* Use _LOGGER.exception to get the stack trace too, per PEP8 recommendation for a bare Exception being caught.

* per @balloob, switch to just catching OSError on a narrow block; I'm not sure this protects all problems with Doorbird device startup, but it protects against the primary one I experience.
This commit is contained in:
gjbadros 2019-12-09 00:14:55 -08:00 committed by Paulus Schoutsen
parent 8dea7f0f98
commit 6996ad3541

View File

@ -67,8 +67,14 @@ def setup(hass, config):
token = doorstation_config.get(CONF_TOKEN)
name = doorstation_config.get(CONF_NAME) or "DoorBird {}".format(index + 1)
device = DoorBird(device_ip, username, password)
status = device.ready()
try:
device = DoorBird(device_ip, username, password)
status = device.ready()
except OSError as oserr:
_LOGGER.error(
"Failed to setup doorbird at %s: %s; not retrying", device_ip, oserr
)
continue
if status[0]:
doorstation = ConfiguredDoorBird(device, name, events, custom_url, token)