merdok / homebridge-miot

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

miot/raw commands cli questions #364

Closed satrik closed 1 year ago

satrik commented 1 year ago

Hey,

I need the "miot send" command to setup room cleaning for my needs. As here described, I think the command would look something like this

miot send $IP -t $TOKEN action '{"did":"$MY_ID","siid":4,"aiid":1,"in":["{\"selects\":[[1,1,1,1,1],[2,1,1,1,1]]}",{\"piid\":1,\"value\":18}]'

Is this correct? Are there any docs available how the raw commands are formatted?

And another question to the room values. The fourth value indicates the mopping mode, but what do I need to send if I only want sweeping for a specific room and no mopping? If I read it right for my robot there are only 3 values and all are for sweeping. From the naming, I would assume vacuum:start-room-sweep is the right one, but than I don't know how to "mix" sweeping/mopping with 1 command.

Thanks and greetings satrik

merdok commented 1 year ago

The commands looks fine and should work that way.

You more or less have to find out the parameters by experimenting. If you have an Android device then you can use the modified mi home app which can capture the commands send to the device, so by sending a specific command you can have a look what changed.

satrik commented 1 year ago

I don't have an android but I think it could work with an Emulator on Mac. Will try it and write my findings here

satrik commented 1 year ago

So here are the first logs, but they are confusing me just more than they help right now 😂

Room 3 - Sweeping and mopping Room 4 - Only sweeping

2022-10-23 13:42:57 -> {"id":5942,"method":"action","params":{"did":"1234567890","siid":4,"aiid":1,"in":[{"piid":1,"value":18},{"piid":10,"value":"{\"selects\":[[4,1,1,1,1],[3,1,1,1,1]]}"}]}}

Without room selection, just start cleaning with the custom settings for each room via the App. Rooms 1,2,3 Sweeping and mopping, the others only sweeping. Maybe with customClean the last number indicates the mode and it uses map:update-map to send the action 🤔

2022-10-23 13:31:54 -> {"id":9687,"method":"action","params":{"did":"1234567890","siid":6,"aiid":2,"in":[{"piid":4,"value":"{\"customeClean\":[[1,1,2,1,2],[2,1,2,1,2],[3,1,2,1,2],[4,1,2,1,0],[5,1,2,1,0],[6,1,2,1,0]]}"}]}}

Will make some more tests later with more different settings. I hope it gets clearer than...

satrik commented 1 year ago

Omg what a pain to find the sense in the logs, but I think I'm almost done

Set the preferred settings for each room without starting to clean, is done with this call. While testing I had the behavior that the settings for some rooms were resettet, so I assume it is important to always send the settings for all rooms.

2022-10-23 17:04:14 -> {"id":5629,"method":"action","params":{"did":"1234567890","siid":6,"aiid":2,"in":[{"piid":4,"value":"{\"customeClean\":[[1,1,2,1,2],[2,1,2,1,2],[3,1,2,1,2],[4,1,2,1,0],[5,1,2,1,0],[6,1,2,1,0]]}"}]}}

The numbers [1,1,2,1,2] mean

  1. Room ID
  2. Vacuum power
  1. Mopping mode (not the same as in "vacuum-extend:mop-mode" !)
  1. Cleaning Times 1 or 2
  2. Mode

Afterwards the room cleanup can be started with this call

2022-10-23 17:02:17 -> {"id":2060,"method":"action","params":{"did":"1234567890","siid":4,"aiid":1,"in":[{"piid":1,"value":18},{"piid":10,"value":"{\"selects\":[[4,1,1,1,1],[3,1,1,1,1]]}"}]}}

So in the actual "start clean" call are no more settings which can be adjusted. It's just Room ID followed by ,1,1,1,1.

To start a complete clean with the custom settings without specifying rooms, this is the right call

2022-10-23 17:06:13 -> {"id":8542,"method":"action","params":{"did":"1234567890","siid":2,"aiid":1,"in":[]}}

I'm sure I'll do more tests over the next few days and if there are new findings, I will write them again here

merdok commented 1 year ago

That looks like some good info and findings. Thanks for that! Maybe we can update the guide?

satrik commented 1 year ago

@merdok did a lot of tests in the last days and everything works rock solid with the commands from above. Also changing single room settings works (not sure what I did wrong while my first tests 🤷🏼‍♂️). Have also tested the action buttons (even if I don't use them) but so I can update the guide today afternoon. Just one question, if I followed the code correctly back, then the default button for the robot calls vacuum:start-sweep, right?

merdok commented 1 year ago

Great! Thanks for the update! Yes, this action is called by the default start/stop button.

satrik commented 1 year ago

Created the PR

satrik commented 1 year ago

As all of my questions are answered, I will close this issue :) Thanks for your help!