rytilahti / python-miio

Python library & console tool for controlling Xiaomi smart appliances
https://python-miio.readthedocs.io
GNU General Public License v3.0
3.64k stars 550 forks source link

Mijia vacuum v2 cleaner (mijia.vacuum.v2) #1325

Closed phodina closed 2 years ago

phodina commented 2 years ago

Before submitting a new request, use the search to see if there is an existing issue for the device.

Device information:

Use miiocli device --ip <ip address> --token <token>.

Additional context I've aquired the token by using a simple script on first connection https://github.com/phodina/python-miio/commit/6094b3d048ec30bc5e83e797e72e86eed7442d0b. I'll probably open another ticket for integration of that code.

Unfortunately I can't get any commands recognized as I get this response:

Error: {'code': -9999, 'message': 'undefined command'}

Is there some guide on porting new vacuum cleaner? Also is there a fuzzer that would test the commands? Or do I have to get the firmware and "check it from the inside"?

rytilahti commented 2 years ago

That device should already be supported by https://github.com/rytilahti/python-miio/blob/master/miio/integrations/vacuum/mijia/g1vacuum.py so, e.g., miiocli g1vacuum should work on your device. Is this not the case, or are you missing some features?

To your other questions, generally speaking, if the device is using the more recent miot protocol, a spec file defining the protocol can be found on the internet. https://github.com/rytilahti/python-miio/tree/master/devtools contains a script to download these files for a given model, but you can also just browse the website and download them manually.

There is no real "fuzzer" that would try all potential properties but creating such would be straightforward, it is just that there hasn't been need for that. The spec files are not always complete though, especially the parameters are not always documented correctly which leaves you to either reverse the firmware (or the mi home app plugin) or perform a traffic capture while playing around with the official implementation.

phodina commented 2 years ago

Thanks @rytilahti. The miiocli g1vaccum works and the device is recognized! Sorry for labeling it as a new device but the marketing names are just confusing and misleading.

I'm currently not missing functions/features as it's already implemented.

I've looked at the documentation and there is possibility to do OTA.

However, I'm just missing the firmware for the device as I didn't use the official app and just send simple UDP packet to get the token. I'd like to ask if there is also a site which lists the firmwares available to download or if I have to use the app and reverse engineer the URL where to obtain it.

My interest is to modify the firmware (add SSH, disable any data that it sends ...) without opening the device. I've checked and there is unfortunately no serial port attached. But that question is maybe more aimed at don't vacuum me

202202170945102639967946910723799

rytilahti commented 2 years ago

Glad it's working! The autodetection capabilities of the cli tool could be improved to show directly if the device is already supported, to make it clearer as the names are at times not as exact as the model information.

The ota update may or may not work with newer devices, but the dustcloud/dustbuilder/dontvacuum community is indeed the place for look for tips on rooting the vac :-) Alas, I don't think there exist a centralized place listing the firmware update files..

radek-kafka commented 2 years ago

Please is it possible to set/get current level of water to be used for cleaning. I could set it via cloud but when I would like to escape from cloud jail I could not set this property or do not know what raw command to be used for .. Any ideas or source of information please ?

rytilahti commented 2 years ago

Maybe this property?

{"iid":5,"type":"urn:miot-spec-v2:property:target-water-level:00000069:mijia-v1:1","description":"Target Water Level","format":"uint8","access":["read","write","notify"],"unit":"none","value-list":[{"value":1,"description":"Level1"},{"value":2,"description":"Level2"},{"value":3,"description":"Level3"}]}

It would be siid 2, piid 5, so you could fetch it's current value

miiocli g1vacuum get_property_by 2 5

and set it using

miiocli g1vacuum set_property_by 2 5 <wanted value> int

Anyway, please open an issue (or even better, create a PR to add support) instead of continuing the discussion on this already closed one.