georgezhao2010 / midea_ac_lan

Auto-configure and then control your Midea M-Smart devices (Air conditioner, Fan, Water heater, Washer, etc) via local area network.
MIT License
1.4k stars 231 forks source link

ESP8266/ESP32 Device #328

Open DjordjeMandic opened 1 year ago

DjordjeMandic commented 1 year ago

Device type and model (or SN)

samsung ar12txhqasineu - ar3500

The description of new feature

Have anyone tried to implement network adapter for indoor unit with ESP8266/ESP32? As far as i understand all communication is done in this integration. Hardware on unit itself is just serial bridge. Am i wrong?

georgezhao2010 commented 1 year ago

The data transmitted over Wi-Fi networks is actually an encapsulation of the UART protocol, which adds a protocol header and checksum to the UART protocol. If I understand correctly, the ESP only transmits UART protocol over the network, so this integration cannot be used for the ESP.

Device type and model (or SN)

samsung ar12txhqasineu - ar3500

The description of new feature

Have anyone tried to implement network adapter for indoor unit with ESP8266/ESP32? As far as i understand all communication is done in this integration. Hardware on unit itself is just serial bridge. Am i wrong?

The data transmitted over Wi-Fi networks is actually an encapsulation of the UART protocol, which adds a protocol header and checksum to the UART protocol. If I understand correctly, the ESP only transmits UART protocol over the network, so this integration cannot be used for the ESP.

DjordjeMandic commented 1 year ago

ESP8266/32 can ecapsulate whatever we like how we like. By iteself it does nothing. Thats just a microcontroller than can be programmed. If documentation of original protocol is available its possible to make firmware for cheap espressifs mcu to encapsulate uart protocol and expose it to network. I'm willing to experiment to develop open source dongle based on esp32 thats compatible with this integration (esp8266 is not reccomended for new designs in my opinion).

Is there any documentation for encapsulation of uart and protocol that this integration is using? I would like to try to implement it and maybe even port that then to ESPHome so that ESPHome device can expose itself on network as midea lan device. Adding support for this in esphome would really help thinkers and modders.

Could you add help needed label and etc to get more people intrested in this?

georgezhao2010 commented 1 year ago

ESP8266/32 can ecapsulate whatever we like how we like. By iteself it does nothing. Thats just a microcontroller than can be programmed. If documentation of original protocol is available its possible to make firmware for cheap espressifs mcu to encapsulate uart protocol and expose it to network. I'm willing to experiment to develop open source dongle based on esp32 thats compatible with this integration (esp8266 is not reccomended for new designs in my opinion).

Is there any documentation for encapsulation of uart and protocol that this integration is using? I would like to try to implement it and maybe even port that then to ESPHome so that ESPHome device can expose itself on network as midea lan device. Adding support for this in esphome would really help thinkers and modders.

Could you add help needed label and etc to get more people intrested in this?

The UART protocol used by Midea is known as the Appliance Control Protocol. Since it is developed by different departments or even third-party subsidiaries, there is no unified protocol. Each type of home appliance, and even each model, can be different. Midea has written a Lua script for each model in the app to parse the protocol. The Appliance Control Protocol is encapsulated and referred to as the M-Smart protocol, which is the protocol compatible with this integration.

So, If you want to develop a dongle, you only need to implement the encapsulation and decapsulation process between the M-Smart Protocol and the Appliance Protocol.

[App / integration] <---(M-Smart Protocol)---> [Midea dongle / your dongle] <---(Appliance Control Protocol)---> [Appliance]
Filed length in byte(s) Description
Header tag 1 Fixied to 0xAA
Length 1 N + 10, N for length of body, 10 for length of M-Smart header
Type of appliance 1 refer Type
Frame check 1 Unusded
Reserved 2 0x00
Frame ID 1 Unused
Frame protocol version 1 Unused
Appliance protocol version 1 Unused
Type 1 set = 0x02
query = 0x03
notify = 0x04
notify2 = 0x05
exception = 0x06
exception2 = 0x0A
Body N The UART Protocol / Appliance Control Protocol
Checksum 1

For more details, you can read this integration source code to understand.