Midea branded AC’s with ESPhome (no cloud)

I’ve been asked to secure this info from Any Support for Midea A/C
I’ve put here all relevant info from that topic:


Looks like it is finally working!
Thanks Mac-Zhou, ReneKlootwijk, SergeyDudanov, Fraschi for awesome collaboration.
(it already works, but development still ongoing to support more models and functions)

See this post for supported models (list is updated regularly) Thanks @paddy0174 !!

Hardware:
You can either order them online (pre-assembled, have a look here Thanks @dudanov for making this available for free!!)

Or make your own:
image
Requirements:
1x


and to program it
1x image
or with soldered links to put it into programming mode

(Check this link for more options flashing esp-01’s)

I used this to flash the esp-01: USB Serial Adapter CH340G 5V/3.3V USB to TTL-UART.

As the AC itself doesn’t use USB (even though it uses an USB connector), you cannot use the programmer adapter there, you need the 5V/3.3V Adapter.
Mine looks like this (my A/C was both equipped with USB as well as header plug, so I could choose)

Software:
Normally ‘programming’ would be done from the ESPHome add-on


example of my mideahvac.yaml:

# Example configuration entry
substitutions:
  node_name: mideahvac # Use a unique name.
  node_id: midea_ac    # Use a unique id.
  friendly_node_name: "Midea AC"

esphome:
  name: ${node_name}
  comment: ${friendly_node_name}
  platform: ESP8266
  board: esp01_1m

wifi:
  ssid: <mywifissid>
  password: <mywifipassword>
  domain: <my own domain name> # Optional in case mdns .local doesn't work

# Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: ${node_name} " FB"
    password: "fallback"

captive_portal:

# Enable Home Assistant API
api:
  password: <myapipassword> # Optional in case set on HA esphome addon

# Enable Over The Air updates
ota:

# Disable logging
logger:
  baud_rate: 0
  logs:
    sensor: ERROR
    duty_cycle: ERROR
    binary_sensor: ERROR
    light: ERROR

# Optional, Enable Web server; start internal webserver so it can be used stand-alone
web_server:
  port: 80

# Optional, Sync time with Home Assistant.
time:
  - platform: homeassistant
    id: ${node_id}_homeassistant_time

# Binary Sensors.
binary_sensor:
  - platform: status
    name: ${friendly_node_name} Connection Status
    id: ${node_id}_connection_status

# Sensors.
sensor:
  - platform: uptime
    name: Uptime Sensor
    id: ${node_id}_uptime_sensor
    icon: mdi:clock-start
    update_interval: 60s
  - platform: wifi_signal
    name: ${friendly_node_name} WiFi Signal
    id: ${node_id}_wifi_signal
    update_interval: 60s
  - platform: template
    name: ${friendly_node_name} fan mode
    id: ${node_id}_fan_mode
    internal: true
    update_interval: 10s
    lambda: !lambda |-
      if (id(${node_id}_my_climate).fan_mode == 2)
      {
        if (id(${node_id}_select_fan_mode).state != "Auto")
        {
          auto call = id(${node_id}_select_fan_mode).make_call();
          call.set_option("Auto");
          call.perform();
        }
      }
      else if (id(${node_id}_my_climate).fan_mode == 3)
      {
        if (id(${node_id}_select_fan_mode).state != "Low")
        {
          auto call = id(${node_id}_select_fan_mode).make_call();
          call.set_option("Low");
          call.perform();
        }
      }
      else if (id(${node_id}_my_climate).fan_mode == 4)
      {
        if (id(${node_id}_select_fan_mode).state != "Medium")
        {
          auto call = id(${node_id}_select_fan_mode).make_call();
          call.set_option("Medium");
          call.perform();
        }
      }
      else if (id(${node_id}_my_climate).fan_mode == 5)
      {
        if (id(${node_id}_select_fan_mode).state != "High")
        {
          auto call = id(${node_id}_select_fan_mode).make_call();
          call.set_option("High");
          call.perform();
        }
      }
      return id(${node_id}_my_climate).fan_mode;

# Text Sensors.
text_sensor:
  - platform: version
    name: ${friendly_node_name} ESPHome Version
    id: ${node_id}_esphome_version    
  - platform: wifi_info
    ip_address:
      name: ${friendly_node_name} IP Address
      id: ${node_id}_ip_address
      icon: mdi:ip-network

# Select.
select:
  - platform: template
    name: "Fan mode"
    id: ${node_id}_select_fan_mode
    icon: mdi:fan
    optimistic: true
    options:
      - Auto
      - Low
      - Medium
      - High
    on_value:
      then:
        - lambda: |-
            auto call = id(${node_id}_my_climate).make_call();
            call.set_fan_mode(x.c_str());
            call.perform();

# Switches.
switch:
  - platform: restart
    name: ${friendly_node_name} Restart
    id: ${node_id}_restart
    icon: "mdi:restart"
  - platform: shutdown
    name: ${friendly_node_name} Shutdown
    id: ${node_id}_shutdown
  - platform: safe_mode
    name: ${friendly_node_name} Restart (Safe Mode)"
    id: ${node_id}_safe_mode
  - platform: template
    name: ${friendly_node_name} Beeper
    icon: mdi:volume-source
    id: ${node_id}_beeper
    restore_state: true
    optimistic: true
    turn_on_action:
      midea_ac.beeper_on:
    turn_off_action:
      midea_ac.beeper_off:

# Define UART pinout 
uart:
  tx_pin: 1
  rx_pin: 3
  baud_rate: 9600

climate:
  - platform: midea
    id: ${node_id}_my_climate   # Use a unique id
    name: ${node_name}          # Use a unique name

# Optional settings overrides.
    period:  2s                        # Optional
    timeout: 4s                       # Optional
    num_attempts: 3              # Optional
    visual:                              # Optional
      min_temperature: 17 °C    # min: 17
      max_temperature: 30 °C    # max: 30
      temperature_step: 0.5 °C  # min: 0.5
    autoconf = true                # Optional

# All capabilities in the section below are detected when autoconf = true:
    supported_modes:    
      - FAN_ONLY
      - HEAT_COOL
      - COOL
      - HEAT
      - DRY
    custom_fan_modes:
      - SILENT
      - TURBO
    supported_presets:  # All capabilities in this section detected by autoconf.
      - ECO
      - BOOST
      - SLEEP
    custom_presets:     # All capabilities in this section detected by autoconf.
      - FREEZE_PROTECTION
    supported_swing_modes:
      - VERTICAL
      - HORIZONTAL
      - BOTH
    outdoor_temperature:  # Optional. Create outdoor unit temperature sensor (may display incorrect values after long inactivity).
      name: "Temp"
    power_usage:          # Optional. Create power usage sensor (only for devices that support this feature).
      name: "Power"
    humidity_setpoint:    # Optional. Create indoor humidity sensor.
      name: "Humidity"

A full overview of parameters can be found here

Checking size /data/mideahvac/.pioenvs/mideahvac/firmware.elf
RAM:   [=====     ]  45.2% (used 37064 bytes from 81920 bytes)
Flash: [====      ]  40.1% (used 411128 bytes from 1023984 bytes)
Creating BIN file "/data/mideahvac/.pioenvs/mideahvac/firmware.bin" using "/root/.platformio/packages/framework-arduinoespressif8266/bootloaders/eboot/eboot.elf" and "/data/mideahvac/.pioenvs/mideahvac/firmware.elf"
========================= [SUCCESS] Took 8.98 seconds =========================
INFO Successfully compiled program.

OTA works for me nowadays(which was not the case when i used the dev repository).
But, if it fails, you can also compile it on HA, and then download and flash it over ser2usb,
Or compile the bins on W10 and flash it using the serial2usb com-port.

Below my command lines used to compile on W10:

cd c:\workshop\esphome

pip install esphome
pip install esphomeflasher
pip install --upgrade git+ https://github.com/esphome/esphome

esphome mideahvac.yaml wizard
esphome mideahvac.yaml compile

esphomeflasher

using the compiled C:\_workshop\esphome\mideahvac\.pioenvs\mideahvac\firmware.bin

image
Assuming you already installed python :wink:

More info here:

PS: If you have a Midea branded AC which uses an osk102/103 wifi module, and it doesn’t work (or works partially), please contact the Midea-msmart development team on Telegram and they will try to fix it😉

22 Likes

Hi,

Thanks for the detailed information, do you know if there are any pinout details available for the Midea usb-a to the header plug? My Midea dont look exactly as yours, hence I dont see the plug in the Midea circuit board, if not I probably need to measure for 5v and guess rx&tx pins :slight_smile:

The picture is from Telegram, and should help:

  • blue gnd
  • red +5v
  • yellow Rx
  • green Tx

    But still, if you measure you are sure😉
    Tx/Rx seems to be a guess always, as it also depends from which side you’re looking at it.
    (That also explain why manufacturers are not very consistent with it :thinking:)

Can’t you pull it apart a little more? The circuit board should be accessable relatively easy. What model do you have?

These units are mostly pretty basic in design, there is not much “technical” inside.

@aceindy
Thanks a lot for this thread, very much appreciated. Unfortuntaely I can’t test it, some python things are missing in the “supervised install” of HA (in the esphome container add-on), so I can’t get your version to install. I didn’t invest much time in it yet, so this may as well be just a small thing. I’ll try again in the next days. :slight_smile:

You could try the ‘custom’ repo option for esphome?

I think the bin is too big for OTA but you will be able to compile and download the bin…

Hmm looks like my USB is not standard model A, it have some minor cut at the ends as seen in the picture, so I cant just plugin a usb cable.

image

It also looks like there are some additional logic compared to the image as seen here: https://github.com/dudanov/midea-open-dongle

Updated:

So I tried to connect it using a modified USB connector and found the 5v/gnd lines, it however dont quite work as it should, I managed to get the AC to start but it kept “beeping” and did not allow me to make any changes on temp or modes beyond this. I thought it were an easy swap since I use the midea_ac by mac-zhou without any issues guess not :frowning:

Can i just use a Wemos D1 Mini instead of the ESP01 with the adapter? The Wemos has 5V and ground pins to be powered and the tx,rx pins for the serial connection. Also can be programed with a usb cable.

Please provide your manufacturer and model. :slight_smile:

Its a QLIMA SC-JA2516

I have midea-like AC (Lessar). I’ve opened it, found the board but there is no any usb-like port.
But there is some unsoldered ports with points 5v and grnd. Can somebody take a look on my board and say, is there any chance to connect it to HA?IMG_20210110_204618|280x500

Thanks, unfortunately the esphome container (the addon for Hass.io) does seem to miss some requirements, so it doesn’t compile your version. I’ll have to check what exactly is missing. Can’t be something big.

I’ll try and report back!

@yodi
Unfortunately I can’t find any information what chipset is build into the wifi dongle or even the A/C. Sorry, can’t be of more help here, we need to wait for someone to debug this model. It is, unfortunately, not very easy to debug something, you don’t own and can’t mess around with… :frowning:

@bartlebi
This is the under side of the circuit board, what about the other side? :wink: The dongle has to have a connection to that board, otherwise it wouldn’t work even with the manufacturer dongle. Or is your model not able to use a manufacturer dongle?

@all
Just to note: it does make sense, to give at least the manufacturer and model, so helping get’s a little easier. So please provide the data for your setup.

@paddy0174 There is a second photo in the post with a link. I don’t know why it was so loaded from the mobile.
There it is:https://community.home-assistant.io/uploads/short-url/c6Vw2OecR8AGWCaxo79ESYhcCn2.jpeg
No, my air conditioner does not support the wifi port out of the box, but I think they use a similar board, which in my case is simply not wired. It would be great if I could just solder the port and use it.

1 Like

@paddy0174 That’s weird…it compiles fine here:

INFO Reading configuration /config/esphome/Midea-hvac.yaml...
INFO Generating C++ source...
INFO Compiling app...
INFO Running:  platformio run -d /config/esphome/mideahvac
Please wait while upgrading PlatformIO...
PlatformIO has been successfully upgraded to 5.0.1!

********************************************************************************
If you like PlatformIO, please:
- follow us on Twitter to stay up-to-date on the latest project news > https://twitter.com/PlatformIO_Org
- star it on GitHub > https://github.com/platformio/platformio
- try PlatformIO IDE for embedded development > https://platformio.org/platformio-ide
********************************************************************************

Processing mideahvac (board: esp01_1m; framework: arduino; platform: [email protected])
--------------------------------------------------------------------------------
Tool Manager: Installing platformio/tool-scons @ ~4.40001.0
Tool Manager: tool-scons @ 4.40001.0 has been installed!
Tool Manager: Removing tool-scons @ 3.30102.0
Tool Manager: tool-scons @ 3.30102.0 has been removed!
HARDWARE: ESP8266 80MHz, 80KB RAM, 1MB Flash
PACKAGES: 
 - framework-arduinoespressif8266 3.20704.0 (2.7.4) 
 - tool-esptool 1.413.0 (4.13) 
 - tool-esptoolpy 1.20800.0 (2.8.0) 
 - toolchain-xtensa 2.40802.200502 (4.8.2)
Library Manager: Installing Update
Library Manager: Already installed, built-in library
Dependency Graph
|-- <ESPAsyncTCP-esphome> 1.2.3
|   |-- <ESP8266WiFi> 1.0
|-- <ESP8266WiFi> 1.0
|-- <ESP8266mDNS> 1.2
|   |-- <ESP8266WiFi> 1.0
|-- <ESPAsyncWebServer-esphome> 1.2.7
|   |-- <ESPAsyncTCP-esphome> 1.2.3
|   |   |-- <ESP8266WiFi> 1.0
|   |-- <Hash> 1.0
|   |-- <ESP8266WiFi> 1.0
|-- <DNSServer> 1.1.1
|   |-- <ESP8266WiFi> 1.0
Compiling /data/mideahvac/.pioenvs/mideahvac/src/esphome/components/midea_ac/midea_climate.cpp.o
Compiling /data/mideahvac/.pioenvs/mideahvac/src/esphome/components/midea_ac/midea_frame.cpp.o
Compiling /data/mideahvac/.pioenvs/mideahvac/src/esphome/components/midea_dongle/midea_dongle.cpp.o
Compiling /data/mideahvac/.pioenvs/mideahvac/src/esphome/components/midea_dongle/midea_frame.cpp.o
Compiling /data/mideahvac/.pioenvs/mideahvac/src/main.cpp.o
Linking /data/mideahvac/.pioenvs/mideahvac/firmware.elf
Building /data/mideahvac/.pioenvs/mideahvac/firmware.bin
Retrieving maximum program size /data/mideahvac/.pioenvs/mideahvac/firmware.elf
Checking size /data/mideahvac/.pioenvs/mideahvac/firmware.elf
RAM:   [=====     ]  45.2% (used 37064 bytes from 81920 bytes)
Flash: [====      ]  40.1% (used 411128 bytes from 1023984 bytes)
Creating BIN file "/data/mideahvac/.pioenvs/mideahvac/firmware.bin" using "/root/.platformio/packages/framework-arduinoespressif8266/bootloaders/eboot/eboot.elf" and "/data/mideahvac/.pioenvs/mideahvac/firmware.elf"
========================= [SUCCESS] Took 8.98 seconds =========================
INFO Successfully compiled program.

I only can’t upload it OTA:

ERROR Error binary size: Error: ESP does not have enough space to store OTA file. Please try flashing a minimal firmware (remove everything except ota)

However, I can download the bin, and then flash it by USB using ESPFlasher

The board I have looks similar, however, if I disconnect the cable to the Wifi module USB port, my indoor unit stops responding to the IR remote. So I dont think you can just solder on a port, the IR receiver is on the PCB with the LED display. The USB port module that I have looks similar to the one @yodi has. I also have the USB A port with the cuts.

@yodi did you have any success yet ?

Here are some pictures:



My system is an Inventor Multisplit with AR2MVI-12WiFi indoor units. The WiFi module that came with it is the EU-OSK103.

@nvschilleman, No sorry I’ve not had time to play with this yet, plan is to setup the serial bridge / uart sniffer from https://github.com/reneklootwijk to get a better view of what is being transmitted, but indeed our units looks very similar.

@bartlebi Do you have the wifi board as shown in nvschilleman’s 3rd picture? I think you’ll need that in order to enable wifi…
@nvschilleman The left connector on the wifi board goes to ?? CN3 on the display board ??

1 Like

@nvschilleman Thanks for your photos. It is strange, and is not clear for me how the IrDA and the Wi-Fi module are related. Am i right that you already had a board for connecting USB devices when you bought it, and after you bought only the Wi-Fi module itself?

I wrote to the service of the air conditioner brand with this question, they replied that simply unsoldering the connector on the board or replacing the display board with one with an indication and a connector will give nothing, since the presence of a wifi is not programmed in the main unit of the air conditioner and it simply will not work …

@yodi Okay! I ordered some ESP-01’s yesterday. When those arrive I’ll also give it a shot and post my progress in this topic.

@aceindy The left connector on the wifi board goes to CN3 on the display board.

@bartlebi, yes it is indeed strange, when I connect the WIFI board the LED on this board stars blinking a few times, also when there is no WIFI module plugged into the USB port of the WIFI board. When it stops blinking my IR remote works again…

What make/model is your air conditioner?

@nvschilleman I have 2 Lessar LS-H09KPA2/LU-H09KPA2.