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 Miio vacuum sensor values incorrect #58923

Closed
tomlut opened this issue Nov 2, 2021 · 24 comments · Fixed by #58995
Closed

Xiaomi Miio vacuum sensor values incorrect #58923

tomlut opened this issue Nov 2, 2021 · 24 comments · Fixed by #58995

Comments

@tomlut
Copy link

tomlut commented Nov 2, 2021

The problem

With the move from attributes to sensors the Xiaomi Miio vacuum integration is no longer reporting accurate values for my S5 vacuum. Some are much worse than others:

HA Sensor HA (sec) HA (hrs) Mi Home (hrs) Difference (hrs)
sensor.robovac_downstairs_filter_left 35888 9.97 106 -96.03
sensor.robovac_downstairs_main_brush_left 83547 23.21 263 -239.79
sensor.robovac_downstairs_sensor_dirty_left 66237 18.40 18 0.40
sensor.robovac_downstairs_side_brush_left 69147 19.21 163 -143.79
sensor.robovac_upstairs_filter_left 85513 23.75 120 -96.25
sensor.robovac_upstairs_main_brush_left 71083 19.75 212 -192.25
sensor.robovac_upstairs_sensor_dirty_left 35105 9.75 10 -0.25
sensor.robovac_upstairs_side_brush_left 56683 15.75 112 -96.25

Also the use of seconds as a unit is not helpful for values measured in days and will require creating templates sensors for each sensor to rectify this. Can the values be reported in hours instead, as the attribute used to be?

What version of Home Assistant Core has the issue?

core-2021.11.0b3

What was the last working version of Home Assistant Core?

core-2021.10.6

What type of installation are you running?

Home Assistant OS

Integration causing the issue

core-2021.11.0b3

Link to integration documentation on our website

https://www.home-assistant.io/integrations/xiaomi_miio/

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

@probot-home-assistant
Copy link

Hey there @rytilahti, @syssi, @starkillerOG, @bieniu, mind taking a look at this issue as it has been labeled with an integration (xiaomi_miio) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)


xiaomi_miio documentation
xiaomi_miio source
(message by IssueLinks)

@tomlut tomlut changed the title Xiaomi Miio vacuum sensors incorrect Xiaomi Miio vacuum sensor values incorrect Nov 2, 2021
@pdobrien3
Copy link

I have the roborocks S4. I vote for hours as the xiaomi mi app uses but anything is better than seconds. Here is what my sensor are reporting

I don't think the sensors are accurate either. I just went and did all the calculations. The app reports in hours which I think is good. But here is what I found out:

Main Brush Time Report = 21,290 seconds = 5.9138889 hours and the app reports 150 hours
Side Brush Time Reports = 6,890 seconds = 1.913889 hours and the app reports 50 hours
Sensor Time Reports = 1,468 seconds = 0.4077778 hours and the app reports 24 hours
Filter Time Reports = 82,065 seconds = 22.795833 hours and the app reports 143 hours
Total Cleaning Time Reports = 21,906 seconds =  6.085 hours and the app reports 150 hours

@tomlut
Copy link
Author

tomlut commented Nov 2, 2021

I've edited my issue, Hours would be acceptable for me too. That is what the attributes used to be reported in.

@hmmbob
Copy link
Contributor

hmmbob commented Nov 2, 2021

I'm seeing the same - the new units come in no calculation close to the values reported by the app.

I.e.:
Side brush sensor in HA: 47753s left (=~796hrs!)
Side brush in app: 181hrs left

S5 Max

@frenck frenck added this to the 2021.11.0 milestone Nov 2, 2021
@mbo18
Copy link
Contributor

mbo18 commented Nov 2, 2021

From what I understood, data from the vacuum is in seconds, that’s why it is in second in HA.
#54990 (comment)

@hmmbob
Copy link
Contributor

hmmbob commented Nov 2, 2021

From what I understood, data from the vacuum is in seconds, that’s why it is in second in HA. #54990 (comment)

Yeah, that's known. The issue is that the value is incorrect and way off. The unit_of_measurement is a choice (debated, but chosen for s), but then the value should be accurate so if you calculate it back to whatever the original app uses, it is the same. And it isn't.

@pdobrien3

This comment has been minimized.

@tomlut

This comment has been minimized.

@hmmbob
Copy link
Contributor

hmmbob commented Nov 2, 2021

but the sensor_dirty sensors are completely wrong when converted to hours and compared to the app.

And this is the issue at hand ;-) (for all sensors btw)

@tomlut
Copy link
Author

tomlut commented Nov 2, 2021

Nope. Look at the first post. Only the filter_left and main_brush_left are incorrect. The sensor_dirty_left just suffers a small amount of rounding error.

@pdobrien3
Copy link

All of my maintenance sensors are wrong, including the total cleaned time.

@hmmbob
Copy link
Contributor

hmmbob commented Nov 2, 2021

Same for me, all sensors are way off

@tomlut
Copy link
Author

tomlut commented Nov 2, 2021

Weird. So the S5 has one sensor that is correct. The S5 Max and S4 sensors are all wrong.

@rytilahti
Copy link
Member

rytilahti commented Nov 2, 2021

