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

Hi! This is my first aportation to the community.

I bought a Haier Air Conditioner with wifi support by a usb module, but, instead of buy a wifi module, I made one with a wemos d1 mini and ESP Home, so, I get Home Assistant integration.

You can get the c++ code, .yalm file and “the circuit” in my GitHub

4 Likes

Excellent work. There is a similar project for Mitsubishi heat pumps. https://github.com/SwiCago/HeatPump

In your readme, "wodule"should be “module” - a simple typo I expect.

1 Like

Nice! Could you please explain a bit more of the process?
Thanks

Hi @diego06

You need a Wemos D1 Mini o other esp module.

image

You need cut a USB cable and connect it

image

  • Red -> 5V
  • Black -> GND
  • Green -> RX
  • White -> TX

Finnally, you use the code of my github and flash it with ESPHome, and connected the usb in the usb module connection of Haier internal console.

Hi, very nice work! :+1:
I have one of the 2 haier airco’s connected and is working fine.

image

Is there a way that you can add a sensor so that i can add only the current temperature to a graph? I’m not that good in programming.

1 Like

You can use a template sensor to get only the temperature from climate.

  - platform: template
    sensors:
      estudio_temperatura:
        friendly_name: "Temperatura estudio"
        value_template: "{{ state_attr('climate.haier_estudio', 'current_temperature') }}"
        device_class: temperature

1 Like

Thanks! It is working. I had to add unitit_of_measurement variable to get the historical graph showing it the right way.


- platform: template
  sensors:
    haier1_current_temp:
      friendly_name: "Current Room Temperature Bedroom 1"
      unit_of_measurement: '°C'
      value_template: "{{ state_attr('climate.haier1', 'current_temperature') }}"
    haier2_current_temp:
      friendly_name: "Current Room Temperature Bedroom 2"
      unit_of_measurement: '°C'
      value_template: "{{ state_attr('climate.haier2', 'current_temperature') }}" 

image

1 Like

I’m glad to hear that.

Enjoy your haier :wink:

thanks a lot… I am still waiting for the installation of the aircon but I will try as soon as I have the system ready!
Using your system it will not work anymore with the app, correct?

Not, the app will not works. Only Home Assistant.

Awesome, but fan speed would be nice, dont want to blow cold air in my cat’s face when we’re away :smiley:

Yes, I know it. I am waiting for ESPHome support for Fan Speed

hi, i have problem compiling the code.
i get this

C:\esphaier-master>esphome esphaier.yaml run
e[32mINFO Reading configuration esphaier.yaml...e[0m
e[32mINFO Generating C++ source...e[0m
e[32mINFO Compiling app...e[0m
e[32mINFO Running:  platformio run -d haiere[0m
Processing haier (board: d1_mini; framework: arduino; platform: [email protected])
------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif8266/d1_mini.html
PLATFORM: Espressif 8266 2.2.3 > WeMos D1 R2 and mini
HARDWARE: ESP8266 80MHz, 80KB RAM, 4MB Flash
PACKAGES: toolchain-xtensa 1.40802.0 (4.8.2), framework-arduinoespressif8266 2.20502.0 (2.5.2), tool-esptool 1.409.0 (4.9), tool-esptoolpy 1.20600.0 (2.6.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Looking for Update library in registry
Warning! Library `{'name': 'Update', 'requirements': None}` has not been found in PlatformIO Registry.
You can ignore this message, if `{'name': 'Update', 'requirements': None}` is a built-in library (included in framework, SDK). E.g., SPI, Wire, etc.
Found 29 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <ESPAsyncTCP-esphome> 1.2.2
|   |-- <ESP8266WiFi> 1.0
|-- <ESP8266WiFi> 1.0
|-- <ESP8266mDNS> 1.2
|   |-- <ESP8266WiFi> 1.0
Compiling .pioenvs\haier\src\main.cpp.o
In file included from src\main.cpp:12:0:
src\Haier.h: In member function 'void Haier::readData()':
src\Haier.h:147:20: error: reference to 'CLIMATE_MODE_OFF' is ambiguous
             mode = CLIMATE_MODE_OFF;
                    ^
In file included from src\esphome/components/api/api_connection.h:5:0,
                 from src\esphome.h:2,
                 from src\main.cpp:3:
src\esphome/components/api/api_pb2.h:47:3: note: candidates are: esphome::api::EnumClimateMode CLIMATE_MODE_OFF
   CLIMATE_MODE_OFF = 0,
   ^
In file included from src/esphome/components/climate/climate.h:6:0,
                 from src/esphome/core/application.h:27,
                 from src\esphome/components/api/api_connection.h:4,
                 from src\esphome.h:2,
                 from src\main.cpp:3:
src/esphome/components/climate/climate_mode.h:11:3: note:                 esphome::climate::ClimateMode CLIMATE_MODE_OFF
   CLIMATE_MODE_OFF = 0,
   ^
In file included from src\main.cpp:12:0:
src\Haier.h:153:28: error: reference to 'CLIMATE_MODE_COOL' is ambiguous
                     mode = CLIMATE_MODE_COOL;
                            ^
In file included from src\esphome/components/api/api_connection.h:5:0,
                 from src\esphome.h:2,
                 from src\main.cpp:3:
src\esphome/components/api/api_pb2.h:49:3: note: candidates are: esphome::api::EnumClimateMode CLIMATE_MODE_COOL
   CLIMATE_MODE_COOL = 2,
   ^
In file included from src/esphome/components/climate/climate.h:6:0,
                 from src/esphome/core/application.h:27,
                 from src\esphome/components/api/api_connection.h:4,
                 from src\esphome.h:2,
                 from src\main.cpp:3:
src/esphome/components/climate/climate_mode.h:15:3: note:                 esphome::climate::ClimateMode CLIMATE_MODE_COOL
   CLIMATE_MODE_COOL = 2,
   ^
In file included from src\main.cpp:12:0:
src\Haier.h:156:28: error: reference to 'CLIMATE_MODE_HEAT' is ambiguous
                     mode = CLIMATE_MODE_HEAT;
                            ^
In file included from src\esphome/components/api/api_connection.h:5:0,
                 from src\esphome.h:2,
                 from src\main.cpp:3:
src\esphome/components/api/api_pb2.h:50:3: note: candidates are: esphome::api::EnumClimateMode CLIMATE_MODE_HEAT
   CLIMATE_MODE_HEAT = 3,
   ^
In file included from src/esphome/components/climate/climate.h:6:0,
                 from src/esphome/core/application.h:27,
                 from src\esphome/components/api/api_connection.h:4,
                 from src\esphome.h:2,
                 from src\main.cpp:3:
src/esphome/components/climate/climate_mode.h:17:3: note:                 esphome::climate::ClimateMode CLIMATE_MODE_HEAT
   CLIMATE_MODE_HEAT = 3,
   ^
In file included from src\main.cpp:12:0:
src\Haier.h:159:28: error: reference to 'CLIMATE_MODE_AUTO' is ambiguous
                     mode = CLIMATE_MODE_AUTO;
                            ^
In file included from src\esphome/components/api/api_connection.h:5:0,
                 from src\esphome.h:2,
                 from src\main.cpp:3:
src\esphome/components/api/api_pb2.h:48:3: note: candidates are: esphome::api::EnumClimateMode CLIMATE_MODE_AUTO
   CLIMATE_MODE_AUTO = 1,
   ^
In file included from src/esphome/components/climate/climate.h:6:0,
                 from src/esphome/core/application.h:27,
                 from src\esphome/components/api/api_connection.h:4,
                 from src\esphome.h:2,
                 from src\main.cpp:3:
src/esphome/components/climate/climate_mode.h:13:3: note:                 esphome::climate::ClimateMode CLIMATE_MODE_AUTO
   CLIMATE_MODE_AUTO = 1,
   ^
In file included from src\main.cpp:12:0:
src\Haier.h: In member function 'virtual void Haier::control(const esphome::climate::ClimateCall&)':
src\Haier.h:177:22: error: reference to 'CLIMATE_MODE_AUTO' is ambiguous
                 case CLIMATE_MODE_AUTO:
                      ^
In file included from src\esphome/components/api/api_connection.h:5:0,
                 from src\esphome.h:2,
                 from src\main.cpp:3:
src\esphome/components/api/api_pb2.h:48:3: note: candidates are: esphome::api::EnumClimateMode CLIMATE_MODE_AUTO
   CLIMATE_MODE_AUTO = 1,
   ^
In file included from src/esphome/components/climate/climate.h:6:0,
                 from src/esphome/core/application.h:27,
                 from src\esphome/components/api/api_connection.h:4,
                 from src\esphome.h:2,
                 from src\main.cpp:3:
src/esphome/components/climate/climate_mode.h:13:3: note:                 esphome::climate::ClimateMode CLIMATE_MODE_AUTO
   CLIMATE_MODE_AUTO = 1,
   ^
In file included from src\main.cpp:12:0:
src\Haier.h:181:22: error: reference to 'CLIMATE_MODE_HEAT' is ambiguous
                 case CLIMATE_MODE_HEAT:
                      ^
In file included from src\esphome/components/api/api_connection.h:5:0,
                 from src\esphome.h:2,
                 from src\main.cpp:3:
src\esphome/components/api/api_pb2.h:50:3: note: candidates are: esphome::api::EnumClimateMode CLIMATE_MODE_HEAT
   CLIMATE_MODE_HEAT = 3,
   ^
In file included from src/esphome/components/climate/climate.h:6:0,
                 from src/esphome/core/application.h:27,
                 from src\esphome/components/api/api_connection.h:4,
                 from src\esphome.h:2,
                 from src\main.cpp:3:
src/esphome/components/climate/climate_mode.h:17:3: note:                 esphome::climate::ClimateMode CLIMATE_MODE_HEAT
   CLIMATE_MODE_HEAT = 3,
   ^
In file included from src\main.cpp:12:0:
src\Haier.h:185:22: error: reference to 'CLIMATE_MODE_COOL' is ambiguous
                 case CLIMATE_MODE_COOL:
                      ^
In file included from src\esphome/components/api/api_connection.h:5:0,
                 from src\esphome.h:2,
                 from src\main.cpp:3:
src\esphome/components/api/api_pb2.h:49:3: note: candidates are: esphome::api::EnumClimateMode CLIMATE_MODE_COOL
   CLIMATE_MODE_COOL = 2,
   ^
In file included from src/esphome/components/climate/climate.h:6:0,
                 from src/esphome/core/application.h:27,
                 from src\esphome/components/api/api_connection.h:4,
                 from src\esphome.h:2,
                 from src\main.cpp:3:
src/esphome/components/climate/climate_mode.h:15:3: note:                 esphome::climate::ClimateMode CLIMATE_MODE_COOL
   CLIMATE_MODE_COOL = 2,
   ^
In file included from src\main.cpp:12:0:
src\Haier.h:173:20: warning: enumeration value 'CLIMATE_MODE_OFF' not handled in switch [-Wswitch]
             switch (call.get_mode().value()) {
                    ^
src\Haier.h:173:20: warning: enumeration value 'CLIMATE_MODE_AUTO' not handled in switch [-Wswitch]
src\Haier.h:173:20: warning: enumeration value 'CLIMATE_MODE_COOL' not handled in switch [-Wswitch]
src\Haier.h:173:20: warning: enumeration value 'CLIMATE_MODE_HEAT' not handled in switch [-Wswitch]
Compiling .pioenvs\haier\FrameworkArduino\time.cpp.o
Compiling .pioenvs\haier\FrameworkArduino\uart.cpp.o
Compiling .pioenvs\haier\FrameworkArduino\umm_malloc\umm_malloc.cpp.o
*** [.pioenvs\haier\src\main.cpp.o] Error 1
============================================== [FAILED] Took 2.12 seconds ==============================================

C:\esphaier-master>

Could you tell me why?

Thank you

Paolo

Jums… It look like that you include two times the file.

Can you paste the yalm file?

esphome:
  name: haier
  platform: ESP8266
  board: d1_mini
  includes:
    - Haier.h


logger:
  level: DEBUG
  baud_rate: 0 #Important. You can't use serial port
  
  
wifi:
  ssid: "PAOLO_AZZU_CASA"
  password: "abcdefghi"


# Enable Home Assistant API
api:
  password: "abcdefghi"

ota:
  password: "abcdefghi"



  
  
climate:
  - platform: custom
    lambda: |-
      auto haier = new Haier();
      App.register_component(haier);
      return {haier};
    climates:
      - name: "Haier"

i run the command
esphome esphaier.yaml run
from the directory
C:\esphaier-master\

Good news! I’ve re-installed esphome, now it works fine!
Thank you

1 Like

Hello guys I did correctly connected my AC with Hassio and all are working excellent except that I can never know when my AC is ON or OFF. Its always shows the mode of the AC before becomes off. It shows that is OFF rarely and randomly. Please is very important for me to know when is ON or OFF when I am away.
I have attached some screenshots that may help.

I don’t understand.

Do you can show the status in Home Assistant?

In your screenshot show “mode: HEAT”, so, it is on. If the current is 19 and the tarjet is 30 and the mode is heat, the AC must heat the room…

No the AC actually is OFF but the mode in logs of ESPHOME shows that is ON and HEAT.
Due to this I can never be sure when the AC is ON or OFF.

For example as we speak now became Off randomly :confused: