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

Xiaomi Mi Robot Vacuum V1 - Fan Speed Issue #860

Closed
mat4444 opened this issue Nov 14, 2020 · 18 comments · Fixed by #893
Closed

Xiaomi Mi Robot Vacuum V1 - Fan Speed Issue #860

mat4444 opened this issue Nov 14, 2020 · 18 comments · Fixed by #893
Labels

Comments

@mat4444
Copy link
Contributor

mat4444 commented Nov 14, 2020

Describe the bug
This bug report is copied from home-assistant/core#43196
With the Xiaomi Mi Robot Vacuum V1 running on FW 3.5.8_004018, the fan speed options (Silent, Standard, Medium, Turbo and Gentle) are not understood by the vacuum.
However, from Home Assistant, fan speed can be set with the set_fan_speed service using the following integer values:
Silent --> 38
Standard --> 60
Medium --> 75
Turbo --> 100
Gentle --> Not an option for this vacuum

Version information (please complete the following information):

  • Platform: Raspberry Pi 3B+
  • OS: Running on HomeAssistant 0.117.6 (HassOS 4.15)
  • python-miio: version 0.5.3

Device information:

  • Model: Xiaomi Mi Robot Vacuum V1 (rockrobo.vacuum.v1)
  • Hardware version: Linux ?
  • Firmware version: 3.5.8_004018
    (PS: the command line in your bug report template misses 'info' at the end of miiocli device --ip <ip address> --token <token>)

To Reproduce
Using Home Assistant, I try to change the fan speed of my vacuum (v1) using the built-in options (drop down list), but it does not work. Nothing happens, there is no acknowledgment nor error message.
image
However, I can use the set_fan_speed service with integer values to change the speed.

Expected behavior
The vacuum speed should be changeable by default, using the default options.

Console output
No error in Home Assistant log

@mat4444 mat4444 added the bug label Nov 14, 2020
rytilahti added a commit that referenced this issue Nov 28, 2020
@rytilahti
Copy link
Owner

So the issue is, that since 3.5.7 for the v1 changed the behavior in regards of fan speed, see home-assistant/core#32723 and issues linked there (and in the fix pr). python-miio was adapted to check for the specific versions when v1 is detected (#643).

The logic is shown at https://github.com/rytilahti/python-miio/blob/master/miio/vacuum.py#L499 but I have no idea how to fix this without breaking anything. There are open questions like was the 100-105 format only temporary for the 3.5.7 series for v1, and could we remove the version detection?

For a quick fix, if you are not using the cloud functionality, simply block its internet access and it will start using the legacy speeds :-)

@mat4444
Copy link
Contributor Author

mat4444 commented Nov 29, 2020

Hello,
Thank you for your reply.
I am probably missing something obvious, but I don't see why adding a FW check against version 3.5.8 would be a breaking change? It only requires creating a new fanspeedV3 class with the new values. It won't affect people who still have a vacuum with FW version 3.5.7.
Regarding the cloud functionality, how can I simply block the internet access? Is it an option in xiaomi home app, or should it be done at the router level?

@syssi
Copy link
Collaborator

syssi commented Nov 29, 2020

On router level.

@rytilahti
Copy link
Owner

