-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
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
Add a service for zoned cleaning for Xiaomi Miio vacuum #15932
Conversation
y1: int = 25500, | ||
x2: int = 25500, | ||
y2: int = 25500, | ||
repetitions: int = 1): |
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.
continuation line over-indented for visual indent
x1: int = 25500, | ||
y1: int = 25500, | ||
x2: int = 25500, | ||
y2: int = 25500, |
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.
continuation line over-indented for visual indent
def async_clean_zone(self, | ||
x1: int = 25500, | ||
y1: int = 25500, | ||
x2: int = 25500, |
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.
continuation line over-indented for visual indent
@asyncio.coroutine | ||
def async_clean_zone(self, | ||
x1: int = 25500, | ||
y1: int = 25500, |
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.
continuation line over-indented for visual indent
@@ -318,6 +340,20 @@ def async_send_command(self, command, params=None, **kwargs): | |||
"Unable to send command to the vacuum: %s", | |||
self._vacuum.raw_command, command, params) | |||
|
|||
@asyncio.coroutine | |||
def async_clean_zone(self, | |||
x1: int = 25500, |
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.
continuation line over-indented for visual indent
Thanks for your contribution, please change your pull request's target to |
params = [[x1, y1, x2, y2, repetitions]] | ||
yield from self._try_command( | ||
"Unable to start zoned cleaning: %s", | ||
self._vacuum.raw_command, |
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.
The proper way to do this would be to fix the python-miio instead of using raw_command
, see rytilahti/python-miio#311 . It could be also useful to add a service for "goto" for the purpose of emptying the bin :-)
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.
We should probably also have some documentation that shows how the x1, x2, y1, and y2 coordinates relates to the real world, as I have personally seen the map change orientation on different runs of the vacuum. (Would changing the orientation of the map also change the coordinates, such that an automation to clean up the kitchen floor after I'm done cooking would make the vacuum clean a different area?) and how do we extract the correct x and y coordinates? |
Please rebase your PR and use the new "goto" method of python-miio 0.4.1: https://github.com/rytilahti/python-miio/blob/master/miio/vacuum.py#L80 |
@asyncio.coroutine | ||
def async_goto(self, | ||
x: int = 25500, | ||
y: int = 25500): |
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.
continuation line over-indented for visual indent
|
||
@asyncio.coroutine | ||
def async_goto(self, | ||
x: int = 25500, |
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.
continuation line over-indented for visual indent
"""Clean a specific zone.""" | ||
zoneList = [] | ||
for zone in zones: | ||
zoneList.append([int(zone["x1"]), int(zone["y1"]), int(zone["x2"]), int(zone["y2"]), int(zone["iterations"])]) |
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.
line too long (122 > 79 characters)
y1: int = 25500, | ||
x2: int = 25500, | ||
y2: int = 25500, | ||
iterations: int = 1): |
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.
continuation line over-indented for visual indent
x1: int = 25500, | ||
y1: int = 25500, | ||
x2: int = 25500, | ||
y2: int = 25500, |
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.
continuation line over-indented for visual indent
def async_clean_zone(self, | ||
x1: int = 25500, | ||
y1: int = 25500, | ||
x2: int = 25500, |
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.
continuation line over-indented for visual indent
@asyncio.coroutine | ||
def async_clean_zone(self, | ||
x1: int = 25500, | ||
y1: int = 25500, |
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.
continuation line over-indented for visual indent
@@ -318,6 +371,38 @@ def async_send_command(self, command, params=None, **kwargs): | |||
"Unable to send command to the vacuum: %s", | |||
self._vacuum.raw_command, command, params) | |||
|
|||
@asyncio.coroutine | |||
def async_clean_zone(self, | |||
x1: int = 25500, |
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.
continuation line over-indented for visual indent
I have tested all three services with my roborock 2 and it seems to be working. NOTE: From the docking station point of view facing away from the wall it is placed against the X-axis is positive towards the right and the Y-axis is positive forward. |
@tenfire Do you know of any limit regarding the maximum number of zones to be cleaned per API call? If I recall correctly, the MiHome app has a limit of 5. |
The app is limited to 3 iterations, but it worked with 5 using python-miio. I did not test with a higher number |
Thanks for testing and clearing that up :) So if I want to use more than 5 zones I need to wrap it in some kind of automation. |
Yes, but you can "reset" the map and orientation with the following method. |
|
||
SERVICE_SCHEMA_CLEAN_ZONES = VACUUM_SERVICE_SCHEMA.extend({ | ||
vol.Required(ATTR_ZONE_ZONES): | ||
vol.All(vol.Coerce(list)), |
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.
This should be more than just list
. Also, use cv.ensure_list
.
@@ -69,7 +80,41 @@ | |||
vol.Optional(ATTR_RC_DURATION): cv.positive_int, | |||
}) | |||
|
|||
SERVICE_SCHEMA_CLEAN_ZONE = VACUUM_SERVICE_SCHEMA.extend({ |
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.
This one should be removed, clean_zones
should be able to handle the cleaning of 1 zone.
vol.All(vol.Coerce(list)), | ||
}) | ||
|
||
SERVICE_SCHEMA_GOTO = VACUUM_SERVICE_SCHEMA.extend({ |
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.
Please limit PRs to 1 service at a time.
"""Clean a specific zone.""" | ||
zoneList = [] | ||
for zone in zones: | ||
zoneList.append([int(zone["x1"]), int(zone["y1"]), int(zone["x2"]), int(zone["y2"]), int(zone["iterations"])]) |
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.
Conversion of variables has to happen in voluptuous schema.
You will also need to fix the linting erros. |
Added a service for zoned cleaning after some help from pnbruckner (thanks!). Tested with my Xiaomi Roborock 2.
Description:
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:
tox
. Your PR cannot be merged unless tests passIf user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
REQUIREMENTS
variable (example).requirements_all.txt
by runningscript/gen_requirements_all.py
..coveragerc
.If the code does not interact with devices: