fix DeviceException handling when updating xiaomi vacuum ()

* Fix DeviceException handling when updating entity

* add DeviceException error handling to generic request
pull/8956/head
Eugenio Panadero 2017-08-13 15:02:48 +02:00 committed by Martin Hjelmare
parent 73d6227021
commit c92e5c147a
1 changed files with 5 additions and 5 deletions
homeassistant/components/vacuum

View File

@ -219,12 +219,12 @@ class MiroboVacuum(VacuumDevice):
@asyncio.coroutine @asyncio.coroutine
def _try_command(self, mask_error, func, *args, **kwargs): def _try_command(self, mask_error, func, *args, **kwargs):
"""Call a vacuum command handling error messages.""" """Call a vacuum command handling error messages."""
from mirobo import VacuumException from mirobo import DeviceException, VacuumException
try: try:
yield from self.hass.async_add_job(partial(func, *args, **kwargs)) yield from self.hass.async_add_job(partial(func, *args, **kwargs))
return True return True
except VacuumException as ex: except (DeviceException, VacuumException) as exc:
_LOGGER.error(mask_error, ex) _LOGGER.error(mask_error, exc)
return False return False
@asyncio.coroutine @asyncio.coroutine
@ -341,7 +341,7 @@ class MiroboVacuum(VacuumDevice):
@asyncio.coroutine @asyncio.coroutine
def async_update(self): def async_update(self):
"""Fetch state from the device.""" """Fetch state from the device."""
from mirobo import VacuumException from mirobo import DeviceException
try: try:
state = yield from self.hass.async_add_job(self._vacuum.status) state = yield from self.hass.async_add_job(self._vacuum.status)
_LOGGER.debug("Got new state from the vacuum: %s", state.data) _LOGGER.debug("Got new state from the vacuum: %s", state.data)
@ -351,6 +351,6 @@ class MiroboVacuum(VacuumDevice):
except OSError as exc: except OSError as exc:
_LOGGER.error("Got OSError while fetching the state: %s", exc) _LOGGER.error("Got OSError while fetching the state: %s", exc)
# self._available = False # self._available = False
except VacuumException as exc: except DeviceException as exc:
_LOGGER.warning("Got exception while fetching the state: %s", exc) _LOGGER.warning("Got exception while fetching the state: %s", exc)
# self._available = False # self._available = False