8000 WIP: vacuum.xiaomi_miio: read dnd status properly instead of using impreci… by rytilahti · Pull Request #9733 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

WIP: vacuum.xiaomi_miio: 8000 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
wants to merge 2 commits into from

Conversation

rytilahti
Copy link
Member
@rytilahti rytilahti commented Oct 7, 2017

…se dnd flag from vacuum_state

Description:

The value stored in the vacuum_state's dnd is not precise, and does not at least always correlate with the correct state. Therefore another call has to be made to find out the real settings.
This also exposes the currently used start and end hours.

Related issue (if applicable): fixes #

Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.github.io#<home-assistant.github.io PR number goes here>

Example entry for configuration.yaml (if applicable):

Checklist:

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

If the code does not interact with devices:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • Tests have been added to verify that the new code works.

@azogue
Copy link
Member
azogue commented Oct 8, 2017

Looks good to me, but to complete the change of name, the test_xiaomi_miio.py and requirements_all.txt need to be changed also, to use the new library.

The light.xiaomi_miio component needs to be changed also to use the new name?

@azogue
Copy link
Member
azogue commented Oct 8, 2017

I suppose the required python-miio version needs to be increased, isn't it @rytilahti ?
Because with the 0.2.0 version, the call to .dnd_status() returns a list like:

[{'start_hour': 23, 'start_minute': 0, 'end_minute': 0, 'enabled': 1, 'end_hour': 8}]

So this code can't work:

ATTR_DO_NOT_DISTURB: 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),

Copy link
Member
@azogue azogue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rytilahti, if this change has to be tested with a new 0.3.0 future release of the miio library, please advise on how to get that 0.3.0 code to test against.

@@ -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.2.0']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to review the mirobo imports down there, not all are changed to miio imports.
Example: L92

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, they are there for now as there has been no real releases of python-miio yet. I'm still working on some changes on python-miio I want to get it in before pushing this PR forwards. For now it's just for curious people to test it out (requires installing the master branch atm).

8000
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),
Copy link
Member

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.

@@ -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)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my last comment

@rytilahti
Copy link
Member Author

suppose the required python-miio version needs to be increased, isn't it @rytilahti ?
Because with the 0.2.0 version, the call to .dnd_status() returns a list like:

The version will be bumped later on when it's time to make a release, this code currently depends on the unreleased master of python-miio. For now this is just to keep track and potentially gain feedback from other people while I'm doing some required work for 0.3.0 (proper multidevice & config handling for the cli tool are on my pipeline still for that release).

@rytilahti rytilahti requested a review from andrey-git as a code owner October 21, 2017 00:50
@rytilahti rytilahti changed the title WIP: vacuum.xiaomi_miio: read dnd status properly instead of using impreci… vacuum.xiaomi_miio: read dnd status properly instead of using impreci… Oct 21, 2017
@rytilahti rytilahti changed the title vacuum.xiaomi_miio: read dnd status properly instead of using impreci… WIP: vacuum.xiaomi_miio: read dnd status properly instead of using impreci… Oct 21, 2017
@balloob
Copy link
Member
balloob commented Nov 11, 2017

This PR seems to have gone stale. Closing it. You can reopen it when you're ready to finish it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants
0