ESP Haier: Haier Air Conditioner + ESP Home + Wemos D1 mini

No unfortunately I can not get it to work. I now use a BroadLink RM4 Mini with Climate MQTT and programmed all cooling, heating and drying modes from 16 to 23 degrees included with the fan modes auto, low, medium and high. That’s working great, but as you can imagine it’s a pitty to not have a state response from the AC itself. But the RM4 Mini is very reliable as am experiencing in the couple of weeks.

What was the problem? I am experiencing something similar. My UI component always apears to be off even though it is on and working.

Hi everybody
Using a sonoff basic I was able to flash it and get the component on the UI, but the component appears always to be off.
When I watch at the ESPHome logging I see only the poll messages:

'I edited Haier.h in order to print whether the loop was called:

 void loop() override  {


        if (Serial.available() > 0) {
            
			if (Serial.read() != 255) return;
			if (Serial.read() != 255) return;
			
			data[0] = 255;
			data[1] = 255;

            Serial.readBytes(data+2, sizeof(data)-2);

            readData();

        } else {
			ESP_LOGD("loop", "No serial available");
		}
    }

And the result is that no data is ever available

Any idea why could be happening? It is like there is no actual communication with the Haier device…

Thanks!!

How do you connect the Sonoff TX/RX?

Maybe, the GPIOS aren’t the same that in wemos d1

Hi!
The problem was that the Haier protocol has changed.

I opened the Wifi module and soldered 2 ftdi cable to the TX and RX to be able to spy the communication between the Wifi module and the AC with Docklight. Once connected and capturing I’ve made some test turning on and off the AC from the remote control aswell as from the application (I kept the time).
I have both the logs and the timing where I was triggering the commands

Here are the files:
https://drive.google.com/drive/folders/1cQpStGslVXtKyNsSP_BV0ZW_kcq9yRuF?usp=sharing

After that, I send some frames from my laptop with FTDI conversor to the HAIER uart and worked!!
ON command: FF FF 0C 40 00 00 00 00 00 01 5D 01 00 01 AC BD FB
OFF command: FF FF 0C 40 00 00 00 00 00 01 5D 01 00 00 AB 7D 3A
Setpoint 25: FF FF 14 40 00 00 00 00 00 01 60 01 09 08 25 00 02 03 00 06 00 0C 03 0B 70

When I’ll have time I’ll try to update my Haier.h file for ESPHome component and try it out.

The commands that I identified so far are:

 	byte poll[15] = {0xFF,0xFF,0x0A,0x40,0x00,0x00,0x00,0x00,0x00,0x01,0x4D,0x01,0x99,0xB3,0xB4};
    byte power_command[17]     = {0xFF,0xFF,0x0C,0x40,0x00,0x00,0x00,0x00,0x00,0x01,0x5D,0x01,0x00,0x01,0xAC,0xBD,0xFB};
    byte power_on_command[17]  = {0xFF,0xFF,0x0C,0x40,0x00,0x00,0x00,0x00,0x00,0x01,0x5D,0x01,0x00,0x01,0xAC,0xBD,0xFB};
    byte power_off_command[17] = {0xFF,0xFF,0x0C,0x40,0x00,0x00,0x00,0x00,0x00,0x01,0x5D,0x01,0x00,0x00,0xAB,0x7D,0x3A };
	byte set_point_command[25] = {0xFF,0xFF,0x14,0x40,0x00,0x00,0x00,0x00,0x00,0x01,0x60,0x01,0x09,0x08,0x25,0x00,0x02,0x03,0x00,0x06,0x00,0x0C,0x03,0x0B,0x70};

The polling is done every 5 seconds
And from the polling response the following informtion can be extracted:

        #define TEMPERATURE_OFFSET   	21
        #define SET_TEMPERATURE_OFFSET 12
        #define POWER_OFFSET       		17
        #define POWER_OFF   		2


        current_temperature = data[TEMPERATURE_OFFSET] + 16;
        target_temperature = data[SET_TEMPERATURE_OFFSET] + 16;
        if (data[POWER_OFFSET] == POWER_OFF) {
            mode = CLIMATE_MODE_OFF;
        } 

One thing I’m missing is the CRC calculation. In this protocol change it seems instead of one byte it has 2, but it is not a sum neither xor…

Maybe is not a CRC, mabye is a sign with password…

The first step is get all valid frame posibles, changing the temperature, modes, turn off and turn on…

I finally found it.
The final 3 bytes are: [Checksum] [CRC16 Hi] [CRC16 Low]

Once I have the updated Haier.h for the new Haier firmware I’ll post it here the repo.

1 Like

Hi

Here is my repo forked from @MiguelAngelLV repo.

With the Haier.h file compatible with the latest Haier firmware (R_1.0.00/e_2.5.14)

1 Like

Thank you! But unfortunately still doesn’t work for my Haier AS25NHPHRA:

Hi @pavuk

For the log you shared your ESP module is not reading anything from the serial port.

How are you connecting the esp to your Haier unit? You cannot connected through a FTDI cable, you have to take a USB cable, cut it and connect it to the esp board serial output

The usb female connector of the Haier unit is not a USB protocol, it is a plain serial, so you just need to take the red and black for the power (5V) and the other ones for the TX and RX.

If your setup is alright, maybe the problem is in that the Haier firmware is not the same as mine and the protocol has changed.
The only thing left to do is connect back your wifi module and hack it (as I did) to see the frames comming in and out. Once you have the frames, you’ll have to decode them.

I hope it helps…

I have connected it correctly, I think. Look at attached picture.
Looks like something wrong with firmware for my Haier AS25NHPHRA :frowning:

Hi, If you already checked the TX and RX are connected ok (TX -----> RX and RX <---------- TX) then the next thing I would do is to sniff the protocol between Wifi Module and the Haier Unit.

Once you’ve got it soldered all you have to do is take 2 ftdi cables (serial <-> usb) and connect the each one of the rx of the cable to the wifi module.
On your laptop then you’ll be able to see the communication between wifi module and the haier unit

WifiModule sniffer

I hope it helps.

Let me know if you have any doubt.

Hi,
@albetaCOM , How can we communicate in a non-forum? Mail or Telegram?

Yes.
Do you have any issue with the repo? You can create an issue to the repo aswell.

You have a fork of the repository, it is not possible to create an issue there. Find me in telegram @instalator

Thanks @albetaCOM

I’ve prepared an USB extension cable, cut it, soldered pins to it. Hopefully it will also work this way. Now (still) waiting for the FTDI. :innocent:


@albetaCOM

We have followed your configuration (except removing the comment in front of the baudrate).
The Haier aircon can be used to set the temperature and use the cool or auto function, however we do not get the current temp and the off mode does not work.

In the log files of the wemos, there is only a POLL command shown. To exclude any wiring issues we used a second wemos and same result here, so in our opinion we wired correctly and because the temp can be set the unit is functional.

Any thoughts on the OFF mode and current setpoint? We tried the old Haier.h but nothing works there so the unit must be on latest firmware.

Hi @ceriel,

I’ve been doing some changes in order to work with the AC modes. As in the Haier there are more modes than the ESPHome climate components what I’ve done is when selecting Auto mode in the climate component it will put the Haier in Fan mode so the mode available are:

  • Heat
  • Cool
  • Fan

Also, when doing the changes I broke something related to turning on the unit, but it is working now. Can you test it with the last commit?

I also update the yaml file to be the same it is working with my devices.

Let me know if the last version works with your unit.

@albetaCOM,

Thanks! Somehow the transmit works, but the receive does not.

