tobiaslins / homebridge-mi-robot-vacuum

🤖 A homebridge plugin to control your xiaomi mi robot vacuum
MIT License
10 stars 0 forks source link

The hex data is the same every time? #1

Open biogerm opened 7 years ago

biogerm commented 7 years ago

Hi,

I have been trying to reproduce the procedure you have suggested on my Mi power outlet. I don't own a vacuum robot, so what I found from the power outlet are:

  1. the hex payload is different every time...
  2. most of time the packet is sent from a server outside my LAN...
  3. packages are even not with equal size
  4. payload sent from my phone directly to the device is bigger than the package from cloud

Does the vacuum robot's package appear in the same way? Can you please describe a little about the package you captured? Maybe it can give me a little help to find out a way to home bridge the outlets. Thanks!

BR Ryan

tobiaslins commented 7 years ago

Hi,

The hex payload is the same every time (at least for the vacuum) Be sure that you just selected the "Data" field within Wireshark. If you don't select it, the payload will be different every time! https://github.com/jghaanstra/com.robot.xiaomi-mi/raw/master/assets/readme/wireshark_data.png?raw=true

biogerm commented 7 years ago

Sure it's the data. I guess the vacuum is implemented differently than the power plug then... For me it's more like it's encrypted by an algorithm.

aholstenson commented 7 years ago

The actual data sent over the network uses encryption based on a token associated with a device. For the Mi Robot Vacuum the token can only be fetched before it is configured to with the correct WiFi settings.

If you are interested in the structure of the packets I found this documentation to be good: https://github.com/OpenMiHome/mihome-binary-protocol

I've been working on adding support for the Mi Robot Vacuum in my miio library (not a Homebridge plugin) and as long as you have the right token communicating with the vacuum should be quite easy. The same is true for many other types of Mi Home devices.

biogerm commented 7 years ago

@aholstenson your repo seems very well documented :) what is it used for? Controlling Mi devices from browser? btw where can you buy Mi devices in Sweden? (where i am living too)

aholstenson commented 7 years ago

The library is just an easy to use API for as many devices as I can support. There is no actual control interface, but it could be used for example in this library to control the vacuum, or to build a web interface.

I usually buy my devices from Aliexpress, it takes a few weeks for stuff to get to Sweden but it works.