ttimpe / homebridge-midea

This is a homebridge plugin for Midea AC units.
https://www.npmjs.com/package/homebridge-midea
Other
51 stars 10 forks source link

Rotenso devices #24

Open cojoj opened 4 years ago

cojoj commented 4 years ago

Hey, first of all, a big round of 👏 for creating this plugin.

I'm based in Poland and I'm using Rotenso Split AC. They're also using this WiFi module from Midea and are using NetHome Plus app for communication from mobile devices. I was able to integrate this plugin with my Homebridge instance and it seems to work (more or less 😅). I've spotted a couple of issues here and there and I'm not really sure whether they're related to the type of devices I have or they're simply some bugs, WIPs or features. Anyway, I'll list them below and maybe we can discuss it in the issue?

  1. Would be great to have the possibility to set the device's temperature range. I know my Rotenso AC goes from 17℃ to 30℃. I don't see a reason to be able to select other values. I believe I've seen this being already mentioned in some other issue, but I can't recollect in which.
  2. As already mentioned in #11 - when I do something the temperature unit is going crazy and changing it works only for a moment.
  3. Selecting fan speed using a slider is also not the best option since devices actually use enum for this with a couple of values + auto mode. I think supporting this would improve the overall usability of this HomeKit component. I've noticed that Characteristic.RotationSpeed only supports values from 0 to 100, so no enum here. I've also noticed there's a Min Step and maybe it's possible to modify this value to jump every 25 instead of the default of 1.
  4. supportedSwingMode doesn't work with my devices at all and I suspect this might be related to the device's manufacturer, but I'd love to see this working.
  5. I was wondering whether it's possible to react to the settings from different sources? For example, when I set something on my remote it's not being reflected in HomeKit. The same applies when I do something in NetHome Plus app. On the other hand, when I modify something using HomeKit I can see this in NetHome Plus just fine. I believe this would be related to polling their API and adjusting UI to reflect changes. I have no idea whether this is possible.

I know this is a lot to digest and I'm not here to throw least expected:

Can you implement this, thanks.

But rather to help out as much as possible. I'm an iOS developer (I don't have JS expertise at all), so I can help out with reverse engineering network traffic, checking the iOS SDK or do some other things as well. Also, I'm willing to try and contribute to this repo, but I'd need some guidance in understanding what's happening.

ttimpe commented 4 years ago

Thank you for the kind words. A lot of things can definitely be improved in the plugin. The number one problem right now is the lack of any official documentation.

I am using the following existing implementations to find out how the API actually works:

https://github.com/TA2k/ioBroker.midea https://github.com/NeoAcheron/midea-ac-py https://github.com/yitsushi/midea-air-condition https://github.com/andersonshatch/midea-ac-py https://github.com/barban-dev/midea_inventor_dehumidifier

Using these I have developed some sense of how the API actually works, at least for some devices. Some settings like the Fahrenheit/Celsius switch are single-bit values inside the byte-array so they're quite a bit tricky to find, especially with all the encryption going on (I suspect the extra AES encryption is due to some sort of encryption restriction in China).

Other than that, I've also just been using BurpSuite to MITM the app requests and I've decompiled the Android app. Midea provides statically compiled SDK frameworks for both iOS and Android, however I have been unable to gain any new and useful information from them other than some new error codes.

I would suggest you start by going through some of those projects linked above (including their wiki pages) to gain an understanding of how the API might work and then start MITM'ing your apps requests and decrypting the data as shown in the Util class.

  1. I am already testing something like that as most of the properties of a service can be set in JS/TS using setProps, however I can still adjust the dial lower than 17 °C so I don't know what wrong there.

  2. This is related to a feature request regarding Fahrenheit support, you need to read the value from the ApplianceResponse and send it right back with your update

  3. Same as 1

  4. Good luck with the API :)

  5. This just depends on the polling interval you set in the config.json. You can set it to something like 0.5 to make it 30 seconds or even less.

I am currently still in the process of actually getting the code somewhat structured, go ahead and check out the development branch if you want to help :)