-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
WIP: vacuum.xiaomi_miio: read dnd status properly instead of using impreci… #9733
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See my last comment |
||
self._is_on = state.is_on | ||
self._available = True | ||
except OSError as exc: | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As in
python-miio
v0.2.0,self.dnd_state
is a list with one dict, I suppose with the new version that would be an object. If not, this won't work.