Skip to content
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

Improve Viomi support (status reporting, maps) #808

Merged
merged 15 commits into from
Feb 8, 2021

Conversation

titilambert
Copy link
Contributor

@titilambert titilambert commented Aug 31, 2020

This PR refactors viomi vacuum (like STYJ02YM)

I tested all the attributes with STYJ02YM.
I re-organised the commands to stick with the android UI.
I added also some commands:

  • maps management
  • list rooms
  • cleaning specific room

@coveralls
Copy link

coveralls commented Aug 31, 2020

Coverage Status

Coverage decreased (-0.1%) to 73.831% when pulling dd83750 on titilambert:viomi_status into 93b7a77 on rytilahti:master.

@titilambert titilambert changed the title Viomi status Improve Viomi status Aug 31, 2020
@titilambert
Copy link
Contributor Author

@rytilahti ping

Copy link
Owner

@rytilahti rytilahti left a 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! I did a quick initial review, do you have plans to figure out the unknown variables and are you sure requesting so many variables is not breaking some limits?

edit: some of the consumables are duplicates and already available thanks to #805?

miio/viomivacuum.py Show resolved Hide resolved
miio/viomivacuum.py Outdated Show resolved Hide resolved
miio/viomivacuum.py Outdated Show resolved Hide resolved
miio/viomivacuum.py Outdated Show resolved Hide resolved
miio/viomivacuum.py Outdated Show resolved Hide resolved
miio/viomivacuum.py Outdated Show resolved Hide resolved
miio/viomivacuum.py Show resolved Hide resolved
miio/viomivacuum.py Outdated Show resolved Hide resolved
miio/viomivacuum.py Outdated Show resolved Hide resolved
miio/viomivacuum.py Outdated Show resolved Hide resolved
miio/viomivacuum.py Outdated Show resolved Hide resolved
miio/viomivacuum.py Outdated Show resolved Hide resolved
miio/viomivacuum.py Outdated Show resolved Hide resolved
@rytilahti
Copy link
Owner

@titilambert Ping? Could you also update the description for the PR?

@titilambert
Copy link
Contributor Author

@titilambert Ping? Could you also update the description for the PR?

done

@titilambert
Copy link
Contributor Author

@rytilahti I made a refactoring to have something structured like the android app.
I added a big module docstring to explain what is missing or not.
I still need to test some properties.
After that, I guess, we could merge this PR.
Then, the thing missing will be the management of the scheduled cleanup !

miio/device.py Outdated Show resolved Hide resolved
miio/discovery.py Outdated Show resolved Hide resolved
miio/viomivacuum.py Outdated Show resolved Hide resolved
miio/viomivacuum.py Outdated Show resolved Hide resolved
miio/viomivacuum.py Outdated Show resolved Hide resolved
miio/viomivacuum.py Outdated Show resolved Hide resolved
miio/viomivacuum.py Outdated Show resolved Hide resolved
miio/viomivacuum.py Outdated Show resolved Hide resolved
miio/viomivacuum.py Outdated Show resolved Hide resolved
miio/viomivacuum.py Outdated Show resolved Hide resolved
@titilambert titilambert force-pushed the viomi_status branch 2 times, most recently from 646029a to 318eece Compare November 24, 2020 04:22
@syssi
Copy link
Collaborator

syssi commented Nov 24, 2020

@titilambert Take a look at your inbox. I've sent you an e-mail (subject: "Some material to support your viomi PR").

@titilambert titilambert reopened this Nov 24, 2020
@titilambert
Copy link
Contributor Author

@titilambert Take a look at your inbox. I've sent you an e-mail (subject: "Some material to support your viomi PR").

Thanks ! I already had this file but only for viomi.v7
I think I got everything I can (for now)

@titilambert
Copy link
Contributor Author

@rytilahti I found a way to create a map in live using Pillow.
Once this PR is merged, I will create a new one just for this feature
Are you open to add Pillow as dependency in the project ?

@titilambert
Copy link
Contributor Author

@rytilahti I think this PR is now ready !

@titilambert
Copy link
Contributor Author

@rytilahti The PR is now rebased

miio/exceptions.py Outdated Show resolved Hide resolved
miio/viomivacuum.py Outdated Show resolved Hide resolved
miio/viomivacuum.py Outdated Show resolved Hide resolved
miio/viomivacuum.py Outdated Show resolved Hide resolved
miio/viomivacuum.py Outdated Show resolved Hide resolved
miio/viomivacuum.py Show resolved Hide resolved
miio/viomivacuum.py Outdated Show resolved Hide resolved
miio/viomivacuum.py Outdated Show resolved Hide resolved
miio/viomivacuum.py Outdated Show resolved Hide resolved
miio/device.py Outdated Show resolved Hide resolved
@titilambert
Copy link
Contributor Author

titilambert commented Dec 12, 2020

@rytilahti need to get PR #884 merged, then I rebase this one and It will be ready for review

titilambert and others added 6 commits February 2, 2021 22:08
Co-authored-by: Teemu R. <tpr@iki.fi>
Co-authored-by: Teemu R. <tpr@iki.fi>
Co-authored-by: Teemu R. <tpr@iki.fi>
Co-authored-by: Teemu R. <tpr@iki.fi>
Co-authored-by: Teemu R. <tpr@iki.fi>
Co-authored-by: Teemu R. <tpr@iki.fi>
@jeremysherriff
Copy link

There is a lot of comments in this PR, and it's very hard to see what is now resolved and what still needs work.
I would like to help, please ignore if the following is not useful;