Could someone try if mirobo consumables or miiocli vacuum --ip <ip> --token <token> consumable_status (and miiocli vacuum --ip <ip> --token <token> clean_history are reporting correct values?

Also, did the state attributes used to report the values correctly or was it always incorrect?

For the "x left" values, the deviation may be caused by different devices reporting the values differently, the current calculations are based on hard-coded values used by my gen1 vacuum as listed here: https://github.com/rytilahti/python-miio/blob/master/miio/integrations/vacuum/roborock/vacuumcontainers.py#L337

edit: I can confirm that the values reported by homeassistant sensors are incorrect. While homeassistant reports positive values (filter left 37,710 s, sensor dirty left 9,473 s) here is what mirobo says:

$ mirobo consumables
Main brush:   7 days, 19:47:11 (left 4 days, 16:12:49)
Side brush:   7 days, 19:47:11 (left 12:12:49)
Filter:       7 days, 19:31:30 (left -2 days, 10:28:30)
Sensor dirty: 3 days, 3:22:07 (left -2 days, 2:37:53)

edit2: Let's keep this issue on the topic of wrong values being reported, and avoid discussing about what is the proper unit to use. There is an architecture issue regarding on the measurement granularity and whether that's backend's or frontend's task, discussion on that should be avoided in this issue.

@tomlut
Copy link
Author

tomlut commented Nov 3, 2021

It used to be correct.

It also used to be in hours which was usable.

The new use of seconds as a unit is not. This is definitely part of the issue of the new integration implementation.

@pdobrien3
Copy link

@rytilahti , I would be happy to help. I run HAss in docker. I imagine this would need to be either inside the container or I would need to install something? If you nudge me along I will get what I can.

@rytilahti
Copy link
Member

I found the problem and the linked PR should fix it, unfortunately it'll be first fixed in the first point release :(

@pdobrien3 yes, those commands should be run on the container (or any system) where python-miio is installed. But there's no need for that now, thanks for the offer though!

@OGKevin
Copy link
Contributor

OGKevin commented Nov 3, 2021

Apologies, was not aware of this issue. Would have looked into it otherwise. But I see @rytilahti already found and fixed the issue 👍🏾. Rookie mistake on my end to not actually validate the data during the migration😅.

@tomlut
Copy link
Author

tomlut commented Nov 5, 2021

It seems the values are now correct but the units are still not at all appropriate.

EDIT: I see a PR is open to fix this. ❤️

@hmmbob
Copy link
Contributor

hmmbob commented Nov 5, 2021

Values are correct here as well.

Discussion on unit_of_measurement: #59027
Potential fix for that: #59092

@pdobrien3
Copy link

pdobrien3 commented Nov 5, 2021

My values are also correct. Noticed something different though. Will create a new issue if someone else is experiencing it. My vacuum went into error mode yesterday. Got hung up on a cord. I have an automation to notify me when the unit goes to an error state. Before 2021.11, I would receive one notify and all good. Yesterday I was getting spammed about every couple minutes. I looked and the vacuum was going back and forth from unavailable to error causing multiple notifies. Easy to fix in the automation trigger just wanted to make sure it wasn’t a larger issue.

@maretodoric
Copy link

maretodoric commented Nov 6, 2021

Unfortunately i have to report that my values are not correct for some reason. Following entities:
sensor.roborock_vacuum_s5e_filter_left: 28960
sensor.roborock_vacuum_s5e_main_brush_left: 50560
sensor.roborock_vacuum_s5e_sensor_dirty_left: 83663
sensor.roborock_vacuum_s5e_side_brush_left: 36160

When i run miiocli vacuum --ip --token --model roborock.vacuum.s5e status i get:

<ConsumableStatus filter=2 days, 21:57:20 filter_left=3 days, 8:02:40 main_brush=2 days, 21:57:20 main_brush_left=9 days, 14:02:40 sensor_dirty=6:45:37 sensor_dirty_left=23:14:23 side_brush=2 days, 21:57:20 side_brush_left=5 days, 10:02:40>

So it appears it's only evaluating based on hours displayed and ignoring "# days"
In first example (for filter), miiocli returns:

filter_left=3 days, 8:02:40

However sensors says 28960 seconds, which would pretty much mean 8 hours 2 minutes and 40 seconds.
Truth be told i was using new python-miio directly from github, it's not apparently yet released in pip repository, so --model command is misiing in HassOS. However when i try to run miiocli command in HassOS homeassistant docker i get the same:

bash-5.1# miiocli vacuum --ip <ip> --token <token> consumable_status
Running command consumable_status
<ConsumableStatus filter=2 days, 21:57:20 filter_left=3 days, 8:02:40 main_brush=2 days, 21:57:20 main_brush_left=9 days, 14:02:40 sensor_dirty=6:45:37 sensor_dirty_left=23:14:23 side_brush=2 days, 21:57:20 side_brush_left=5 days, 10:02:40>

Is the fix planned?

@hmmbob
Copy link
Contributor

hmmbob commented Nov 6, 2021

It's in 2021.11.1

@maretodoric
Copy link

Yup, you're right, sorry. Just updated and it's there. Thanks!

@github-actions github-actions bot locked and limited conversation to collaborators Dec 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants