merdok / homebridge-miot

Homebridge plugin for devices supporting the Xiaomi miot protocol
MIT License
388 stars 61 forks source link

Roborock S7 maxV statuses not synchronized #286

Closed nicoodeimos closed 2 years ago

nicoodeimos commented 2 years ago

Describe the bug A clear and concise description of what the bug is. Roborock s7 maxV statuses are not correctly synchronized with HomeKit. While washing the mop, or mop+sweeping, HomeKit tile is not updated and appears « turned off ».

I looked on logs and found that many statuses returned by the device roborock.vacuum.a27 (which is s7 maxV) are not handled by the plug-in.

1D044E4D-96EE-43E5-BC56-FDC29B8BB6AF

merdok commented 2 years ago

Oh, right... Will add the missing status mapping in the next update!

merdok commented 2 years ago

Oh, i see that it is no clear from the spec what status is the mop and what is the mop+sweeping. Could you please check on your device? You would need to add a propertyMonitor for your device for the property vacuum:status and let me know what numbers come up during mop and during mop+sweeping. That would be helpful...

nicoodeimos commented 2 years ago

Let me check. Do you know why the official doc is so poorly documented? Any ways to have a more trustable source to determine the status?

Also, I found that after updating to the last fix for the properties (previous bug), I can no longer update device mode with actions. Device seems unresponsive and does not updates its mode with « dig » sound. HomeKit button stays on for a few secs and reverts to off. I’ll have to dig into the logs. Right ?

merdok commented 2 years ago

Not sure why... Yes, you have to check the logs. But please first add the propertyMonitor and provide me with the correct status id for mop and sweep+mop.

nicoodeimos commented 2 years ago

So here is what I got:

For the unresponsive mode buttons from HomeKit

[6/12/2022, 2:32:44 PM] [miot] [Roborock S7 MaxV] Set vacuum:mode property request! RAW: {"did":"xxxx","siid":2,"piid":4,"value":"106"}
[6/12/2022, 2:32:44 PM] [miot] [Roborock S7 MaxV] (Protocol) Call 192.168.1.4: set_properties - [{"did":"xxxx","siid":2,"piid":4,"value":"106"}] - {"retries":2,"timeout":4000}
[6/12/2022, 2:32:44 PM] [miot] [Roborock S7 MaxV] (Protocol) 192.168.1.4 <- (2) {"method":"set_properties","params":[{"did":"xxxx","siid":2,"piid":4,"value":"106"}],"id":291}
[6/12/2022, 2:32:44 PM] [miot] [Roborock S7 MaxV] (Protocol) 192.168.1.4 <- !1�鏫��j.5)��׊p0����K
[6/12/2022, 2:32:44 PM] [miot] [Roborock S7 MaxV] (Protocol) 192.168.1.4 -> Data: {"id":291,"result":{"code":-4004},"exe_time":100}
[6/12/2022, 2:32:44 PM] [miot] [Roborock S7 MaxV] (Protocol) 192.168.1.4 -> Message: {"id":291,"result":{"code":-4004},"exe_time":100}
[6/12/2022, 2:32:44 PM] [miot] [Roborock S7 MaxV] Error: Error while setting property vacuum:mode to value 106! Invalid response. Response: {"code":-4004}

For the modes

Vacuum only — Quiet 101
Vacuum only — Balanced 102
Vacuum only — Turbo 103
Vacuum only — Max 104
Vacuum only — Max+ 108

Mopping only (any scrub intensity or route) — 105
**Seems weird that device does not change the mode if I switch scrub intensity or suction power.**

Vac + mop (any scrub intensity) — Quiet 101
Vac + mop (any scrub intensity) — Balanced 102
Vac + mop (any scrub intensity) — Turbo 103
Vac + mop (any scrub intensity) — Max 104
**Seems weird that device does not change the mode if I switch scrub intensity.**

For the statuses

Clean All — 5
Clean Rooms — 18
Clean Zone — 17

Go charging — 6
Go washing — 26

Washing — 23
Emptying — 22
Charging — 8

Paused — 10
Idle — 3

Let me know if this helps. Do you have any idea how to change the suction power or scrub intensity with a HomeKit action? Thanks!

merdok commented 2 years ago

For the modes: not sure if you are using a propertyControl for that, but the mode "Custom" has the value 106, not "106" (it is a number not a string), this is why you getting an error while trying to set that value.

Ok, so mopping has status 23, and how about mopping and sweeping?

You could do two propertyControl entries for suction power or scrub intensity which will then allow you to use them in homekit

nicoodeimos commented 2 years ago

Actually, 23 is for the wash empty dock, while washing the mop.

Mopping and sweeping or both are either 5, 18 or 17 depending on the cleaning type (full map, zone or rooms). I always get those values no matter if mopping of vacuuming of both (s7 maxV allows each).

Regarding the scrub intensity and suction power, I have not figured their own modes since they always return 105. That’s why I was asking if you had any idea.

1AD03C73-913A-4308-9D47-321E991ECA15 A6268D7F-E842-4A38-88C4-5893A4A0D4AC A2FDB104-DFF3-49FA-8363-CF3C76CFB894

merdok commented 2 years ago

I see sweeping have the status id's 5, 7, 11, 16, 17, 18, 29. That is quit some, can you maybe tell me the differences between those? Since I need to figure out how to name those to easily identify what is happening. The best way is that you try all the various options of your vacuum and and see how the status changes. That would be really helpful.

Hmm, scrub intensity and suction power is actually missing in the miot protocol spec, see: https://merdok.github.io/miotspec/?model=roborock.vacuum.a27 I wonder how they send those settings... For that you would need to intercept the vacuum traffic in order for me to see what is actually being sent by the official app...

nicoodeimos commented 2 years ago

That is exactly what I did and failed to get statuses other than 5, 17 and 18. They map to vacuum being on « sweeping » or « mopping » or both (see screenshots), for the « all apartment », « room only » or « zone only » modes, but nothing else. I’m stuck here.

Another way to say it is that, if I start a room clean, let’s say, vacuum only, then I always get status 5, no matter the suction power, of scrub. Same goes for clean all (status 5) and clean specific zone (status 17).

When you say « intercept traffic », you mean with Charles for iOS for ex?

I really don’t understand why the documentation is so poorly written 😮

nicoodeimos commented 2 years ago

Ok, here is what I found from this:

        case 1:
          return "initiating";
        case 2:
          return "charger-offline";
        case 3:
          return "waiting";
        case 5:
          return "cleaning";
        case 6:
          return "returning";
        case 8:
          return "charging";
        case 9:
          return "charging-error";
        case 10:
          return "paused";
        case 11:
          return "spot-cleaning";
        case 12:
          return "error";
        case 13:
          return "shutting-down";
        case 14:
          return "updating";
        case 15:
          return "docking";
        case 17:
          return "zone-cleaning";
        case 18:
          return "room-cleaning";
        case 22:
          return "dust-collection";
        case 100:
          return "full";
merdok commented 2 years ago

Ok, well in that case i will set status 17 to mopping and 18 to sweeping+mopping. Hope that will work. With intercept i mean that you would need to use the modified mi home app using an android device. That modified app can log all requests in plain text which help to find such things.

nicoodeimos commented 2 years ago

Well, 18, 5, 11 and 17 are just different cleaning modes, they are not related to how you clean. You could have all sorts of strategies to clean (mop, vac, mop+vac) for the above cleaning modes. In essence, if status is [18, 17, 5, 11] you can consider the accessory active, but you cannot know if sweeping or mopping or both.

merdok commented 2 years ago

Yeah, this is kind of strange for this device. It has quite some sweeping statuses but they are not actually differentiated what they do... Anyway, I will try to come up with a solution to map all of them!

nicoodeimos commented 2 years ago

I can run tests if you need to. Just let me know! Honestly would be ready to kill to have this plugin working as the other one is buggy as f.ck is does not seem to be maintained well.

merdok commented 2 years ago

I just pushed a commit which now should fix your issues. You can simply download the lib\modules\robotcleaner\devices\roborock.vacuum.a27.js file, replace it locally and restart homebridge. You can try that out and let me know if that fixes your issues.

yestrdave commented 2 years ago

Nicolas, I have been running the other plug in with my s6 max. Worked ok. I have a new S7 maxV Ultra coming tomorrow. I was just looking at this plug in. Could you share the config file with me. I’m a not great with scripting. I need to figure the rooms out. It was a pain with the other plug in. Feel free to reach out drichhome@live.com please.

nicoodeimos commented 2 years ago

Nicolas, I have been running the other plug in with my s6 max. Worked ok. I have a new S7 maxV Ultra coming tomorrow. I was just looking at this plug in. Could you share the config file with me. I’m a not great with scripting. I need to figure the rooms out. It was a pain with the other plug in. Feel free to reach out drichhome@live.com please.

I'm afraid I don't know how to add room cleaning with this plugin. There seems to be no out-of-the-box management of room discovery and handling. The other plugin does however but is far more buggy.

Here is my config file, if that helps:

      {
            "devices": [
                {
                    "name": "Roborock S7 MaxV",
                    "ip": "YOUR_IP",
                    "token": "YOUR_TOKEN",
                    "deviceId": "YOUR_DEVICE_ID",
                    "model": "roborock.vacuum.a27",
                    "pollingInterval": 10,
                    "deepDebugLog": false,
                    "buzzerControl": false,
                    "ledControl": false,
                    "childLockControl": false,
                    "modeControl": true,
                    "propertyControl": [
                        {
                            "property": "vacuum:mode",
                            "name": "Quiet mode",
                            "value": 101
                        },
                        {
                            "property": "vacuum:mode",
                            "name": "Balanced mode",
                            "value": 102
                        },
                        {
                            "property": "vacuum:mode",
                            "name": "Turbo mode",
                            "value": 103
                        },
                        {
                            "property": "vacuum:mode",
                            "name": "Max mode",
                            "value": 104
                        },
                        {
                            "property": "vacuum:mode",
                            "name": "Max+ mode",
                            "value": 108
                        },
                        {
                            "property": "vacuum:mode",
                            "name": "Custom mode",
                            "value": 106
                        }
                    ]
                }
            ],
            "platform": "miot"
        }
nicoodeimos commented 2 years ago

@merdok I tested with new file, there seem to be improvements! Thanks! HomeKit now reports vacuum as ON when sweeping + mopping.

Any idea how to handle water scrub intensity independently from the suction power? This plugin only seems to handle setting modes, but I can’t find anywhere reference for actions to change scrub intensity. Many thanks!

merdok commented 2 years ago

Food to hear that it improved👍

If it is not available in the miot spec then it is not possible, nothing to do with the plugin.

nicoodeimos commented 2 years ago

That is what I figured, ok. Thank you anyway!

yestrdave commented 2 years ago

I’m guessing you guys haven’t got room mapping params string figured out ? I’m really sorry I would love to help get this sorted but I,m in and out of the country until end of July.

Thanks DaveR


From: Nicolas Bigot @.> Sent: Thursday, July 7, 2022 8:08:43 AM To: merdok/homebridge-miot @.> Cc: yestrdave @.>; Comment @.> Subject: Re: [merdok/homebridge-miot] Roborock S7 maxV statuses not synchronized (Issue #286)

That is what I figured, ok. Thank you anyway!

— Reply to this email directly, view it on GitHubhttps://github.com/merdok/homebridge-miot/issues/286#issuecomment-1177506783, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AWMXKFPFARD4HXK64LXZL5TVS3CEXANCNFSM5YN5GXNA. You are receiving this because you commented.Message ID: @.***>

nicoodeimos commented 2 years ago

This is the next thing I'll try, probably this week-end. Will let you know if progress 👍

nicoodeimos commented 2 years ago

Sooooo, I tried everything I had in mind to handle room cleaning, but I was unable to make it work. I can start a cleaning with actions

vacuum:start-sweep
vacuum:start-mop
vacuum:start-sweep-mop
vacuum:start-room-sweep

but the robot doesn't seem to care whether its mopping, sweeping or specific rooms. It only starts a full clean of the map. I'm giving up guys 🤷🏻‍♂️

nicoodeimos commented 2 years ago

Hey @merdok, any plans to merge this in main and release an official fix? Many thanks !

merdok commented 2 years ago

What do you mean? If you are talking about the status fix, then this was already part of the last update.