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

OK I understood. As for the esphome and the firmware https://github.com/Oksion/esphaier I use, then I get such data, does this mean something? I can only guess that the rest of the bits are responsible for the rest of the functionality similar to the remote, right?

POLL: 
0-255
1-255
2-10
3-0
4-0
5-0
6-0
7-0
8-1
9-1
10-77
11-1
12-90 
13:58:32	[D]	[Haier:167]	
Readed message: 
0-255
1-255
2-34
3-0
4-0
5-0
6-0
7-0
8-1
9-2
10-109
11-1
12-0
13-27
14-0
15-0
16-0
17-127
18-0
19-0
20-0
21-0
22-0
23-1
24-0
25-1
26-0
27-0
28-0
29-0
30-0
31-12
32-0
33-0
34-0
35-8
36-67 
13:58:33	[D]	[climate:385]	
'ac-haier-livingroom' - Sending state:
13:58:33	[D]	[climate:388]	
  Mode: OFF
13:58:33	[D]	[climate:390]	
  Action: OFF
13:58:33	[D]	[climate:393]	
  Fan Mode: LOW
13:58:33	[D]	[climate:405]	
  Swing Mode: HORIZONTAL
13:58:33	[D]	[climate:408]	
  Current Temperature: 27.00°C
13:58:33	[D]	[climate:414]	
  Target Temperature: 24.00°C

Yes, that is right. I will also try to check that firmware today, no promises, and if I also get it working I will try to help.

I’ve tried a lot, couldn’t get any response with a Serial sniffer tool, tried setting it to COM5 instead of COM4 in the Device Manager, but nope. I did try USB sniffer from the same company which did find something every 5 seconds. So the default USB stick is sniffing every 5 seconds. Couldn’t really detect any useful info from this, didn’t look like it was consistently changing when changing the temperature.

I guess I bricked my ESP32 by setting the baud_rate to 9600 with the following:

logger:
  level: VERBOSE
  baud_rate: 9600

After this I cannot get it to do anything. It isn’t available wirelessly anymore, and even when I’m connecting it to a USB cable to my computer, or the Home Assistant computer it doesn’t see it, also not after restarting HA (because of Docker). Tried ‘factory resetting’ the ESP32 with holding the DU button, pressing Reset, wait a couple of seconds, and releasing the Reset button, but doesn’t look like that is working.

Update: New day, new micro USB cable, somehow it not worked again, ESP32 is fine again.

If you search haier.h in Oksion repo for ie. HEALTH_MODE_BIT_ON you will find it only in DEF, but nowhere it is actually user …

So basically as far as i know no one made firmware that has health, light etc. fuctionality for the ACs that use protocol version that MiguelAngelLV or Instalater did code for.

I do not even know how to implement those things, like what are limitations of esphome climate control, or HA climate control or how to add additional functionality to the esphome device. IE. the “light” can be “light bulb” device separate from the climate and same could be done for the position or health mode. But again, I do not know how to do such a thing or how to modify other firmwares, as they use ie. 0x40 for dry mode instead of 4 and i do not understand how that works.

Yes, I understand that it is difficult, good knowledge in reverse engineering, esphome and HA is required, it is unlikely that we have such guys in the chat. Maybe you have an example of air conditioners whose users have already revealed their functionality? And on their example, together we will come up with something

As an example of excellent implementation of an AC device with UART ESP<=>AC communication
I can recommend you midea AC implementation esphome/esphome/components/midea at dev ¡ esphome/esphome ¡ GitHub It is really great.
I am slowly trying to implement something similar in my small project but it will take some time.

2 Likes

So I finally started using MiguelAngelLV’s code, esphome and Home Assistant to control ACs, control does work, temperature updates, but when i turn off ac from HA it does actually turn off, but in HA last status is still shown.

Does this happen to everyone else?




Ok now i see that mode is 23, but power is index 29, even weirder, i guess value 24 should be off too, at least in my case it is

Same here ESP Haier: Haier Air Conditioner + ESP Home + Wemos D1 mini - #17 by mikekoumas

Same thing as @mikekoumas later writes that 24 moves to 8 in time; from @instalator blog it seems that it might be some compressor idle state? (I’m just guessing)

Here we can see that position 29 changed from 24 to 8 at 22:07, but there is no change in power usage by AC at that time

Can you please help me with displaying current temperature in current home assistant version?

I put this

template:
  - sensor:
      - name: "ac_obyvak_current_temperature"
        unit_of_measurement: "°C"
        state: "{{ state_attr('climate.ac_obyvak', 'current_temperature') }}"
        device_class: temperature

at the end of configuration.yaml, but I don’t see ac_obyvak_current_temperature as sensor in ie. statistics graph

I can see the sensor in home assistant settings - entities and even see the value history, but even when manually added to statistics graph i does not show

update:
this works

template:
  - sensor:
      - name: "ac obyvak current t"
        unique_id: "AcObyvakCurentT"
        unit_of_measurement: "°C"
        state: "{{ state_attr('climate.ac_obyvak', 'current_temperature') }}"
        device_class: temperature
        state_class: measurement

Will it be possible to do something based on the haiersmartair2 protocol? Health mode, sleep, indication control, remote control lock?
Based on this https://github.com/Oksion/esphaier

My code is based on this protocol. Still need to implement some of the features. Work in progress…

1 Like

Do you need help? Of course, I’m not strong in programming and reverse engineering, but I can try testing…

Yes I will need a help with testing. Just not now. I am on vacation right now will be back in 10 days.

1 Like

I tried to understand your code but I have no idea how does it actually read or set the values from the UART data from AC. I only see the climate.get_data and HaierClimate.getSerialData(), but I do not understand where is definition ie. that if position 29 has value of 24 or 8 means that climate component should report AC as off (this is from the smartair2 controlled ac)? If it is in haier_packet.h then I do not understand how that works. So I wanted to switch to your code and I was curious if I can get it to compile. I could not because of some platfrom.io stuff. But I will order esp32 dev boards so i can try it out later.

Looks really great as I could see references to all the stuff like health positions, outside temp, light etc.

First about structure, it everything is in haier_packet.h I used c++ (actually even c) thing called bit field Bit-field - cppreference.com
About reading: you can define which uart port to use in yaml file. You need to define port in uart section (for uart0 of esp8266 you can use pin 1 for tx and pin 3 for rx.
You should be able to use my code with esp8266 and arduino framework but you will need to change yaml file. Keep in mind that I never tried it with real hardware. Once I will be back from my vacation I can write detailed instruction how to do it (difficult to write long posts from phone :slight_smile:)

1 Like

Can someone help - how to disable “Swing” buttons - they are unreadable in HomeKit and making fault with “Turn Off” for me…
Want just leave the “Mode / Temp / Speed + Auto” options for homekit.

Has anyone managed to get the Haier air conditioning with hOn app / protocol working? I have the new version air conditioning where I got the wifi module. It says ESP32-For-Haier_V1.1
I haven’t done anything with it yet to keep it intact.

Now I have tried several haier.h’s which were in this forum on both ESP8266 and ESP32. All connected to Vin, GND, TX and RX ports.
But unfortunately I can’t get it to work yet.

I hope you guys can help and guide me

Have you tried mine? It was actually made for Esp for haier. ESP Haier: Haier Air Conditioner + ESP Home + Wemos D1 mini - #186 by paveldn

Yes I tried this on a Wemos D1 Mini, here I set the uart ports to 1 & 3.
This is UART0 on the Wemos.
I only see the messages that are trying to be sent.
Unfortunately I don’t get any feedback from the air conditioning.

This is the message what is sended:
[14:45:33][D][Haier:496]: Message sent: FF FF 0A 00 00 00 00 00 00 61 00 07 72

This is how my configuration file looks like:

esphome:
  name: woonkamer-airco

esp32:
  board: esp32dev
  framework:
    type: arduino

external_components:
  source:
    type: local
    path: ./src

# Enable logging
logger:
  level: DEBUG
  baud_rate: 0

uart:
  baud_rate: 9600
  tx_pin: 1
  rx_pin: 3
  id: ac_port  

# Enable Home Assistant API
api:
  encryption:
    key: 

ota:
  password: 

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Woonkamer-Airco Fallback Hotspot"
    password: !secret wifi_fallback_password

captive_portal:

climate:
  - platform: haier
    name: "Woonkamer - Airco" 
    uart_id: ac_port
    wifi_signal: true
    outdoor_temperature:        # Optional outdoor temperature sensor. Shows incorrect values when AC is not active for a long time
      name: "Buiten - Airco temperatuur"

Do you have an idea what else I could try or will it not work with a Wemos D1 mini?

I got it working.
I switched the cables to the same GPIO as in the project.
I don’t know why this made a difference, but the communication started working right away!
Thanks for the work

You are welcome. Glad it worked.