Midea branded AC’s with ESPhome (no cloud)


1 Like

EDIT:
It’s indeed the dev one, as in the regular ESPHome the config is basically empy.
I have installed the dev one and added the repository, let’s see.

EDIT2:
I think I’m almost there.
since I get the OTA error when trying to upload the compiled firmware to the ESP8266, I would need to get the firmware.bin compiled in the Hassio (raps) folder
/data/giatsucamera/.pioenvs/giatsucamera/firmware.bin

EDIT3:
Plugged the programmer in the rasp and flashed from there.
It seems that changing the board from stuff to esp01_1m breaks the connection.

EDIT4 (yeah…):
I got the entity! I’m using the “programmer” not modified to read the ESP8266 and I finally got it :slight_smile:
The lady is sleeping right in the room with the Split, so I’ll connect it tomorrow and update (again!) the post.

Thank you!!!

1 Like

Hi again,

Unfortunately, the moment I plug the ESP8266 to the AC, it connects to WiFi but it always appears as Unavailable in Home Assistant.

When I plug it to my PC (with the USB adapter, below), it connects to wifi and it is recognized by Home Assistant…

I tried to switch the RX and TX three times, but the result is always the same (and I don’t think that may be the issue…).

A bit lost here, ideas?

Thanks!

Does the HA log say anything? Errors, warnings? That’s the log from HA, you can find it under Settings -> Logs.

And while you’re at it, what does the ESPHome log for the device is telling you? Any errors? That is the log in your WebUI from ESPHome, every device you flashed should have a LOG button to check the device directly. Setup the dongle in your A/C, let it connect to WIFI and then check the log. Let that screen run for a while, it should give you more information what is happening. :slight_smile:

Thank you @paddy0174.

I was wrong. The ESP only connets when plugged into the reader and then connected to my pc.
The moment I connect it to the AC, it won’t connect to the WiFi (I was wrong before as my router wasn’t updating the connected devices once I unplugged it from the pc and connected to the AC).

So, to sum up:

Compiling and flashing shouldn’t be the problem, as the ESP is recognized by HA once plugged into the PC.

The moment I connect it to the AC, it shows both leds (red and blue) like if it tried to connect but it won’t.

WiFi signal shouldn’t be a problem, as I have an AX1800 xiaomi router that has a huge reach and there is only a thin wall between the ESP and the router (8m max).

I really don’t understand.
My next step would be to remove the board from the AC housing and check if there are info below about the pin wiring, the only difference for it to work and not working…

What do you mean with showing both LED’s like if it tried to connect?
Red should be steadily on, while blue blinks approx. once every sec…

If Red blinks too, it indicates something wrong with powersupply.

PS: you can supply the converter board with external 5 volt power (just make sure the gnd wire from powersupply and AC are connected)

PPS: if you turn off the router, does the eps show up as available hotspot?
image
If not, another indication the unit does not start up correctly when connected to the AC…

As @aceindy suggested, you should try the dongle directly. No need to power off your router, just set a “false” wifi in your ESP data, so the dongle can’t connect. That should start the captive portal and the dongle should bring up it’s own wifi. Connect to it with your phone or pc.

But before you do so, check the log within ESP while you have it running (connected to your pc).

EDIT: I almost forgot…did you check your router for correct settings? I had it once, that I had disallowed “new devices” to the wifi… :smiley:

Thank you @aceindy and @paddy0174!

So, the red led is always on, yeah.
The blue led is off most of the time, with some intervals of it being on for 3-4 seconds in a row and then off again.
I know by checking it when connected to the PC, that if it is blinking every second, it is connected to WiFi.

Now, after checking all this and with the ESP connected to the AC (and no wifi), I decided to relax a bit by playing a long skirmish at C&Cnet. After playing it (2h more or less), I was on my way to remove the board of the AC to check the wiring and when I entered the room where the AC is, the ESP blue led was blinking and it was indeed connected and showing up in HA!
I tried to turn the AC on from HA but I couldn’t do anything (every button was grayed out), so I gather the TX and RX were probably switched. I then unplugged the ESP to resolder the TX and RX wires and plugged it back and now it’s there, same as always, not connecting.

This takes me to some considerations:

  1. Problem may be some weird things happening with the lease of the router with the ESP, no idea why as no other device is behaving like that (30+ devices connected there).

  2. I will try to put a fake WiFi as suggested and then connect to the WiFi dongle, just to be sure the issue is not in the ESP

For now, thanks a lot for all you help and support, hugely appreciated! :slight_smile:

As I said, check your router settings… :smiley: Maybe you hit a limit in adding devices or something strange like that… :smiley: Some AVM FritzBoxes have a limit for something, but IIRC it was around 150 or 200 devices.

I would take a maybe slower but more oriented approach. Check the WIFI settings first, even if it comes up in HA, don’t mess with it, check why the wifi is working at that moment. Maybe there are some clues in the log, and while it is working, it is the ideal time to check. :smiley:

If wifi is working, and you know why that is, move over to HA. It doesn’t make it easier to debug if the connection is only partly available. :smiley:

In HA I’d work my way up from the ESPHome log over the “normal” HA log to enabling the debug log in HA.

Hi again,

After some checks I can say that:

WiFi range is not the issue. I’ve plugged the ESP on my other split, 3 meters away from the router, same results.
I compiled a new firmware with a fake wifi, to check the ESP hotspot.
Once plugged into the AC, it indeed creates a hotspot I can connect to. Once joined the Hotspot network I can point the ESP to the available WiFi networks. If I point it to my wifi Network (providing the Password in the relevant field), it tried to connect to it but without luck.

I get the following logs from ESPHome:

INFO Reading configuration /config/esphome/test01.yaml...
INFO Starting log output from test01.local using esphome API
INFO Connecting to test01.local:6053 (192.168.31.9)
WARNING Initial connection failed. The ESP might not be connected to WiFi yet (Error connecting to 192.168.31.9: [Errno 111] Connection refused). Re-Trying in 1 seconds
INFO Connecting to test01.local:6053 (192.168.31.9)
WARNING Initial connection failed. The ESP might not be connected to WiFi yet (Error connecting to 192.168.31.9: [Errno 111] Connection refused). Re-Trying in 1 seconds
INFO Connecting to test01.local:6053 (192.168.31.9)
WARNING Initial connection failed. The ESP might not be connected to WiFi yet (Error connecting to 192.168.31.9: [Errno 111] Connection refused). Re-Trying in 2 seconds
INFO Connecting to test01.local:6053 (192.168.31.9)

I then tried to compile a new firmware with a fake wifi BUT without the UART and Midea dongle bit.
Rechecked everything and when I point the ESP to my wifi through the Hotspot it creates, it connects to it no problem!!

I could also launch the logs in HA from the ESPHome and the ESP appears connected there, without issues.

This makes me think the issue is somewhere in the UART and Midea bit:

uart:
  tx_pin: 1
  rx_pin: 3
  baud_rate: 9600

midea_dongle:

midea_ac:
  name: "Split Camera"
  beeper: true

Note:
are the UART pins referring to the actual pins i connect to the AC?
If yes, how do you count these pins? Starting from a side? If that’s the case, won’t 1 always be VCC or GND? I’m completely ignorant of this argument so please bear with me if I said stupid stuff :slight_smile:

What do you think @aceindy @paddy0174?

UPDATE:
I left the ESP connected yesterday night and went to bed. Few minutes ago I looked at it and the blue led was flashing.
I checked on HA and it’s connected!

I queried the ESPHome log and it’s indeed there:

