diff --git a/homeassistant/components/vacuum/xiaomi_miio.py b/homeassistant/components/vacuum/xiaomi_miio.py index 5747dd1dc9e39..1cd794c9429dc 100644 --- a/homeassistant/components/vacuum/xiaomi_miio.py +++ b/homeassistant/components/vacuum/xiaomi_miio.py @@ -21,7 +21,7 @@ ATTR_ENTITY_ID, CONF_HOST, CONF_NAME, CONF_TOKEN, STATE_OFF, STATE_ON) import homeassistant.helpers.config_validation as cv -REQUIREMENTS = ['python-mirobo==0.2.0'] +REQUIREMENTS = ['python-miio==0.3.0'] _LOGGER = logging.getLogger(__name__) @@ -48,6 +48,8 @@ ATTR_CLEANING_TIME = 'cleaning_time' ATTR_DO_NOT_DISTURB = 'do_not_disturb' +ATTR_DO_NOT_DISTURB_START = 'do_not_disturb_start' +ATTR_DO_NOT_DISTURB_END = 'do_not_disturb_end' ATTR_MAIN_BRUSH_LEFT = 'main_brush_left' ATTR_SIDE_BRUSH_LEFT = 'side_brush_left' ATTR_FILTER_LEFT = 'filter_left' @@ -155,6 +157,7 @@ def __init__(self, name, vacuum): self.consumable_state = None self.clean_history = None + self.dnd_state = None @property def name(self): @@ -196,11 +199,14 @@ def fan_speed_list(self): @property def device_state_attributes(self): """Return the specific state attributes of this vacuum cleaner.""" + attrs = {} if self.vacuum_state is not None: attrs.update({ ATTR_DO_NOT_DISTURB: - STATE_ON if self.vacuum_state.dnd else STATE_OFF, + STATE_ON if self.dnd_state.enabled else STATE_OFF, + ATTR_DO_NOT_DISTURB_START: str(self.dnd_state.start), + ATTR_DO_NOT_DISTURB_END: str(self.dnd_state.end), # Not working --> 'Cleaning mode': # STATE_ON if self.vacuum_state.in_cleaning else STATE_OFF, ATTR_CLEANING_TIME: int( @@ -223,7 +229,6 @@ def device_state_attributes(self): / 3600)}) if self.vacuum_state.got_error: attrs[ATTR_ERROR] = self.vacuum_state.error - return attrs @property @@ -366,7 +371,7 @@ def async_remote_control_move_step(self, @asyncio.coroutine def async_update(self): """Fetch state from the device.""" - from mirobo import DeviceException + from miio 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) @@ -375,6 +380,9 @@ def async_update(self): self._vacuum.consumable_status) self.clean_history = yield from self.hass.async_add_job( self._vacuum.clean_history) + self.dnd_state = yield from self.hass.async_add_job( + self._vacuum.dnd_status) + self._is_on = state.is_on self._available = True except OSError as exc: diff --git a/requirements_all.txt b/requirements_all.txt index 37201e3592071..9c53d95e007de 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -790,9 +790,11 @@ python-juicenet==0.0.5 # homeassistant.components.light.xiaomi_miio # homeassistant.components.switch.xiaomi_miio -# homeassistant.components.vacuum.xiaomi_miio python-mirobo==0.2.0 +# homeassistant.components.vacuum.xiaomi_miio +python-miio==0.3.0 + # homeassistant.components.media_player.mpd python-mpd2==0.5.5