Handle all WeMo ensure_long_press_virtual_device exceptions (#53094)

* Handle all exceptions around the WeMo ensure_long_press_virtual_device method

* Don't use a bare exception

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Log exception

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
Eric Severance 2021-07-20 00:20:47 -07:00 committed by GitHub
parent e453871c68
commit ab36ac7a94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,7 +1,7 @@
"""Home Assistant wrapper for a pyWeMo device."""
import logging
from pywemo import PyWeMoException, WeMoDevice
from pywemo import WeMoDevice
from pywemo.subscribe import EVENT_TYPE_LONG_PRESS
from homeassistant.config_entries import ConfigEntry
@ -81,8 +81,10 @@ async def async_register_device(
if device.supports_long_press:
try:
await hass.async_add_executor_job(wemo.ensure_long_press_virtual_device)
except PyWeMoException:
_LOGGER.warning(
# Temporarily handling all exceptions for #52996 & pywemo/pywemo/issues/276
# Replace this with `except: PyWeMoException` after upstream has been fixed.
except Exception: # pylint: disable=broad-except
_LOGGER.exception(
"Failed to enable long press support for device: %s", wemo.name
)
device.supports_long_press = False