INFO Reading configuration /config/esphome/test01.yaml...
INFO Starting log output from test01.local using esphome API
INFO Connecting to test01.local:6053 (192.168.31.9)
INFO Successfully connected to test01.local
[12:56:40][I][app:105]: ESPHome version 1.16.0-dev compiled on Feb 22 2021, 16:15:49
[12:56:40][C][wifi:443]: WiFi:
[12:56:40][C][wifi:303]:   SSID: [redacted]
[12:56:40][C][wifi:304]:   IP Address: 192.168.31.9
[12:56:40][C][wifi:306]:   BSSID: [redacted]
[12:56:40][C][wifi:307]:   Hostname: 'test01'
[12:56:40][C][wifi:311]:   Signal strength: -38 dB ▂▄▆█
[12:56:40][C][wifi:315]:   Channel: 11
[12:56:40][C][wifi:316]:   Subnet: 255.255.255.0
[12:56:40][C][wifi:317]:   Gateway: 192.168.31.1
[12:56:40][C][wifi:318]:   DNS1: 8.8.8.8
[12:56:40][C][wifi:319]:   DNS2: 8.8.4.4
[12:56:40][D][midea_ac:053]: TX: query
[12:56:40][D][midea_dongle:094]: TX: AA 22 AC 00 00 00 00 00 03 03 41 00 00 FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 84 68 
[12:56:40][C][uart_esp8266:075]: UART Bus:
[12:56:40][C][uart_esp8266:077]:   TX Pin: GPIO1
[12:56:40][C][uart_esp8266:080]:   RX Pin: GPIO3
[12:56:40][C][uart_esp8266:081]:   RX Buffer Size: 256
[12:56:40][C][uart_esp8266:083]:   Baud Rate: 9600 baud
[12:56:40][C][uart_esp8266:084]:   Data Bits: 8
[12:56:40][C][uart_esp8266:085]:   Parity: NONE
[12:56:40][C][uart_esp8266:086]:   Stop bits: 1
[12:56:40][C][uart_esp8266:088]:   Using hardware serial interface.
[12:56:40][W][uart:041]:   You're using the same serial port for logging and the UART component. Please disable logging over the serial port by setting logger->baud_rate to 0.
[12:56:40][D][midea_dongle:081]: TX: notify WiFi STA connected, signal stretch 4
[12:56:40][D][midea_dongle:094]: TX: AA 1F FF 00 00 00 00 00 03 0D 01 01 04 00 00 00 00 FF 00 00 00 00 00 00 00 00 00 00 00 00 31 9C 
[12:56:40][D][midea_dongle:033]: RX: AA 22 AC 00 00 00 00 00 03 03 C0 00 8E 66 7F 7F 00 3C 00 00 00 61 4A 00 00 00 00 00 00 00 00 00 00 1D 76 
[12:56:40][D][midea_ac:031]: RX: query frame
[12:56:40][C][logger:185]: Logger:
[12:56:40][C][logger:186]:   Level: DEBUG
[12:56:40][C][logger:187]:   Log Baud Rate: 115200
[12:56:40][C][logger:188]:   Hardware UART: UART0
[12:56:40][C][captive_portal:169]: Captive Portal:
[12:56:40][D][midea_ac:053]: TX: query
[12:56:40][D][midea_dongle:094]: TX: AA 22 AC 00 00 00 00 00 03 03 41 00 00 FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 84 68 
[12:56:40][D][midea_dongle:033]: RX: AA 1F AC 00 00 00 00 00 03 0D 01 01 04 00 00 00 00 FF 00 00 00 00 00 00 00 00 00 00 00 00 31 EF 
[12:56:40][W][midea_ac:024]: RX: not PropertiesFrame!
[12:56:40][C][ota:029]: Over-The-Air Updates:
[12:56:40][C][ota:030]:   Address: test01.local:8266
[12:56:40][C][ota:032]:   Using Password.
[12:56:41][C][api:095]: API Server:
[12:56:41][C][api:096]:   Address: test01.local:6053
[12:56:41][D][midea_dongle:033]: RX: AA 22 AC 00 00 00 00 00 03 03 C0 00 8E 66 7F 7F 00 3C 00 00 00 61 4A 00 00 00 00 00 00 00 00 00 00 1D 76 
[12:56:41][D][midea_ac:031]: RX: query frame
[12:56:41][D][midea_ac:053]: TX: query
[12:56:41][D][midea_dongle:094]: TX: AA 22 AC 00 00 00 00 00 03 03 41 00 00 FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 84 68 
[12:56:42][D][midea_dongle:033]: RX: AA 22 AC 00 00 00 00 00 03 03 C0 00 8E 66 7F 7F 00 3C 00 00 00 61 4A 00 00 00 00 00 00 00 00 00 00 1D 76 
[12:56:42][D][midea_ac:031]: RX: query frame
[12:56:42][D][midea_ac:053]: TX: query
[12:56:42][D][midea_dongle:094]: TX: AA 22 AC 00 00 00 00 00 03 03 41 00 00 FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 84 68 
[12:56:43][D][midea_dongle:033]: RX: AA 22 AC 00 00 00 00 00 03 03 C0 00 8E 66 7F 7F 00 3C 00 00 00 61 4A 00 00 00 00 00 00 00 00 00 00 1D 76 
(and so on with exa codes)

I then created a card in lovelace with the entity and I could control the Split without any issue, it is working flawlessly. O_O

A couple of thoughts:

  1. I obviously can’t stay without the Split control every time power goes away or I turn it off for any reason.
  2. I still don’t understand why the ESP doesn’t connect right away. Maybe it’s related to the lease as i said before, so I reduced the lease time in the router to 5 minutes, just to see if that may be a cause.
  3. The TX and RX were wired exactly as explained in your picture @aceindy :slight_smile:

Let’s see how it goes now.
Thanks a lot for now guys!

2 Likes

@nvschilleman i think you have logger enabled??

And yes, unit is updating frequently (during which the blue led blinks)

For the beeping i do not have any clues…sorry
I suspect it is related to

frame check failed

Maybe you can ask on the Telegram group Midea-msmart, as most devs are on there :wink:

Just a last update from me as everything seems to be finally working fine!
I gather the connection issues were due to the lease of the router and the fact I had two different ESP8266 for my two splits and, pretty dumbly I have to say, I’ve been juggling around with firmware and such on both.

I did some checks and even after disconnecting and reconnecting them after some minutes or hours, they connect to internet in a matter of few seconds.

So yeah, thanks again for all the help, really!

Should you even need IT or ES translations for your projects, just let me know :slight_smile:

2 Likes

Good to hear everything works as you wanted and glad to help :wink:

I am running Home Assistant 2021.2.3 on a Raspberry PI. I have installed ESPHome 1.16.2 and am able to flash the ESP-01 boards. When the ESP-01 board is powered up it connects to the network and in the ESPHome UI the red bar above the relevant turns green. I couldn’t get the https://github.com/dudanov/esphome repository to install in HACS - custom repository and get the error “Repostitory structure for dev is not compliant” to make the Midea-ac component available in ESPHome.

Using my Mac I was able to follow the instructions for flashing the ESP-01 on another computer with the Midea-ac component included however, the board doesn’t then appear in ESPHome on the home assistant.

Do I need to find a way to get the Midea-ac component onto my home assistant PI? If so, does anyone have any ideas on how to do that?

Sorry, just read again your message and I think your issue is what I had at the beginning.
You have to install the ESPHome dev addon, not the regular one, as in the dev version you can actually modify the configuration in the supervisor > addon part adding the dudanov repo. @aceindy explained this to me just a few post above :slight_smile:

It is not added in HACS, but a configuration option in the esphome addon:


Thanks. I hadn’t realised that I needed to type the version in on that page. The steps for getting the dev version of ESPHome was what tripped me up.

I must say I’m slightly confused by the more recent posts.

My board setup looks the same as @nvschilleman’s boards, CN3 is 5-pin, connected to an adapter board that says 2.4G(WIFI) on it.

Can I connect directly to the CN3 as @kokuo81 did with their 4-pin, or do I need to use a modified USB port?
Thanks!

the usb and 4 pin connector(cn3) are the same; I also used the 4 pin plug myself
(as shown in the picture in the first post)
However, nvschilleman did have some issues, never heard if they got resolved…

You said that your AC had both the 4pin and usb style plugs. Do you have one of these interface adapters for the USB?
image