fix DeviceException handling when updating xiaomi vacuum (#8954)

* 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

View File

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