-
-
Notifications
You must be signed in to change notification settings - Fork 574
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 support Mi Robot Vacuum-Mop 2 Pro (ijai.vacuum.v3) #1497
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1497 +/- ##
==========================================
+ Coverage 80.82% 80.93% +0.11%
==========================================
Files 151 153 +2
Lines 14798 14989 +191
Branches 1696 3678 +1982
==========================================
+ Hits 11960 12131 +171
- Misses 2591 2610 +19
- Partials 247 248 +1
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
5352d80
to
03a3d3c
Compare
Add support for basic actions:
The code structure is based on Currently not sure the error code mapping, so leave the mapping empty |
Sorry, I haven't had time to review this yet, one question I had was whether the implementation differs that much from the g1 to require a separate implementation file? It is not really a big issue, especially with the upcoming introspectable interfaces (see #1495 and https://python-miio.readthedocs.io/en/latest/contributing.html#status-containers), but if the changes are minor we could avoid code duplication. |
That is a good question! I have tried integrating
These differences suggest that they may not have been designed by the same product line. So I decided to split them into two files. But this is the first time I've written this kind of script, so I'm not super sure that my choices are correct. If you still suggest me to integrate them into one file after reading my rationale, I will try to do so. Thanks again for your easy-to-use codebase! |
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.
Thanks for the PR @k402xxxcenxxx, I added some comments inline to improve it before it's ready to be merged!
"""Response (MIoT format) of a Mi Robot Vacuum-Mop 2 Pro (ijai.vacuum.v3) | ||
|
||
[ | ||
{'did': 'battery', 'siid': 3, 'piid': 1, 'code': 0, 'value': 100}, |
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.
Could you please add tests for the property getters using the example payload to make sure the return values and their types are as expected? Just in case this gets refactored in the future :-)
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.
Hi @rytilahti, I tried adding a state payload test. However, I'm not familiar with writing pytest. Can you help me review it first? Then I can write the following tests based on it.
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.
I will check the test code first. I forget to run test before push.
The reasoning sounds good to me, thanks for trying to integrate the implementations! No need to try to force different product lines under a single integration, especially considering the ongoing work to allow downstream users to programmatically find out about available information.
Splitting the implementations sounds good to me. One of the reasons I have tried to "force" support for different devices has been to make the interfaces somewhat consistent. This was due to structural problems in this library that are now being worked on as mentioned in my other comment. I'm glad that you think the code base was easy to work on, I hope it will become even easier in the future :-) |
@rytilahti thanks for reviewing. I will find time to improve it. |
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.
No need to define the unit for timedeltas for now, otherwise this is good to go, thanks!
return self.data["main_brush_life_level"] | ||
|
||
@property | ||
@sensor("Main Brush Life Time Left", unit="hr") |
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.
@sensor("Main Brush Life Time Left", unit="hr") | |
@sensor("Main Brush Life Time Left") |
return self.data["side_brush_life_level"] | ||
|
||
@property | ||
@sensor("Side Brush Life Time Left", unit="hr") |
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.
@sensor("Side Brush Life Time Left", unit="hr") | |
@sensor("Side Brush Life Time Left") |
return self.data["filter_life_level"] | ||
|
||
@property | ||
@sensor("Filter Life Time Left", unit="hr") |
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.
@sensor("Filter Life Time Left", unit="hr") | |
@sensor("Filter Life Time Left") |
return self.data["mop_life_level"] | ||
|
||
@property | ||
@sensor("Mop Life Time Left", unit="hr") |
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.
@sensor("Mop Life Time Left", unit="hr") | |
@sensor("Mop Life Time Left") |
return self.data["clean_area"] | ||
|
||
@property | ||
@sensor("Last Clean Time", unit="mins", icon="mdi:timer-sand") |
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.
@sensor("Last Clean Time", unit="mins", icon="mdi:timer-sand") | |
@sensor("Last Clean Time", icon="mdi:timer-sand") |
class RepeatState(Enum): | ||
Off = False | ||
On = True |
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.
I just briefly checked if all the booleans are defined as such and saw this. This is not used anywhere and should be removed now?
f451c5c
to
33d5905
Compare
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.
LGTM, thanks again! 👍
@rytilahti Hi! When there will be a new release of python-miio to support die mop 2 pro? I'd like to implement my robot into homeassistant, but this will only works with a new release. |
Add support Mi Robot Vacuum-Mop 2 Pro (ijai.vacuum.v3)
Fixes #1388 fixes #1385