Hi, so the question is, is it only the firmware version 3.5.7 that has this different (100-105) fan speed setting, that is, can we use the v1 values on 3.5.8 (https://github.com/rytilahti/python-miio/blob/master/miio/vacuum.py#L55), or do we need a separate v3 for 3.5.8+?

Also, did you get the values by changing the speed using the official app? They are only slightly off from the v1 values, so if those are the new official ones, maybe we indeed need a v3 mapping for that.

@mat4444
Copy link
Contributor Author

mat4444 commented Nov 29, 2020

Hi, it seems that fan speed values on firmware 3.5.8 are different from the V1 and V2 values. We would need a V3 set of values.
I got these values using the official Xiaomi app and checking the status of the vacuum in Home Assistant:
Silent = 38
Standard = 60
Turbo = 75
Max =100
They are indeed different from the V1 values

@raxpa
Copy link

raxpa commented Dec 13, 2020

Hi there I have the same issue in the v1 version is there any solution?

@rytilahti
Copy link
Owner

@mat4444 just to clarify the situation, the newer firmware versions only accept specific values (instead of percentages) as previously? So using set_fan_speed on homeassistant works fine with 38 (for silent), but trying to set it to 10 won't work?

If so, a PR to add this new set of speeds for those newer firmware versions would be appreciated!

@mat4444
Copy link
Contributor Author

mat4444 commented Dec 21, 2020

@rytilahti, yes, the new firmware only accept the specific values I mentioned above. A percentage value like 10 does not work.
I have created a branch for these minors modifications, but I have no idea how to test it on my system before creating the PR.
I am almost sure it would work, but better checking first. Can you please indicate me how to check it ?
Thanks

@rytilahti
Copy link
Owner

rytilahti commented Dec 21, 2020

Okay, so here's the place where the available fan speeds are decided:

if info.model == ROCKROBO_V1:

The best way to try it out is to execute miiocli -d vacuum --ip 192.168.xxx.xxx --token xxxxxx fan_speed_presets & adding unit tests for the fan speed detection for the following cases:

  • Unable to query (fallback to old v1 values)
  • v1 & firmware version == 3.5.7 = v2 enum
  • v1 & firmware version > 3.5.7 = this would be a new enum with those fixed values

@mat4444
Copy link
Contributor Author

mat4444 commented Dec 22, 2020

I am not sure how to use the "fan_speed_presets" option with your command line tool. It only accepts integers.
Anyway, I have tested the updated code directly in HA by replacing the vacuum.py code and it works.
I have create PR #893 but it does not pass two checks. Would you mind having a look at it ?
Thanks!

@rytilahti
Copy link
Owner

Here's how it works on my vacuum:

$ miiocli vacuum --ip 192.168.xx.xx --token xxx fan_speed_presets
Running command fan_speed_presets
{'Silent': 38, 'Standard': 60, 'Medium': 77, 'Turbo': 90}

For the linting error, simply run pre-commit run -a in the directory to fix the issues and commit the changed files, then it should pass the CI checks, too!

@mat4444
Copy link
Contributor Author

mat4444 commented Dec 23, 2020

Sorry, but that's beyond my github knowledge. I don't know where to run the 'pre-commit run -a' command. Should it be done locally on my PC ? Or can it be run directly on Github ?
Sorry if it's a very dumb question, but I have very little knowledge of Github

@mat4444
Copy link
Contributor Author

mat4444 commented Jan 4, 2021

Hi, installed some python packages on my PC to try the 'pre-commit' command, but nothing works ... I really don't know what is wrong with my syntax.
The update of the vacuum.py file is very basic. If you don't mind, could you add these lines yourself to your code ?

line 70 :

class FanspeedV3(enum.Enum):
    Silent = 38
    Standard = 60
    Medium = 75
    Turbo = 100

line 504:

            if version >= (3, 5, 8):
                self._fanspeeds = FanspeedV3
            elif version == (3, 5, 7):
                self._fanspeeds = FanspeedV2
            else:
                self._fanspeeds = FanspeedV1

Thanks,
Mathieu

@rytilahti
Copy link
Owner

Hey Mathieu and thanks, I'll take a look at it at some point, unfortunately I'm very busy with other things at the moment so it may take some time to get to it.

Anyway, the simplest way with pre-commit would be the following:

(move to the source directory)
poetry install  # installs all the dependencies to a clean virtualenv
poetry run pre-commit run -a  # executes all precommit tests
(commit & push the changed files next)

@deluxestyle
Copy link

deluxestyle commented Jan 19, 2021

I updated manually the vacuum.py in my homeassistant installation and I can confirm that is now working
but I changed the fanspeed to following

class FanspeedV3(enum.Enum):
Silent = 38
Standard = 60
Turbo = 75
Max = 100

@rytilahti
Copy link
Owner

There was some unnecessary whitespaces that made linting unhappy, I fixed it now. Thanks for the PR, @mat4444 ! :-)

@mat4444
Copy link
Contributor Author

mat4444 commented Jan 20, 2021

You're welcome ! Thanks for the commit, it honestly was beyond my knowledge with Github !
When can we expect to have this update in H.A ?

@rytilahti
Copy link
Owner

There is no real release schedule in this project, so it's unclear when there will be one. I won't be having any time to do preparations for that until some time in February (I'm not sure about @syssi), and it will still take some time from that until the homeassistant integration gets updated & released. So for the time being you may want to manually edit the file for your own setup :-)

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

Successfully merging a pull request may close this issue.

5 participants