edge_state is a toggle setting in the Mi Home app (so probably a boolean). The wording in English in the app is
Vacuum along the edges with description This setting is valid once. It will cause the vacuum to only vacuum the edges of the room/zone/map. The setting reverts to off/0/false once the clean-up completes or is cancelled.

repeat_state is also a toggle setting in the app. The wording in English in the app is
Secondary cleanup with description After enabling the cleanup will be repeated, only takes effect once. It makes the vacuum repeat the cleanup room/zone/map twice over (for extra clean!). The setting reverts to off/0/false once the clean-up completes or is cancelled.

Screenshot of these settings in app:
image

@jeremysherriff
Copy link

The voice volume is set using integers ranging from 1 to 10, represented in the app as 10% to 100%. I assume this is the same as other Xiaomi models?

Here's logs from the Mi Home app with me setting the volume to 90% and then back to 100%:

2021-02-03 19:50:31 -> {"id":1115,"method":"set_voice","params":[1,9]}
2021-02-03 19:50:31 <- {"code":0,"id":1115,"otlocalts":1612335031389261,"result":["ok"]}

2021-02-03 19:50:35 -> {"id":1117,"method":"set_voice","params":[1,10]}
2021-02-03 19:50:35 <- {"code":0,"id":1117,"otlocalts":1612335035817524,"result":["ok"]}

When disabling the voice, the parameters become [0,5] (presumably, "off" and "50%") and the app hides the volume setting. When re-enabling, the app sets the voice volume to 50% regardless of what volume it was originally. The following is the result of me disabling the voice when it is was 100% volume, and then re-enabling, and manually setting the volume back to 100%:

2021-02-03 19:57:40 -> {"id":4146,"method":"set_voice","params":[0,5]}
2021-02-03 19:57:40 <- {"code":0,"id":4146,"otlocalts":1612335461613965,"result":["ok"]}

2021-02-03 19:57:45 -> {"id":4148,"method":"set_voice","params":[1,5]}
2021-02-03 19:57:45 <- {"code":0,"id":4148,"otlocalts":1612335466505960,"result":["ok"]}

2021-02-03 19:58:48 -> {"id":4157,"method":"set_voice","params":[1,10]}
2021-02-03 19:58:48 <- {"code":0,"id":4157,"otlocalts":1612335528958184,"result":["ok"]}

@rytilahti rytilahti mentioned this pull request Feb 6, 2021
miio/viomivacuum.py Outdated Show resolved Hide resolved
miio/viomivacuum.py Outdated Show resolved Hide resolved
miio/viomivacuum.py Outdated Show resolved Hide resolved
@titilambert
Copy link
Contributor Author

@rytilahti I just fixed all your comments and the tests are green :)

@rytilahti
Copy link
Owner

Okay, let's get it merged, thanks for the PR and for your patience! 🎉 For further improvements, let's try to do it more gradually (i.e., with smaller, self-contained changes) to make it easier & faster to review!

@rytilahti rytilahti changed the title Improve Viomi status Improve Viomi support (status reporting, maps) Feb 8, 2021
@rytilahti rytilahti merged commit 0384475 into rytilahti:master Feb 8, 2021
@rytilahti rytilahti mentioned this pull request Mar 13, 2021
@k-0
Copy link

k-0 commented Mar 24, 2021

I've been experimenting with getting specific rooms cleaned, and realised that my Russian hacked Mi Home app is logging the vacuum calls. Here's a successful call to vacuum the Hallway with a single pass:

2021-01-29 15:53:50 -> {"id":163,"method":"set_mode_withroom","params":[0,1,1,15]}
2021-01-29 15:53:50 <- {"code":0,"id":163,"otlocalts":1611888830803511,"result":["ok"]}

As per previous, my rooms are:

jeremy@tvbox:~$ miiocli viomivacuum --ip=192.168.220.115 --token=3a5a32786e57457653576662xxxxxxxx get_rooms
Running command get_rooms
{'10': 'Bathroom', '12': 'Kitchen', '15': 'Hallway', '13': 'Living Room'}

I use this App too. Where can I find this log? Maybe there is a easy way to get the coordinates for zoned-cleaning.

@rezmus
Copy link

rezmus commented Mar 25, 2021

create /vevs/logs/ and kill app. you will find everything (also zone clean coords) in /vevs/logs/miio/did.txt where did is your device id.

xvlady pushed a commit to xvlady/python-miio that referenced this pull request May 9, 2021
* Improve viomi vacuum status

* Fix missing char.

* Update miio/viomivacuum.py

Co-authored-by: Teemu R. <tpr@iki.fi>

* Update miio/viomivacuum.py

Co-authored-by: Teemu R. <tpr@iki.fi>

* Update miio/viomivacuum.py

Co-authored-by: Teemu R. <tpr@iki.fi>

* Update miio/viomivacuum.py

Co-authored-by: Teemu R. <tpr@iki.fi>

* Update miio/viomivacuum.py

Co-authored-by: Teemu R. <tpr@iki.fi>

* Update miio/viomivacuum.py

Co-authored-by: Teemu R. <tpr@iki.fi>

* Fix PR comments

* Fix PR comments

* Fix PR comments

* Update miio/viomivacuum.py

Co-authored-by: Teemu R. <tpr@iki.fi>

* Fix PR comments

* Fix PR comments

* Fix PR comments

Co-authored-by: Teemu R. <tpr@iki.fi>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants