merdok / homebridge-miot

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

Roidmi EVE - specific room cleaning #236

Closed sadanro100 closed 2 years ago

sadanro100 commented 2 years ago

Device model roidmi.vacuum.v60

Device name Roidmi EVE

Hi there I've successfully setup my Roidmi EVE, I am able to start and stop cleaning the whole map but I'm having a hard time figuring out how to make it clean only one or more specific rooms.

I am not sure how to retrieve the room IDs, the README only states how to retrieve Dreame and Viomi room IDs, and the action mentioned there is not available either.

These are the actions available for my device:

"vacuum:start-sweep", "vacuum:stop-sweeping", "vacuum:start-room-sweep", "battery:start-charge", "filter:reset-filter-life", "brush-cleaner:reset-brush-life", "brush-cleaner2:reset-brush-life", "brush-cleaner3:reset-brush-life", "custom:find-robot", "custom:stop-find-charge", "custom:continue-sweep", "custom:start-dust", "custom:pause", "custom:pause-find-charge", "custom:continue-find-charge", "custom:update-audio", "custom:set-voice", "map:request-path", "map:change-area-name", "map:set-auto-area", "map:local-map", "map:area-custom", "map:area-order", "sweep:start-sweep"

merdok commented 2 years ago

Since i do not have the given device, i cannot do any investigation by myself. You would need to try investigate this and share any knowledge which you gathered during that. It is very likely that you can either use the vacuum:start-room-sweep or sweep:start-sweep action, the issue is just to find out the proper parameters format.

sadanro100 commented 2 years ago

Any clues on how I can fetch the correct parameters format?

merdok commented 2 years ago

You can use the modified Mi Home app if you have an Android device and enable logging there. Then you can start the room cleaning from that app and the commands including the parameters will be logged.

It is the Mi Home vevs app

sadanro100 commented 2 years ago

Thank you for the heads up. I've only got a jailbroken iPhone, I'll be looking into that first as I'm an iOS/jailbreak developer. Thanks. As soon as I figure it out I'll post it up here.

merdok commented 2 years ago

Not sure if such an app exists for iOS, but if you happen to figure something out for iOS then please let me know.

Other then that, you would need to get an cheap android device and try it with that.

sadanro100 commented 2 years ago

@merdok

I managed to find the Ids on iOS using jailbreak, but I can't see the calls to understand the parameters format since the payloads are all scrambled.

I also tried Mi Home Vevs on an Android emulator, it did create the folders in /sdcard/vevs but no files are created after starting a clean. Can you help me with that please?

sadanro100 commented 2 years ago

Just figured it out. I had to enable this

7649105D-9DF4-491C-B253-EFC9F9C2C0E3

I'll be right back with the correct format to help others.

sadanro100 commented 2 years ago

This is what I got in the log file after starting an area clean:

2022-03-04 16:07:05 -> {"params":[{"did":"519878831","siid":2,"piid":2}],"datasource":1} /miotspec/prop/get
2022-03-04 16:07:05 <- {"code":0,"message":"","result":[{"did":"519878831","siid":2,"piid":2,"value":0,"code":0,"updateTime":1646239070,"exe_time":0}]}
2022-03-04 16:07:08 -> {"params":[{"did":"519878831","siid":2,"piid":1},{"did":"519878831","siid":3,"piid":1},{"did":"519878831","siid":3,"piid":2},{"did":"519878831","siid":2,"piid":4},{"did":"519878831","siid":8,"piid":11},{"did":"519878831","siid":8,"piid":1},{"did":"519878831","siid":8,"piid":20},{"did":"519878831","siid":8,"piid":19},{"did":"519878831","siid":8,"piid":7},{"did":"519878831","siid":2,"piid":2},{"did":"519878831","siid":8,"piid":1},{"did":"519878831","siid":14,"piid":1},{"did":"519878831","siid":13,"piid":8},{"did":"519878831","siid":8,"piid":30},{"did":"519878831","siid":8,"piid":26},{"did":"519878831","siid":10,"piid":1},{"did":"519878831","siid":11,"piid":2},{"did":"519878831","siid":12,"piid":2},{"did":"519878831","siid":15,"piid":2},{"did":"519878831","siid":1,"piid":4},{"did":"519878831","siid":13,"piid":7},{"did":"519878831","siid":8,"piid":29}],"datasource":1} /miotspec/prop/get
2022-03-04 16:07:08 -> {"params":{"siid":13,"aiid":2,"did":"519878831","in":["{\"StartPos\":0,\"PathID\":0,\"UID\":\"580715\"}"]}} /miotspec/action
2022-03-04 16:07:08 <- {"code":0,"message":"","result":{"did":"519878831","miid":0,"siid":13,"aiid":2,"code":0,"exe_time":0,"withLatency":0}}
2022-03-04 16:07:08 <- {"code":0,"message":"","result":[{"did":"519878831","siid":2,"piid":1,"value":9,"code":0,"updateTime":1646420796,"exe_time":0},{"did":"519878831","siid":3,"piid":1,"value":100,"code":0,"updateTime":1646366988,"exe_time":0},{"did":"519878831","siid":3,"piid":2,"value":1,"code":0,"updateTime":1646420827,"exe_time":0},{"did":"519878831","siid":2,"piid":4,"value":4,"code":0,"updateTime":1646245293,"exe_time":0},{"did":"519878831","siid":8,"piid":11,"value":0,"code":0,"updateTime":1646245293,"exe_time":0},{"did":"519878831","siid":8,"piid":1,"value":true,"code":0,"updateTime":1646239070,"exe_time":0},{"did":"519878831","siid":8,"piid":20,"value":false,"code":0,"updateTime":1646245292,"exe_time":0},{"did":"519878831","siid":8,"piid":19,"value":0,"code":0,"updateTime":1646420054,"exe_time":0},{"did":"519878831","siid":8,"piid":7,"value":0,"code":0,"updateTime":1646420054,"exe_time":0},{"did":"519878831","siid":2,"piid":2,"value":0,"code":0,"updateTime":1646239070,"exe_time":0},{"did":"519878831","siid":8,"piid":1,"value":true,"code":0,"updateTime":1646239070,"exe_time":0},{"did":"519878831","siid":14,"piid":1,"value":0,"code":0,"updateTime":1646420795,"exe_time":0},{"did":"519878831","siid":13,"piid":8,"value":0,"code":0,"updateTime":1646245293,"exe_time":0},{"did":"519878831","siid":8,"piid":30,"value":"file not exist !!!","code":0,"updateTime":1646420827,"exe_time":0},{"did":"519878831","siid":8,"piid":26,"value":"girl_en","code":0,"updateTime":1646420827,"exe_time":0},{"did":"519878831","siid":10,"piid":1,"value":93,"code":0,"updateTime":1646364717,"exe_time":0},{"did":"519878831","siid":11,"piid":2,"value":96,"code":0,"updateTime":1646364717,"exe_time":0},{"did":"519878831","siid":12,"piid":2,"value":95,"code":0,"updateTime":1646364717,"exe_time":0},{"did":"519878831","siid":15,"piid":2,"value":67,"code":0,"updateTime":1646364717,"exe_time":0},{"did":"519878831","siid":1,"piid":4,"value":"0.9.6_2365","code":0,"exe_time":0},{"did":"519878831","siid":13,"piid":7,"value":false,"code":0,"updateTime":1646239073,"exe_time":0},{"did":"519878831","siid":8,"piid":29,"value":102,"code":0,"updateTime":1646239073,"exe_time":0}]}
2022-03-04 16:07:13 -> {"params":{"siid":13,"aiid":2,"did":"519878831","in":["{\"StartPos\":0,\"PathID\":0,\"UID\":\"580715\"}"]}} /miotspec/action
2022-03-04 16:07:13 <- {"code":0,"message":"","result":{"did":"519878831","miid":0,"siid":13,"aiid":2,"code":0,"exe_time":0,"withLatency":0}}
2022-03-04 16:07:15 -> {"params":{"did":"519878831","siid":14,"aiid":1,"in":[2,"{\"mapId\":1645447746,\"segmentId\":[4]}"]}} /miotspec/action
2022-03-04 16:07:15 <- {"code":0,"message":"","result":{"did":"519878831","miid":0,"siid":14,"aiid":1,"code":0,"exe_time":0,"withLatency":0}}
2022-03-04 16:07:18 -> {"params":{"siid":13,"aiid":2,"did":"519878831","in":["{\"StartPos\":0,\"PathID\":0,\"UID\":\"580715\"}"]}} /miotspec/action
2022-03-04 16:07:18 <- {"code":0,"message":"","result":{"did":"519878831","miid":0,"siid":13,"aiid":2,"code":0,"exe_time":0,"withLatency":0}}
2022-03-04 16:07:22 -> {"params":{"siid":13,"aiid":2,"did":"519878831","in":["{\"StartPos\":0,\"PathID\":0,\"UID\":\"580715\"}"]}} /miotspec/action
2022-03-04 16:07:22 <- {"code":0,"message":"","result":{"did":"519878831","miid":0,"siid":13,"aiid":2,"code":0,"exe_time":0,"withLatency":0}}
2022-03-04 16:07:27 -> {"params":{"siid":13,"aiid":2,"did":"519878831","in":["{\"StartPos\":0,\"PathID\":0,\"UID\":\"580715\"}"]}} /miotspec/action
2022-03-04 16:07:27 <- {"code":0,"message":"","result":{"did":"519878831","miid":0,"siid":13,"aiid":2,"code":0,"exe_time":0,"withLatency":0}}

I suppose this is the line I need to use:

{"params":{"did":"519878831","siid":14,"aiid":1,"in":[2,"{\"mapId\":1645447746,\"segmentId\":[4]}"]}} /miotspec/action

And this is where I'm gonna use it:

{
    "action": "vacuum:start-room-sweep",
    "name": "Banheiro",
    "params": [ HERE ]
}

Can you help me with this last step please?

sadanro100 commented 2 years ago

Just tried it like this but nothing happens when I press the button:

"actionButtons": [{
    "action": "vacuum:start-room-sweep",
    "name": "Banheiro",
    "params": [{
        "did": "519878831",
        "siid": 14,
        "aiid": 1,
        "in": [
            2,
            "{\"mapId\":1645447746,\"segmentId\":[4]}"
        ]
    }]
}]
merdok commented 2 years ago

That is some good info you got there. With the info that you provided, the command should look like this:

{
    "action": "14.1",
    "name": "Banheiro",
    "params": [
        2,
        "{\"mapId\":1645447746,\"segmentId\":[4]}"
    ]
}

Try that and check if it works

sadanro100 commented 2 years ago

Unfortunately that didn't work. I tried the following actions as well:

"vacuum:start-sweep" "vacuum:start-room-sweep" "sweep:start-sweep"

Only the first one responded, but it basically started a regular clean, it didn't respect the room params :( Any more suggestions please?

merdok commented 2 years ago

That should certainly work since it is basically the same command as the vacuum is sending. Make sure that there are no typos, you can also post the debug log from executing the action so we can check how it looks like.

sadanro100 commented 2 years ago

Even after enabling

"deepDebugLog": true

I get absolutely nothing in the log after pressing the button. I changed it back to what you suggested and just like before, I copied and pasted it. Still, I double checked spelling and it's all fine.

merdok commented 2 years ago

If you do not get anything in the log after pressing the button then you are doing something wrong. You probably did not start homebridge in debug mode as described in the README. You need to properly enable debugging so we can see what is happening...

sadanro100 commented 2 years ago

You're right, I didn't have Homebridge in debug mode. This is what appears in the log when I press the button:

[3/6/2022, 4:51:14 AM] [miot] [Aspirador] Send action! RAW: {"did":"519878831","siid":14,"aiid":1,"in":[{"piid":1,"value":2},{"piid":2,"value":"{\"mapId\":1645447746,\"segmentId\":[4]}"}]}
[3/6/2022, 4:51:14 AM] [miot] [Aspirador] (MiCloud) Encrypted request https://api.io.mi.com/app/miotspec/action - {"params":{"did":"519878831","siid":14,"aiid":1,"in":[{"piid":1,"value":2},{"piid":2,"value":"{\"mapId\":1645447746,\"segmentId\":[4]}"}]}}
[3/6/2022, 4:51:16 AM] [miot] [Aspirador] Error: Error while executing action sweep:start-sweep with params 2,{"mapId":1645447746,"segmentId":[4]}! Invalid response from device. Response: {"did":"519878831","miid":0,"siid":14,"aiid":1,"code":-704220035,"exe_time":0,"withLatency":0}
[3/6/2022, 4:51:16 AM] [miot] [Aspirador] Error: Error while executing action sweep:start-sweep with params 2,{"mapId":1645447746,"segmentId":[4]}! Invalid response from device. Response: {"did":"519878831","miid":0,"siid":14,"aiid":1,"code":-704220035,"exe_time":0,"withLatency":0}
merdok commented 2 years ago

-704220035 means that the action parameters are invalid, but it seems that all looks good. Maybe the mapId parameter changed, or is only generated per request somehow? What if you start the same room cleaning as before in the modified xiaomi home app, is the mapId still the same or does it change?

sadanro100 commented 2 years ago

This is the output generated this time:

2022-03-06 05:15:30 -> {"params":[{"did":"519878831","siid":2,"piid":2}],"datasource":1} /miotspec/prop/get
2022-03-06 05:15:30 <- {"code":0,"message":"","result":[{"did":"519878831","siid":2,"piid":2,"value":0,"code":0,"updateTime":1646495513,"exe_time":0}]}
2022-03-06 05:15:30 -> {"params":[{"did":"519878831","siid":2,"piid":1},{"did":"519878831","siid":3,"piid":1},{"did":"519878831","siid":3,"piid":2},{"did":"519878831","siid":2,"piid":4},{"did":"519878831","siid":8,"piid":11},{"did":"519878831","siid":8,"piid":1},{"did":"519878831","siid":8,"piid":20},{"did":"519878831","siid":8,"piid":19},{"did":"519878831","siid":8,"piid":7},{"did":"519878831","siid":2,"piid":2},{"did":"519878831","siid":8,"piid":1},{"did":"519878831","siid":14,"piid":1},{"did":"519878831","siid":13,"piid":8},{"did":"519878831","siid":8,"piid":30},{"did":"519878831","siid":8,"piid":26},{"did":"519878831","siid":10,"piid":1},{"did":"519878831","siid":11,"piid":2},{"did":"519878831","siid":12,"piid":2},{"did":"519878831","siid":15,"piid":2},{"did":"519878831","siid":1,"piid":4},{"did":"519878831","siid":13,"piid":7},{"did":"519878831","siid":8,"piid":29}],"datasource":1} /miotspec/prop/get
2022-03-06 05:15:31 <- {"code":0,"message":"","result":[{"did":"519878831","siid":2,"piid":1,"value":9,"code":0,"updateTime":1646535914,"exe_time":0},{"did":"519878831","siid":3,"piid":1,"value":100,"code":0,"updateTime":1646509434,"exe_time":0},{"did":"519878831","siid":3,"piid":2,"value":1,"code":0,"updateTime":1646554530,"exe_time":0},{"did":"519878831","siid":2,"piid":4,"value":4,"code":0,"updateTime":1646495513,"exe_time":0},{"did":"519878831","siid":8,"piid":11,"value":0,"code":0,"updateTime":1646495513,"exe_time":0},{"did":"519878831","siid":8,"piid":1,"value":true,"code":0,"updateTime":1646495513,"exe_time":0},{"did":"519878831","siid":8,"piid":20,"value":false,"code":0,"updateTime":1646495513,"exe_time":0},{"did":"519878831","siid":8,"piid":19,"value":0,"code":0,"updateTime":1646535852,"exe_time":0},{"did":"519878831","siid":8,"piid":7,"value":0,"code":0,"updateTime":1646535852,"exe_time":0},{"did":"519878831","siid":2,"piid":2,"value":0,"code":0,"updateTime":1646495513,"exe_time":0},{"did":"519878831","siid":8,"piid":1,"value":true,"code":0,"updateTime":1646495513,"exe_time":0},{"did":"519878831","siid":14,"piid":1,"value":0,"code":0,"updateTime":1646535913,"exe_time":0},{"did":"519878831","siid":13,"piid":8,"value":0,"code":0,"updateTime":1646495514,"exe_time":0},{"did":"519878831","siid":8,"piid":30,"value":"file not exist !!!","code":0,"updateTime":1646554530,"exe_time":0},{"did":"519878831","siid":8,"piid":26,"value":"girl_en","code":0,"updateTime":1646554530,"exe_time":0},{"did":"519878831","siid":10,"piid":1,"value":93,"code":0,"updateTime":1646506753,"exe_time":0},{"did":"519878831","siid":11,"piid":2,"value":96,"code":0,"updateTime":1646506753,"exe_time":0},{"did":"519878831","siid":12,"piid":2,"value":94,"code":0,"updateTime":1646506753,"exe_time":0},{"did":"519878831","siid":15,"piid":2,"value":66,"code":0,"updateTime":1646506753,"exe_time":0},{"did":"519878831","siid":1,"piid":4,"value":"0.9.6_2365","code":0,"exe_time":0},{"did":"519878831","siid":13,"piid":7,"value":false,"code":0,"updateTime":1646495514,"exe_time":0},{"did":"519878831","siid":8,"piid":29,"value":102,"code":0,"updateTime":1646495514,"exe_time":0}]}
2022-03-06 05:15:31 -> {"params":{"siid":13,"aiid":2,"did":"519878831","in":["{\"StartPos\":0,\"PathID\":0,\"UID\":\"580715\"}"]}} /miotspec/action
2022-03-06 05:15:31 <- {"code":0,"message":"","result":{"did":"519878831","miid":0,"siid":13,"aiid":2,"code":0,"exe_time":0,"withLatency":0}}
2022-03-06 05:15:31 -> {"params":{"siid":13,"aiid":2,"did":"519878831","in":["{\"StartPos\":0,\"PathID\":0,\"UID\":\"580715\"}"]}} /miotspec/action
2022-03-06 05:15:31 <- {"code":0,"message":"","result":{"did":"519878831","miid":0,"siid":13,"aiid":2,"code":0,"exe_time":0,"withLatency":0}}
2022-03-06 05:15:36 -> {"params":{"siid":13,"aiid":2,"did":"519878831","in":["{\"StartPos\":0,\"PathID\":0,\"UID\":\"580715\"}"]}} /miotspec/action
2022-03-06 05:15:36 <- {"code":0,"message":"","result":{"did":"519878831","miid":0,"siid":13,"aiid":2,"code":0,"exe_time":0,"withLatency":0}}
2022-03-06 05:15:42 -> {"params":{"siid":13,"aiid":2,"did":"519878831","in":["{\"StartPos\":0,\"PathID\":0,\"UID\":\"580715\"}"]}} /miotspec/action
2022-03-06 05:15:42 <- {"code":0,"message":"","result":{"did":"519878831","miid":0,"siid":13,"aiid":2,"code":0,"exe_time":0,"withLatency":0}}
2022-03-06 05:15:42 <- {"code":0,"message":"","result":{"did":"519878831","miid":0,"siid":14,"aiid":1,"code":0,"exe_time":0,"withLatency":0}}
2022-03-06 05:15:47 -> {"params":{"siid":13,"aiid":2,"did":"519878831","in":["{\"StartPos\":0,\"PathID\":0,\"UID\":\"580715\"}"]}} /miotspec/action
2022-03-06 05:15:47 <- {"code":0,"message":"","result":{"did":"519878831","miid":0,"siid":13,"aiid":2,"code":0,"exe_time":0,"withLatency":0}}
2022-03-06 05:15:56 -> {"params":{"siid":13,"aiid":2,"did":"519878831","in":["{\"StartPos\":0,\"PathID\":0,\"UID\":\"580715\"}"]}} /miotspec/action
2022-03-06 05:15:56 <- {"code":0,"message":"","result":{"did":"519878831","miid":0,"siid":13,"aiid":2,"code":0,"exe_time":0,"withLatency":0}}
2022-03-06 05:16:01 -> {"params":{"did":"519878831","siid":3,"aiid":1}} /miotspec/action
2022-03-06 05:16:01 <- {"code":0,"message":"","result":{"did":"519878831","miid":0,"siid":3,"aiid":1,"code":0,"exe_time":0,"withLatency":0}}
2022-03-06 05:16:01 -> {"params":{"siid":13,"aiid":2,"did":"519878831","in":["{\"StartPos\":0,\"PathID\":0,\"UID\":\"580715\"}"]}} /miotspec/action
2022-03-06 05:16:01 <- {"code":0,"message":"","result":{"did":"519878831","miid":0,"siid":13,"aiid":2,"code":0,"exe_time":0,"withLatency":0}}
2022-03-06 05:16:07 -> {"params":{"siid":13,"aiid":2,"did":"519878831","in":["{\"StartPos\":0,\"PathID\":0,\"UID\":\"580715\"}"]}} /miotspec/action
2022-03-06 05:16:07 <- {"code":0,"message":"","result":{"did":"519878831","miid":0,"siid":13,"aiid":2,"code":0,"exe_time":0,"withLatency":0}}
sadanro100 commented 2 years ago

Tried it once more:

2022-03-06 05:20:57 -> {"params":[{"did":"519878831","siid":2,"piid":2}],"datasource":1} /miotspec/prop/get
2022-03-06 05:20:57 <- {"code":0,"message":"","result":[{"did":"519878831","siid":2,"piid":2,"value":0,"code":0,"updateTime":1646495513,"exe_time":0}]}
2022-03-06 05:20:58 -> {"params":[{"did":"519878831","siid":2,"piid":1},{"did":"519878831","siid":3,"piid":1},{"did":"519878831","siid":3,"piid":2},{"did":"519878831","siid":2,"piid":4},{"did":"519878831","siid":8,"piid":11},{"did":"519878831","siid":8,"piid":1},{"did":"519878831","siid":8,"piid":20},{"did":"519878831","siid":8,"piid":19},{"did":"519878831","siid":8,"piid":7},{"did":"519878831","siid":2,"piid":2},{"did":"519878831","siid":8,"piid":1},{"did":"519878831","siid":14,"piid":1},{"did":"519878831","siid":13,"piid":8},{"did":"519878831","siid":8,"piid":30},{"did":"519878831","siid":8,"piid":26},{"did":"519878831","siid":10,"piid":1},{"did":"519878831","siid":11,"piid":2},{"did":"519878831","siid":12,"piid":2},{"did":"519878831","siid":15,"piid":2},{"did":"519878831","siid":1,"piid":4},{"did":"519878831","siid":13,"piid":7},{"did":"519878831","siid":8,"piid":29}],"datasource":1} /miotspec/prop/get
2022-03-06 05:20:58 <- {"code":0,"message":"","result":[{"did":"519878831","siid":2,"piid":1,"value":9,"code":0,"updateTime":1646554604,"exe_time":0},{"did":"519878831","siid":3,"piid":1,"value":100,"code":0,"updateTime":1646509434,"exe_time":0},{"did":"519878831","siid":3,"piid":2,"value":1,"code":0,"updateTime":1646554857,"exe_time":0},{"did":"519878831","siid":2,"piid":4,"value":4,"code":0,"updateTime":1646495513,"exe_time":0},{"did":"519878831","siid":8,"piid":11,"value":0,"code":0,"updateTime":1646495513,"exe_time":0},{"did":"519878831","siid":8,"piid":1,"value":true,"code":0,"updateTime":1646495513,"exe_time":0},{"did":"519878831","siid":8,"piid":20,"value":false,"code":0,"updateTime":1646495513,"exe_time":0},{"did":"519878831","siid":8,"piid":19,"value":0,"code":0,"updateTime":1646535852,"exe_time":0},{"did":"519878831","siid":8,"piid":7,"value":0,"code":0,"updateTime":1646535852,"exe_time":0},{"did":"519878831","siid":2,"piid":2,"value":0,"code":0,"updateTime":1646495513,"exe_time":0},{"did":"519878831","siid":8,"piid":1,"value":true,"code":0,"updateTime":1646495513,"exe_time":0},{"did":"519878831","siid":14,"piid":1,"value":0,"code":0,"updateTime":1646554603,"exe_time":0},{"did":"519878831","siid":13,"piid":8,"value":0,"code":0,"updateTime":1646495514,"exe_time":0},{"did":"519878831","siid":8,"piid":30,"value":"file not exist !!!","code":0,"updateTime":1646554857,"exe_time":0},{"did":"519878831","siid":8,"piid":26,"value":"girl_en","code":0,"updateTime":1646554857,"exe_time":0},{"did":"519878831","siid":10,"piid":1,"value":93,"code":0,"updateTime":1646506753,"exe_time":0},{"did":"519878831","siid":11,"piid":2,"value":96,"code":0,"updateTime":1646506753,"exe_time":0},{"did":"519878831","siid":12,"piid":2,"value":94,"code":0,"updateTime":1646506753,"exe_time":0},{"did":"519878831","siid":15,"piid":2,"value":66,"code":0,"updateTime":1646506753,"exe_time":0},{"did":"519878831","siid":1,"piid":4,"value":"0.9.6_2365","code":0,"exe_time":0},{"did":"519878831","siid":13,"piid":7,"value":false,"code":0,"updateTime":1646495514,"exe_time":0},{"did":"519878831","siid":8,"piid":29,"value":102,"code":0,"updateTime":1646495514,"exe_time":0}]}
2022-03-06 05:20:59 -> {"params":{"siid":13,"aiid":2,"did":"519878831","in":["{\"StartPos\":0,\"PathID\":0,\"UID\":\"580715\"}"]}} /miotspec/action
2022-03-06 05:20:59 <- {"code":0,"message":"","result":{"did":"519878831","miid":0,"siid":13,"aiid":2,"code":0,"exe_time":0,"withLatency":0}}
2022-03-06 05:21:04 -> {"params":{"siid":13,"aiid":2,"did":"519878831","in":["{\"StartPos\":0,\"PathID\":0,\"UID\":\"580715\"}"]}} /miotspec/action
2022-03-06 05:21:04 <- {"code":0,"message":"","result":{"did":"519878831","miid":0,"siid":13,"aiid":2,"code":0,"exe_time":0,"withLatency":0}}
2022-03-06 05:21:08 -> {"params":{"siid":13,"aiid":2,"did":"519878831","in":["{\"StartPos\":0,\"PathID\":0,\"UID\":\"580715\"}"]}} /miotspec/action
2022-03-06 05:21:08 <- {"code":0,"message":"","result":{"did":"519878831","miid":0,"siid":13,"aiid":2,"code":0,"exe_time":0,"withLatency":0}}
2022-03-06 05:21:09 -> {"params":{"did":"519878831","siid":14,"aiid":1,"in":[2,"{\"mapId\":1645447746,\"segmentId\":[4]}"]}} /miotspec/action
2022-03-06 05:21:09 <- {"code":0,"message":"","result":{"did":"519878831","miid":0,"siid":14,"aiid":1,"code":0,"exe_time":0,"withLatency":0}}
2022-03-06 05:21:13 -> {"params":{"siid":13,"aiid":2,"did":"519878831","in":["{\"StartPos\":0,\"PathID\":0,\"UID\":\"580715\"}"]}} /miotspec/action
2022-03-06 05:21:13 <- {"code":0,"message":"","result":{"did":"519878831","miid":0,"siid":13,"aiid":2,"code":0,"exe_time":0,"withLatency":0}}
2022-03-06 05:21:18 -> {"params":{"siid":13,"aiid":2,"did":"519878831","in":["{\"StartPos\":0,\"PathID\":0,\"UID\":\"580715\"}"]}} /miotspec/action
2022-03-06 05:21:18 <- {"code":0,"message":"","result":{"did":"519878831","miid":0,"siid":13,"aiid":2,"code":0,"exe_time":0,"withLatency":0}}
2022-03-06 05:21:23 -> {"params":{"siid":13,"aiid":2,"did":"519878831","in":["{\"StartPos\":0,\"PathID\":0,\"UID\":\"580715\"}"]}} /miotspec/action
2022-03-06 05:21:23 <- {"code":0,"message":"","result":{"did":"519878831","miid":0,"siid":13,"aiid":2,"code":0,"exe_time":0,"withLatency":0}}
2022-03-06 05:21:24 -> {"params":{"did":"519878831","siid":3,"aiid":1}} /miotspec/action
2022-03-06 05:21:24 <- {"code":0,"message":"","result":{"did":"519878831","miid":0,"siid":3,"aiid":1,"code":0,"exe_time":0,"withLatency":0}}
2022-03-06 05:21:27 -> {"params":{"siid":13,"aiid":2,"did":"519878831","in":["{\"StartPos\":0,\"PathID\":0,\"UID\":\"580715\"}"]}} /miotspec/action
2022-03-06 05:21:27 <- {"code":0,"message":"","result":{"did":"519878831","miid":0,"siid":13,"aiid":2,"code":0,"exe_time":0,"withLatency":0}}
sadanro100 commented 2 years ago

In

2022-03-06 05:21:09 -> {"params":{"did":"519878831","siid":14,"aiid":1,"in":[2,"{\"mapId\":1645447746,\"segmentId\":[4]}"]}} /miotspec/action

it looks like the map id remains the same

merdok commented 2 years ago

You can try to manually send the command to the device and try to modify it as testing using the cli commands. For that you can just use the miot send cli method in the operating system. Your command would look something like this: miot send <ip> <token> action '[{"did":"519878831","siid":14,"aiid":1,"in":[{"piid":1,"value":2},{"piid":2,"value":"{\"mapId\":1645447746,\"segmentId\":[4]}"}]}]' or miot send <ip> <token> action '[{"did":"519878831","siid":14,"aiid":1,"in":[2,"{\"mapId\":1645447746,\"segmentId\":[4]}"]}]'

sadanro100 commented 2 years ago

Timeout issue perhaps? In order to use the Xiaomi app instead of the Roidmi app, I had to choose the CN region in the Xiaomi app, otherwise my robot wouldn't show up to be paired up. I noticed it's much slower in that server, loading maps, issuing commands and etc

miot send 192.168.15.145 token action '[{"did":"519878831","siid":14,"aiid":1,"in":[{"piid":1,"value":2},{"piid":2,"value":"{\"mapId\":1645447746,\"segmentId\":[4]}"}]}]'
 INFO  Connecting to device at 192.168.15.145
 INFO  Device found! Sending command: action [{"did":"519878831","siid":14,"aiid":1,"in":[{"piid":1,"value":2},{"piid":2,"value":"{\"mapId\":1645447746,\"segmentId\":[4]}"}]}]
(Protocol) Call 192.168.15.145: action - [{"did":"519878831","siid":14,"aiid":1,"in":[{"piid":1,"value":2},{"piid":2,"value":"{\"mapId\":1645447746,\"segmentId\":[4]}"}]}] - {"retries":1,"timeout":5000}
 ERROR  user ack timeout
pi@raspberrypi:/var/lib/homebridge/accessories $ miot send 192.168.15.145 token action '[{"did":"519878831","siid":14,"aiid":1,"in":[2,"{\"mapId\":1645447746,\"segmentId\":[4]}"]}]'
 INFO  Connecting to device at 192.168.15.145
 INFO  Device found! Sending command: action [{"did":"519878831","siid":14,"aiid":1,"in":[2,"{\"mapId\":1645447746,\"segmentId\":[4]}"]}]
(Protocol) Call 192.168.15.145: action - [{"did":"519878831","siid":14,"aiid":1,"in":[2,"{\"mapId\":1645447746,\"segmentId\":[4]}"]}] - {"retries":1,"timeout":5000}
 ERROR  user ack timeout
merdok commented 2 years ago

Try like this: miot send <ip> <token> action '{"did":"519878831","siid":14,"aiid":1,"in":[{"piid":1,"value":2},{"piid":2,"value":"{\"mapId\":1645447746,\"segmentId\":[4]}"}]}' or miot send <ip> <token> action '{"did":"519878831","siid":14,"aiid":1,"in":[2,"{\"mapId\":1645447746,\"segmentId\":[4]}"]}'

sadanro100 commented 2 years ago

Tried the first one and that actually worked!!!

What was the deal so that I can replicate it with other rooms?

What would it look like in the config.json format?

merdok commented 2 years ago

That is strange because i used the command from above from the config.json example so it should also actually work... Can you post your config.json entry?

For other rooms you have to find out the ids using the modified xiaomi home app and create entries in the config.json for every room!

sadanro100 commented 2 years ago

I see... what I mean is, I am not sure how to write this (which worked from the terminal) in the config.json:

miot send <ip> <token> action '{"did":"519878831","siid":14,"aiid":1,"in":[{"piid":1,"value":2},{"piid":2,"value":"{\"mapId\":1645447746,\"segmentId\":[4]}"}]}'

This is what I tried (kinda knowing it wouldn't work):

                    {
                            "action": "14.1",
                            "name": "Banheiro",
                            "did": "519878831",
                            "siid": 14,
                            "aiid": 1,
                            "in": [
                                {
                                    "piid": 1,
                                    "value": 2
                                },
                                {
                                    "piid": 2,
                                    "value": "{\"mapId\":1645447746,\"segmentId\":[4]}"
                                }
                            ]
                        }

[3/6/2022, 3:53:13 PM] [miot] [Aspirador] Error: Error while executing action sweep:start-sweep with params ! Invalid response from device. Response: {"did":"519878831","miid":0,"siid":14,"aiid":1,"code":-704220025,"exe_time":0,"withLatency":0}

As of the second part, yes I understand I'll have to repeat the process for other rooms, I was asking what you'd changed between https://github.com/merdok/homebridge-miot/issues/236#issuecomment-1059918772 and https://github.com/merdok/homebridge-miot/issues/236#issuecomment-1059930173 but it looks like you got rid of the "[]" in the beginning and end.

It seems like I'm one step from it, just having a hard time figuring out how to write the json using the structure that worked with miot send

merdok commented 2 years ago

I gave you an example above on how to write the action, not sure why you try to change format. Also you have an example in the README. There are just 3 possible properties: action, name and params. You need to make sure that there are no typos since the miot protocol is not very graceful😅

sadanro100 commented 2 years ago

The first thing I tried was probably correct, but still didn't work:

[3/7/2022, 11:09:45 AM] [miot] [Aspirador] Send action! RAW: {"did":"519878831","siid":14,"aiid":1,"in":[{"piid":1,"value":2},{"piid":2,"value":"{\"mapId\":1645447746,\"segmentId\":[4]}"}]}

which is exactly the same as you suggested in https://github.com/merdok/homebridge-miot/issues/236#issuecomment-1059930173 and that had worked fine from the terminal.

It seems like sending the command from the terminal works, but not from the plugin.

Trust me, I made several attempts before asking for help and trying things that didn't make sense. You told me to show you what my json looked like at the moment and that was it. But that's fine. Thanks anyway for your time.

merdok commented 2 years ago

You can try to remove the quote escapes and see if that helps like this:

{
    "action": "14.1",
    "name": "Banheiro",
    "params": [
        2,
        '{"mapId":1645447746,"segmentId":[4]}'
    ]
}

Other then that i am not sure exactly why it would not work, can you also please paste your full config.json so i just have an idea what you have inside there?

sadanro100 commented 2 years ago

This is what I've tried so far:

(Your First suggestion)

{
    "action": "14.1",
    "name": "Banheiro",
    "params": [
        2,
        "{\"mapId\":1645447746,\"segmentId\":[4]}"
    ]
}
[3/7/2022, 7:26:06 PM] [miot] [Aspirador] Send action! RAW: {"did":"519878831","siid":14,"aiid":1,"in":[{"piid":1,"value":2},{"piid":2,"value":"{\"mapId\":1645447746,\"segmentId\":[4]}"}]}
[3/7/2022, 7:26:06 PM] [miot] [Aspirador] (MiCloud) Encrypted request https://api.io.mi.com/app/miotspec/action - {"params":{"did":"519878831","siid":14,"aiid":1,"in":[{"piid":1,"value":2},{"piid":2,"value":"{\"mapId\":1645447746,\"segmentId\":[4]}"}]}}
[3/7/2022, 7:26:07 PM] [miot] [Aspirador] Error: Error while executing action sweep:start-sweep with params 2,{"mapId":1645447746,"segmentId":[4]}! Invalid response from device. Response: {"did":"519878831","miid":0,"siid":14,"aiid":1,"code":-704220035,"exe_time":0,"withLatency":0}

(Your latest suggestion)

{
    "action": "14.1",
    "name": "Banheiro",
    "params": [
        2,
        '{"mapId":1645447746,"segmentId":[4]}'
    ]
}

Config Syntax Error Config contains invalid JSON (homebridge doesn't like it)

(inverted quotes)

{
    "action": "14.1",
    "name": "Banheiro",
    "params": [
        2,
        "{'mapId': 1645447746, 'segmentId': [4]}"
    ]
}
[3/7/2022, 7:32:37 PM] [miot] [Aspirador] Send action! RAW: {"did":"519878831","siid":14,"aiid":1,"in":[{"piid":1,"value":2},{"piid":2,"value":"{'mapId': 1645447746, 'segmentId': [4]}"}]}
[3/7/2022, 7:32:37 PM] [miot] [Aspirador] (MiCloud) Encrypted request https://api.io.mi.com/app/miotspec/action - {"params":{"did":"519878831","siid":14,"aiid":1,"in":[{"piid":1,"value":2},{"piid":2,"value":"{'mapId': 1645447746, 'segmentId': [4]}"}]}}
[3/7/2022, 7:32:38 PM] [miot] [Aspirador] Error: Error while executing action sweep:start-sweep with params 2,{'mapId': 1645447746, 'segmentId': [4]}! Invalid response from device. Response: {"did":"519878831","miid":0,"siid":14,"aiid":1,"code":-704220035,"exe_time":0,"withLatency":0}

(Just an attempt)

{
    "action": "14.1",
    "name": "Banheiro",
    "params": [{
            "piid": 1,
            "value": 2
        },
        {
            "piid": 2,
            "value": "{\"mapId\":1645447746,\"segmentId\":[4]}"
        }
    ]
}
[3/7/2022, 7:56:48 PM] [miot] [Aspirador] Send action! RAW: {"did":"519878831","siid":14,"aiid":1,"in":[{"piid":1,"value":2},{"piid":2,"value":"{\"mapId\":1645447746,\"segmentId\":[4]}"}]}
[3/7/2022, 7:56:48 PM] [miot] [Aspirador] (MiCloud) Encrypted request https://api.io.mi.com/app/miotspec/action - {"params":{"did":"519878831","siid":14,"aiid":1,"in":[{"piid":1,"value":2},{"piid":2,"value":"{\"mapId\":1645447746,\"segmentId\":[4]}"}]}}
[3/7/2022, 7:56:49 PM] [miot] [Aspirador] Error: Error while executing action sweep:start-sweep with params [object Object],[object Object]! Invalid response from device. Response: {"did":"519878831","miid":0,"siid":14,"aiid":1,"code":-704220035,"exe_time":0,"withLatency":0}

==================

This is when I try it running miot command from the terminal (only thing that's worked so far)

pi@raspberrypi:~ $ miot send <ip> <token> action '{"did":"519878831","siid":14,"aiid":1,"in":[{"piid":1,"value":2},{"piid":2,"value":"{\"mapId\":1645447746,\"segmentId\":[4]}"}]}'
 INFO  Connecting to device at 192.168.15.145
 INFO  Device found! Sending command: action {"did":"519878831","siid":14,"aiid":1,"in":[{"piid":1,"value":2},{"piid":2,"value":"{\"mapId\":1645447746,\"segmentId\":[4]}"}]}
(Protocol) Call 192.168.15.145: action - {"did":"519878831","siid":14,"aiid":1,"in":[{"piid":1,"value":2},{"piid":2,"value":"{\"mapId\":1645447746,\"segmentId\":[4]}"}]} - {"retries":1,"timeout":5000}
 SUCCESS  Response from device -> {"code":0}

Interestingly, the first and the last examples generate an exactly identical RAW payload to the one I get when I successfully use the miot command in terminal.

I might try to make a switch that runs the command directly and see if that works, I can't think of anything else.

sadanro100 commented 2 years ago

I used homebridge-cmdtriggerswitch to trigger:

miot send <ip> <token> action '{"did":"519878831","siid":14,"aiid":1,"in":[{"piid":1,"value":2},{"piid":2,"value":"{\"mapId\":1645447746,\"segmentId\":[4]}"}]}'

and that worked 🤷‍♂️, which is fine for me.

If you're curious about what happened and want me to debbug more, just let me know.

Thank you very much for helping me out!

merdok commented 2 years ago

I am wondering why do you use micloud for your device? The command which you send from your console is sent straight to the device where it seems that in homebridge you are using micloud. That normally should not be a problem but I am curious if that is the issue for you. Can you just remove the micloud credentials from your config.json so that the plugin will use a direct connection.

sadanro100 commented 2 years ago

[3/8/2022, 2:14:03 PM] [miot] [Aspirador] Device requires MiCloud! Trying to connect! [3/8/2022, 2:14:03 PM] [miot] [Aspirador] Error: The device requires a MiCloud connection! In order to control the device please specify a MiCloud username and password! Canceling setup! [3/8/2022, 2:14:03 PM] [miot] [Aspirador] The specified MiCloud login credentials might be incorrect or the account does not exist... [3/8/2022, 2:14:03 PM] [miot] [Aspirador] Setup failed! [3/8/2022, 2:14:03 PM] [miot] [Aspirador] Error: MiCloud is required but login to MiCloud failed!

merdok commented 2 years ago

Oh, the device is then wrongly marked as MiCloud required. That is not the case since you confirmed that the command miot send did work in the terminal and it sends it directly to the device. I will adjust the device metadata so that MiCloud will not be required in the future.

In the meantime you can try it manually and change true to false here: https://github.com/merdok/homebridge-miot/blob/main/lib/modules/robotcleaner/devices/roidmi.vacuum.v60.js#L28

Afterwards you can try to set the room cleaning in the config and check it out without micloud.

sadanro100 commented 2 years ago

That actually worked. The newly created switch responded fine for room cleaning. One catch though, upon disabling the switch, the robot starts the room clean again, instead of going back to recharge.

merdok commented 2 years ago

This is a stateless switch, meaning it has not state. So every time you press it, the same action will be executed. This is by the design like that since there is no way to know what custom action a user did create. If you want to have an action to send the robot cleaner back to the dock, then you have to create a new action for that.

The interesting thing is now which makes me wonder why it is not working over MiCloud. That should not matter if you use the loca connection or cloud connection. Can you post the debug log from the local command so i can compare the raw requests?

Anyway i will mark the device as not MiCloud required in the next update!

sadanro100 commented 2 years ago

As requested, here's the payload

[3/8/2022, 4:48:00 PM] [miot] [Aspirador] Send action! RAW: {"did":"519878831","siid":14,"aiid":1,"in":[{"piid":1,"value":2},{"piid":2,"value":"{\"mapId\":1645447746,\"segmentId\":[4]}"}]}
[3/8/2022, 4:48:00 PM] [miot] [Aspirador] (Protocol) Call 192.168.15.145: action - {"did":"519878831","siid":14,"aiid":1,"in":[{"piid":1,"value":2},{"piid":2,"value":"{\"mapId\":1645447746,\"segmentId\":[4]}"}]} - {}
[3/8/2022, 4:48:00 PM] [miot] [Aspirador] (Protocol) Start handshake 192.168.15.145

Regarding the stateless switch, I get that, but shouldn't it switch itself back to off right away since it's stateless? That's how homebridge-cmdtriggerswitch works at least.

merdok commented 2 years ago

Ok, the device is now adjusted in version 1.0.6.

Thanks! Request looks the same... not sure what the problem is with MiCloud...

Yeah, the switch will turn itself off after you press it.

sadanro100 commented 2 years ago

My switch remained on, that's why I expected the robot to go back to base when I manually turned the switch off

merdok commented 2 years ago

I guess it was a hiccup or something. Happens...

sadanro100 commented 2 years ago

You're right, it did switch back off now. Thank you ever so much for putting your time into this project and for helping me out