LG AC Wired Controller integration via ESPHome/ESP32

I rechecked the yaml file, I missed the replace the device id in one of the lines, now it’s uploaded successfully, I will install the controller in the vrf indoor units in the weekend to test it, i will inform you of the result

Thanks again.

Out of curiousity does anyone have pictures on how to install these? I have 2 floor units (uq09f) - they were just put in operation today and came to the conclusion they don’t have WiFi…so really keen to try this alternative!

Hi,

I got this error while trying to upload the yaml file to the microcontroller

INFO ESPHome 2023.12.7
INFO Reading configuration /config/esphome/lg-wired-remote.yaml...
INFO Generating C++ source...
INFO Compiling app...
Processing lg-wired-remote (board: esp32dev; framework: arduino; platform: platformio/[email protected])
--------------------------------------------------------------------------------
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
 - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
Dependency Graph
|-- AsyncTCP-esphome @ 2.0.1
|-- WiFi @ 2.0.0
|-- FS @ 2.0.0
|-- Update @ 2.0.0
|-- ESPAsyncWebServer-esphome @ 3.1.0
|-- DNSServer @ 2.0.0
|-- ESPmDNS @ 2.0.0
|-- noise-c @ 0.1.4
Compiling .pioenvs/lg-wired-remote/src/main.cpp.o
Compiling .pioenvs/lg-wired-remote/lib64d/WiFi/WiFiSTA.cpp.o
Compiling .pioenvs/lg-wired-remote/lib64d/WiFi/WiFiScan.cpp.o
<unicode string>: In lambda function:
<unicode string>:45:16: error: 'LgController' was not declared in this scope
<unicode string>:45:16: note: suggested alternative: 'isControl'
<unicode string>:45:29: error: expected primary-expression before ')' token
<unicode string>:45:30: error: expected ')' before 'id'
<unicode string>: In lambda function:
<unicode string>:57:16: error: 'LgController' was not declared in this scope
<unicode string>:57:16: note: suggested alternative: 'isControl'
<unicode string>:57:29: error: expected primary-expression before ')' token
<unicode string>:57:30: error: expected ')' before 'id'
<unicode string>: In lambda function:
<unicode string>:66:16: error: 'LgController' was not declared in this scope
<unicode string>:66:16: note: suggested alternative: 'isControl'
<unicode string>:66:29: error: expected primary-expression before ')' token
<unicode string>:66:30: error: expected ')' before 'id'
<unicode string>: In lambda function:
<unicode string>:87:9: error: 'LgController' was not declared in this scope
<unicode string>:87:9: note: suggested alternative: 'isControl'
<unicode string>:87:22: error: expected primary-expression before ')' token
<unicode string>:87:23: error: expected ')' before 'id'
<unicode string>: In lambda function:
<unicode string>:103:9: error: 'LgController' was not declared in this scope
<unicode string>:103:9: note: suggested alternative: 'isControl'
<unicode string>:103:22: error: expected primary-expression before ')' token
<unicode string>:103:23: error: expected ')' before 'id'
<unicode string>: In lambda function:
<unicode string>:119:9: error: 'LgController' was not declared in this scope
<unicode string>:119:9: note: suggested alternative: 'isControl'
<unicode string>:119:22: error: expected primary-expression before ')' token
<unicode string>:119:23: error: expected ')' before 'id'
<unicode string>: In lambda function:
<unicode string>:135:9: error: 'LgController' was not declared in this scope
<unicode string>:135:9: note: suggested alternative: 'isControl'
<unicode string>:135:22: error: expected primary-expression before ')' token
<unicode string>:135:23: error: expected ')' before 'id'
<unicode string>: In lambda function:
<unicode string>:149:9: error: 'LgController' was not declared in this scope
<unicode string>:149:9: note: suggested alternative: 'isControl'
<unicode string>:149:22: error: expected primary-expression before ')' token
<unicode string>:149:23: error: expected ')' before 'id'
<unicode string>: In lambda function:
<unicode string>:164:9: error: 'LgController' was not declared in this scope
<unicode string>:164:9: note: suggested alternative: 'isControl'
<unicode string>:164:22: error: expected primary-expression before ')' token
<unicode string>:164:23: error: expected ')' before 'id'
<unicode string>: In lambda function:
<unicode string>:177:9: error: 'LgController' was not declared in this scope
<unicode string>:177:9: note: suggested alternative: 'isControl'
<unicode string>:177:22: error: expected primary-expression before ')' token
<unicode string>:177:23: error: expected ')' before 'id'
<unicode string>: In lambda function:
<unicode string>:190:9: error: 'LgController' was not declared in this scope
<unicode string>:190:9: note: suggested alternative: 'isControl'
<unicode string>:190:22: error: expected primary-expression before ')' token
<unicode string>:190:23: error: expected ')' before 'id'
<unicode string>: In lambda function:
<unicode string>:203:9: error: 'LgController' was not declared in this scope
<unicode string>:203:9: note: suggested alternative: 'isControl'
<unicode string>:203:22: error: expected primary-expression before ')' token
<unicode string>:203:23: error: expected ')' before 'id'
<unicode string>: In lambda function:
<unicode string>:217:9: error: 'LgController' was not declared in this scope
<unicode string>:217:9: note: suggested alternative: 'isControl'
<unicode string>:217:22: error: expected primary-expression before ')' token
<unicode string>:217:23: error: expected ')' before 'id'
<unicode string>: In lambda function:
<unicode string>:222:30: error: expected type-specifier before 'LgController'
<unicode string>:229:25: error: could not convert '{controller}' from '<brace-enclosed initializer list>' to 'std::vector<esphome::climate::Climate*>'
Compiling .pioenvs/lg-wired-remote/lib64d/WiFi/WiFiServer.cpp.o
*** [.pioenvs/lg-wired-remote/src/main.cpp.o] Error 1

this is my configuration.yaml

esphome:
  name: lg-wired-remote
  friendly_name: lg wired remote

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "8PShZ4rDya4CVnprSN0MCkjldPqc3TtBI0iaOmdKsOc="

ota:
  password: "d4e17f4ade94d1e8bffe75d116f57c46"

wifi:
  ssid: "homewifi"
  password: "24354e6tr"

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Lg-Wired-Remote Fallback Hotspot"
    password: "Cw5vXjj33J5C"

captive_portal:
    
uart:
  - id: ac_serial
    tx_pin: GPIO25
    rx_pin: GPIO26 # Keep in sync with RxPin in lg-controller.h
    baud_rate: 104

sensor:
  - id: temperature_sensor
    platform: homeassistant
    internal: true
    entity_id: sensor.outdoor_temp
  - platform: custom
    lambda: |-
      return ((LgController*)id(lg-wired-remote))->get_sensors();
    sensors:
      - name: Error Code
      - name: Pipe Temperature In
      - name: Pipe Temperature Mid
      - name: Pipe Temperature Out
  - platform: uptime
    name: Uptime

binary_sensor:
  - platform: custom
    lambda: |-
      return ((LgController*)id(lg-wired-remote))->get_binary_sensors();
    binary_sensors:
      - name: Defrost
      - name: Preheat
      - name: Outdoor Unit

switch:
  - platform: custom
    lambda: |-
      return ((LgController*)id(lg-wired-remote))->get_switches();
    switches:
      - name: Air Purifier
      - name: Internal Thermistor

select:
  - platform: template
    name: Airflow 1 Up/Down
    id: vane_position_1
    optimistic: true
    icon: mdi:arrow-up-down
    options:
      - "0 (Default)"
      - "1 (Up)"
      - "2"
      - "3"
      - "4"
      - "5"
      - "6 (Down)"
    on_value:
      - lambda: |-
          ((LgController*)id(lg-wired-remote))->set_vane_position(1, i);
  - platform: template
    name: Airflow 2 Up/Down
    id: vane_position_2
    optimistic: true
    icon: mdi:arrow-up-down
    options:
      - "0 (Default)"
      - "1 (Up)"
      - "2"
      - "3"
      - "4"
      - "5"
      - "6 (Down)"
    on_value:
      - lambda: |-
          ((LgController*)id(lg-wired-remote))->set_vane_position(2, i);
  - platform: template
    name: Airflow 3 Up/Down
    id: vane_position_3
    optimistic: true
    icon: mdi:arrow-up-down
    options:
      - "0 (Default)"
      - "1 (Up)"
      - "2"
      - "3"
      - "4"
      - "5"
      - "6 (Down)"
    on_value:
      - lambda: |-
          ((LgController*)id(lg-wired-remote))->set_vane_position(3, i);
  - platform: template
    name: Airflow 4 Up/Down
    id: vane_position_4
    optimistic: true
    icon: mdi:arrow-up-down
    options:
      - "0 (Default)"
      - "1 (Up)"
      - "2"
      - "3"
      - "4"
      - "5"
      - "6 (Down)"
    on_value:
      - lambda: |-
          ((LgController*)id(lg-wired-remote))->set_vane_position(4, i);
  - platform: template
    name: Over Heating # Installer setting 15.
    id: overheating
    optimistic: true
    icon: mdi:heating-coil
    options:
      - "0 (Default)"
      - "1 (+4C/+6C)"
      - "2 (+2C/+4C)"
      - "3 (-1C/+1C)"
      - "4 (-0.5C/+0.5C)"
    on_value:
      - lambda: |-
          ((LgController*)id(lg-wired-remote))->set_overheating(i);

number:
  - platform: template
    name: "Fan Speed Slow"
    id: fan_speed_slow
    optimistic: true
    icon: mdi:fan-chevron-down
    mode: box
    min_value: 0
    max_value: 255
    step: 1
    on_value:
      then:
        - lambda: |-
            ((LgController*)id(lg-wired-remote))->set_fan_speed(0, x);    
  - platform: template
    name: "Fan Speed Low"
    id: fan_speed_low
    optimistic: true
    icon: mdi:fan-speed-1
    mode: box
    min_value: 0
    max_value: 255
    step: 1
    on_value:
      then:
        - lambda: |-
            ((LgController*)id(lg-wired-remote))->set_fan_speed(1, x);    
  - platform: template
    name: "Fan Speed Medium"
    id: fan_speed_medium
    optimistic: true
    icon: mdi:fan-speed-2
    mode: box
    min_value: 0
    max_value: 255
    step: 1
    on_value:
      then:
        - lambda: |-
            ((LgController*)id(lg-wired-remote))->set_fan_speed(2, x);    
  - platform: template
    name: "Fan Speed High"
    id: fan_speed_high
    optimistic: true
    icon: mdi:fan-speed-3
    mode: box
    min_value: 0
    max_value: 255
    step: 1
    on_value:
      then:
        - lambda: |-
            ((LgController*)id(lg-wired-remote))->set_fan_speed(3, x);    
  - platform: template
    name: "Sleep Timer (minutes)"
    id: sleep_timer
    optimistic: true
    icon: mdi:timer-outline
    mode: box
    min_value: 0
    max_value: 420
    initial_value: 0
    step: 1
    on_value:
      then:
        - lambda: |-
            ((LgController*)id(lg-wired-remote))->set_sleep_timer(x);

climate:
  - platform: custom
    lambda: |-
      auto* controller = new LgController(id(ac_serial), id(temperature_sensor), 
                                id(vane_position_1), id(vane_position_2), id(vane_position_3), id(vane_position_4),
                                id(overheating),
                                id(fan_speed_slow), id(fan_speed_low), id(fan_speed_medium), id(fan_speed_high),
                                id(sleep_timer)
                              );
      App.register_component(controller);
      return {controller};
    climates:
      - name: "Lg Livingroom"
        id: livingroom_vrf

I got this error while trying to upload the yaml file to the microcontroller

It’s because you’re missing the line in base.yaml that includes lg-controller.h. You need that lg-controller.h file because it’s where most of the code is.

Please follow the instructions and only change the lines I marked with XXX comments without adding/removing other things.

1 Like

Thanks for the quick response,

Frankly as a beginner it’s kind of confusing, I have 8 esphome device and i know the basic but i could not install the device successfully, the instructions not so clear, i think if you put all the codes in one file will be easier for ppl with poor coding skills like me :slightly_smiling_face:

That’s because this is not part of the standard Esphome software suite. Its an external component.

I fixed the issue, this my first esphome device with external components, I didn’t know I had to create the lg-controller.h file in my config, for this reason I was got an error when I add the - lg_controller.h line, I did not connect the board to the A/C unit yet, I will install it tomorrow to test it with LG PREMTA200 controller

I made some changes to add support for multiple controllers and Fahrenheit.

The LG PREMTB controllers can be configured as ‘slave’ controller and can then be added.

I think the PREMTA200 doesn’t support this and is always master, so in this case the ESPHome controller has to be set to ‘slave’ in the YAML file. In this mode the LG controller determines the room temperature, but settings can still be changed by ESPHome.

I haven’t done a lot of testing so it may not work as well as a single controller.

Can you post here a photo/video how to reach CN-REMO port on S12ET indoor unit?

I have 4 of them do connect :slight_smile:

1 Like

Hi,

I was desperately searching a solution to automating my LG split for several month. The LG website is a mess and I was unable to find if it is compatible with any remote or WIFI card…

I was reaching the point to try to automate it via a fake infrared remote with an ESP32 when I found this integration !
So I dismounted my internal unit to get access to the PCB and to my surprise, there is definitively a CN-REMO green connector in it !!!

I just ordered some PCB and will let you know if it does work for me ASAP, can’t wait !!!

My internal LG unit is S09EQ.NSJ

LG indoor units seems pretty standard :
TURN OFF THE MAIN POWER !!!
then :
1 remove the underside plastic
2 there is 2 screws on the front left and right to remove
3 remove the rest of the housing
this link may help you :
https://www.youtube.com/watch?v=x6uadBphdz8

4 there is a metal case on the right of the unit
5 remove the metal screw on the top right front corner (it is under a metallic tape)
6 carefully remove the right metal panel. It is also glued with metallic tape on the top
The main PCB is there !

1 Like

It does work with my unit :slight_smile: LG S09EQ

Thank you so much!!!

1 Like

Hey, I am getting the f09mt(prestige) unit installed next week and was looking into ways of integrating it with HA. I don’t wanna rely on the cloud for this, so I wanted to understand more about this method. My unit has wifi so I assume I would have to unplug the wifi module and plug this one instead? Do you guys have some pics of where it connects on your units? I know it’s different from unit to unit, just want some references to know what to look for. Hopefully not too much disassembly is involved. Thanks!

Edit: after a quick search I found a catalog from LG - they show my unit under the Athena extreme name and according to the accessories section, it should work with a wired remote controller, so maybe compatible with this integration, right?

@JanM321 Thanks for this integration!
I was lucky and my internal unit had a JST-XH connector removed and I had an electronics technician make my board. Everything works perfectly!!!
Now on the remote control I have ENERGY CONTR with 80% and 60% which helps me with the current consumption. Can this energy counter be integrated?
Thank you very much.



Nice! :slight_smile:

Unfortunately I don’t think LG wired controllers support this option, but I’d need the log file of the ESPHome controller to determine this. So start the logging with esphome logs .., then use the wireless remote to change this setting to 60%, 80% etc and then post the log file somewhere.

Here you find the log dpaste/YizJE (Python)

The unit doesn’t send the energy control changes to the controller. Some messages have the “settings changed” bit set, but don’t have any changed settings. The LG controllers I have reverse-engineered don’t support these energy control settings so it’s most likely not supported by the protocol. I’ve seen the same thing with other settings.

LG units support multiple controllers (IR, Wifi, wired) but they all have a different set of features. It’s unfortunate and means we can’t support all features the units have.

1 Like

I’m in the same boat (having to solder the CN_REMO connector) and am a bit afraid of taking the whole Pcb out to do that; also skeptical of if it behaves like the ones that come pre-soldered.

Using the CN_LINK would be a great addition to what is an already amazing project!
Have you, by any chance, given this connector a try?

Has anyone used this in ‘slave’ mode yet? Are the pins ‘just’ shared with both controllers (12v, GND, Signal?).

Someone from Germany interested in a tiny pcb? Would sell some of mine I had to order on top of my personal requirement.