[D][Haier:157]: POLL:  255 255 10 64 0 0 0 0 0 1 77 1 153 179 180 e
[D][Haier:157]: POLL:  255 255 10 64 0 0 0 0 0 1 77 1 153 179 180 e
[D][climate:010]: 'Haier' - Settinge
[D][climate:014]:   Mode: COOLe
[D][Control:235]: Control calle
[D][Control:241]: *call.get_mode() = 2e
[D][Control:245]: POWERING ON THE A/Ce
[D][Haier:345]: Message sent:  255 255 12 64 0 0 0 0 0 1 93 1 0 0 171 125 58  - CRC: AB - CRC16: 7D3Ae
[D][Haier:345]: Message sent:  255 255 20 64 0 0 0 0 0 1 96 1 0 8 37 0 2 3 0 6 0 12 250 36 160  - CRC: FA - CRC16: 24A0e
[D][Control:306]: COOL MODE SENT!!!!!e
[D][climate:172]: 'Haier' - Sending state:e
[D][Haier:157]: POLL:  255 255 10 64 0 0 0 0 0 1 77 1 153 179 180 e
[D][Haier:157]: POLL:  255 255 10 64 0 0 0 0 0 1 77 1 153 179 180 e
[D][Haier:157]: POLL:  255 255 10 64 0 0 0 0 0 1 77 1 153 179 180 e
[D][Haier:157]: POLL:  255 255 10 64 0 0 0 0 0 1 77 1 153 179 180 e
[D][Haier:157]: POLL:  255 255 10 64 0 0 0 0 0 1 77 1 153 179 180 e
[D][Haier:157]: POLL:  255 255 10 64 0 0 0 0 0 1 77 1 153 179 180 e
[D][Haier:157]: POLL:  255 255 10 64 0 0 0 0 0 1 77 1 153 179 180 e
[D][Haier:157]: POLL:  255 255 10 64 0 0 0 0 0 1 77 1 153 179 180 e
[D][Haier:157]: POLL:  255 255 10 64 0 0 0 0 0 1 77 1 153 179 180 e
[D][Haier:157]: POLL:  255 255 10 64 0 0 0 0 0 1 77 1 153 179 180 e
[D][climate:010]: 'Haier' - Settinge
[D][climate:014]:   Mode: COOLe
[D][Control:235]: Control calle
[D][Control:241]: *call.get_mode() = 2e
[D][Control:245]: POWERING ON THE A/Ce
[D][Haier:345]: Message sent:  255 255 12 64 0 0 0 0 0 1 93 1 0 0 171 125 58  - CRC: AB - CRC16: 7D3Ae
[D][Haier:345]: Message sent:  255 255 20 64 0 0 0 0 0 1 96 1 0 8 37 0 2 3 0 6 0 12 250 36 160  - CRC: FA - CRC16: 24A0e
[D][Control:306]: COOL MODE SENT!!!!!e
[D][climate:172]: 'Haier' - Sending state:e
[D][Haier:157]: POLL:  255 255 10 64 0 0 0 0 0 1 77 1 153 179 180 e
[D][Haier:157]: POLL:  255 255 10 64 0 0 0 0 0 1 77 1 153 179 180 e
[D][Haier:157]: POLL:  255 255 10 64 0 0 0 0 0 1 77 1 153 179 180 e
[D][Haier:157]: POLL:  255 255 10 64 0 0 0 0 0 1 77 1 153 179 180 e
[D][Haier:157]: POLL:  255 255 10 64 0 0 0 0 0 1 77 1 153 179 180 e
[D][climate:010]: 'Haier' - Settinge
[D][climate:014]:   Mode: OFFe
[D][Control:235]: Control calle
[D][Control:241]: *call.get_mode() = 0e
[D][Haier:345]: Message sent:  255 255 12 64 0 0 0 0 0 1 93 1 0 0 171 125 58  - CRC: AB - CRC16: 7D3Ae
[D][Control:267]: No need to update mode OFF (0)e
[D][climate:172]: 'Haier' - Sending state:e
[D][climate:175]:   Mode: OFFe
[D][Haier:157]: POLL:  255 255 10 64 0 0 0 0 0 1 77 1 153 179 180 e
[D][climate:010]: 'Haier' - Settinge
[D][climate:014]:   Mode: OFFe
[D][Control:235]: Control calle
[D][Control:241]: *call.get_mode() = 0e
[D][Haier:345]: Message sent:  255 255 12 64 0 0 0 0 0 1 93 1 0 0 171 125 58  - CRC: AB - CRC16: 7D3Ae
[D][Control:267]: No need to update mode OFF (0)e
[D][climate:172]: 'Haier' - Sending state:e
[D][climate:175]:   Mode: OFFe
[D][Haier:157]: POLL:  255 255 10 64 0 0 0 0 0 1 77 1 153 179 180 e
[D][Haier:157]: POLL:  255 255 10 64 0 0 0 0 0 1 77 1 153 179 180 e
[D][Haier:157]: POLL:  255 255 10 64 0 0 0 0 0 1 77 1 153 179 180 e
[D][Haier:157]: POLL:  255 255 10 64 0 0 0 0 0 1 77 1 153 179 180 e
[D][Haier:157]: POLL:  255 255 10 64 0 0 0 0 0 1 77 1 153 179 180 e
[D][Haier:157]: POLL:  255 255 10 64 0 0 0 0 0 1 77 1 153 179 180 e
[D][Haier:157]: POLL:  255 255 10 64 0 0 0 0 0 1 77 1 153 179 180 e
[D][Haier:157]: POLL:  255 255 10 64 0 0 0 0 0 1 77 1 153 179 180 e
[D][Haier:157]: POLL:  255 255 10 64 0 0 0 0 0 1 77 1 153 179 180 e
[D][Haier:157]: POLL:  255 255 10 64 0 0 0 0 0 1 77 1 153 179 180 e

We are using a wemos d1 and have soldered it correctly (we think… :slight_smile:).
Any idea what to check?

@albetaCOM, tried different modules and edited the code but the read does not work. Got my own Haiers today and I can operate them but the current mode and temp is not read. Any idea what i did wrong?