Modbus Intensis LG-RC-MBS-1 // ESP32 on HA

Hi there,

I need help to create the code to interact with my LG ducted system.

I currently have a Bail Industrie system controlling my LG air conditioning (UUD3 U30) with its indoor unit UM36F N20. I would like to replace this system with an ESP32 to integrate it into Home Assistant for controlling the heating with other thermostats and automated management. This system uses an RS485 module (Intesis LG-RC-MBS-1) that is connected to the LG bus. There is LG PREMTB100 / RS3 too that display infos and set parameters for the LG outdoor unit.

I have an ESP32-S3-6CH-RELAY (https://www.waveshare.com/wiki/ESP32-S3-Relay-6CH) which has relays (which will allow me to control my air vents) and also an RS485 interface on TX GPIO17 & RX GPIO18, allowing me to connect the Intesis module to it.

I am unable to figure out how to create this code in ESPHome, although I know it is possible. I have the register information for controlling and retrieving sensors from the module here: https://cdn.chipkin.com/assets/uploads/2018/feb/16-01-14-46_intesisbox_lg-rc-mbs-1_user_manual_en.pdf (pages 7, 8, 9).

Here is an idea of the code, but it doesn’t work :

esphome:
  name: lg_intesis_complete
  platform: esp32
  board: esp32-s3-devkitc-1

# UART for RS485
uart:
  tx_pin: GPIO17  # TX pin ESP32 board
  rx_pin: GPIO18  # RX pin  ESP32 board
  baud_rate: 9600
  parity: NONE
  stop_bits: 1

# Modbus RTU
modbus:
  id: modbus1

# On/Off Control
switch:
  - platform: modbus_controller
    modbus_id: modbus1
    name: "HVAC Power"
    address: 1
    register_type: holding
    register: 0  # Register for On/Off
    command_on_value: 1
    command_off_value: 0

# Mode selection (Auto, Heat, Cool, etc.)
select:
  - platform: modbus_controller
    modbus_id: modbus1
    name: "HVAC Mode"
    address: 1
    register_type: holding
    register: 1  # Register for the mode
    options:
      - "Auto"
      - "Heat"
      - "Cool"
      - "Fan"
      - "Dry"
# Fan speed selection with Lambda
  - platform: modbus_controller
    modbus_id: modbus1
    name: "Fan Speed"
    address: 1
    register_type: holding
    register: 2  # Register for fan speed
    options:
      - "Auto"
      - "Low"
      - "Medium"
      - "High"
    lambda: |-
      if (x == 0) return "Auto";
      if (x <= 2) return "Low";      // Positions 1 and 2
      if (x <= 5) return "Medium";   // Positions 3, 4, 5
      if (x <= 7) return "High";     // Positions 6 and 7
      return "Unknown";

# Temperature setting
number:
  - platform: modbus_controller
    modbus_id: modbus1
    name: "Set Temperature"
    address: 1
    register_type: holding
    register: 4  # Register for target temperature
    unit_of_measurement: "°C"
    min_value: 16
    max_value: 30
    step: 0.5


# Sensors for monitoring
sensor:
  # Room temperature
  - platform: modbus_controller
    modbus_id: modbus1
    name: "Room Temperature"
    address: 1
    register_type: input
    register: 5  # Register for room temperature
    unit_of_measurement: "°C"
    accuracy_decimals: 1
    filters:
      - multiply: 0.1  # Conversion from decicelsius -> celsius

  # Current setpoint temperature
  - platform: modbus_controller
    modbus_id: modbus1
    name: "Setpoint Temperature"
    address: 1
    register_type: input
    register: 4  # Register for target temperature
    unit_of_measurement: "°C"
    accuracy_decimals: 1
    filters:
      - multiply: 0.1

  # Compressor status
  - platform: modbus_controller
    modbus_id: modbus1
    name: "Compressor Status"
    address: 1
    register_type: input
    register: 53  # Register for compressor status
    filters:
      - lambda: |-
          if (x == 0) return "Off";
          if (x == 1) return "To Off";
          if (x == 2) return "To On";
          if (x == 3) return "On";
          return "Unknown";

# Binary sensor for alarms
binary_sensor:
  - platform: modbus_controller
    modbus_id: modbus1
    name: "HVAC Alarm"
    address: 1
    register_type: input
    register: 10  # Register for alarms
    filters:
      - lambda: |-
          return x == 1;  # Activated if an alarm is present

Can someone help me? Thank you very much.

I want to use climate to get this in HA but don’t know how to integrate it with modbus code :

image

Your code is missing modbus controller component.

Ok thanks I have added :

modbus_controller:
- id: modbus_device
  address: 0x1   ## address of the Modbus slave device on the bus
  modbus_id: modbus1
  setup_priority: -10

But I don’t know which value to set for setup_priority ?

Now I have errors here :

# On/Off Control
switch:
  - platform: modbus_controller
    modbus_controller_id: modbus1
    name: "HVAC Power"
    address: 1
    register_type: holding
    register: 0  # Register for On/Off
    command_on_value: 1
    command_off_value: 0

[register] is an invalid option for [switch.modbus_controller]. Did you mean [register_type]?

[command_on_value] is an invalid option for [switch.modbus_controller]. Did you mean [command_topic], [command_retain]?

Register 0 in decimal doesn’t exist.
May I suggest to remove all the number/select/switch from your yaml until you have successful communication with your devices input registers.

Is this good ? :

esphome:
  name: lg_intesis_complete
  platform: esp32
  board: esp32-s3-devkitc-1

# Enable logging
logger:
  level: INFO
  # level: DEBUG

# UART for RS485
uart:
  tx_pin: GPIO17  # TX pin ESP32 board
  rx_pin: GPIO18  # RX pin  ESP32 board
  baud_rate: 9600
  parity: NONE
  stop_bits: 1

# Modbus RTU
modbus:
  id: modbus1

modbus_controller:
- id: modbus_device
  address: 0x1   ## address of the Modbus slave device on the bus
  modbus_id: modbus1
  setup_priority: -10


# Switch for On/Off control
switch:
  - platform: modbus_controller
    modbus_controller_id: modbus_device
    name: "HVAC On/Off"
    id: hvac_on_off
    address: 0  # Protocol register address for On/Off
    register_type: holding
    write_lambda: |-
      if (state) {
        return 1;  // ON value
      } else {
        return 0;  // OFF value
      }

It’s opposite to my suggestion, so what can I answer?
Just leave few input registers like these:

Ignore previous post.
The protocol sheet you linked describes holding registers, not input!
Also there are several errors on you code…
Edit: it also describes 8N2 communication (8 data bits, no parity and 2 stop bit)
Try with this:

uart:
  id: uartx
  tx_pin: GPIO17  # TX pin ESP32 board
  rx_pin: GPIO18  # RX pin  ESP32 board
  baud_rate: 9600
  parity: NONE
  stop_bits: 2

modbus:
  id: modbus1
  uart_id: uartx

modbus_controller:
  - id: modbus_device
    address: 0x1   ## address of the Modbus slave device on the bus
    modbus_id: modbus1
    update_interval: 10s

sensor:
  - platform: modbus_controller
    modbus_controller_id: modbus_device
    name: "Fan Speed"
    id: fan_speed
    register_type: holding
    address: 0x0002
    value_type: U_WORD

I got :

[18:16:30][D][modbus_controller:040]: Modbus command to device=1 register=0x02 no response received - removed from send queue

But when my current system is connected to the Intesis module I received info :


[18:48:42][D][modbus_controller:040]: Modbus command to device=1 register=0x02 no response received - removed from send queue
[18:48:51][V][modbus_controller:232]: Updating modbus component
[18:48:51][V][modbus_controller:199]: Range : 2 Size: 1 (3) skip: 0
[18:48:51][V][modbus_controller:044]: Sending next modbus command to device 1 register 0x02 count 1
[18:48:51][V][modbus:223]: Modbus write: 01.03.00.02.00.01.25.CA (8)
[18:48:51][V][modbus_controller:569]: Command sent 3 0x2 1 send_count: 1
[18:48:51][V][modbus:035]: Clearing buffer of 1 bytes - timeout
[18:48:51][V][modbus:042]: Stop waiting for response from 1
[18:48:51][V][modbus_controller:044]: Sending next modbus command to device 1 register 0x02 count 1
[18:48:51][V][modbus:223]: Modbus write: 01.03.00.02.00.01.25.CA (8)
[18:48:51][V][modbus_controller:569]: Command sent 3 0x2 1 send_count: 2
[18:48:51][V][modbus:035]: Clearing buffer of 1 bytes - timeout
[18:48:51][V][modbus:042]: Stop waiting for response from 1
[18:48:51][V][modbus_controller:044]: Sending next modbus command to device 1 register 0x02 count 1
[18:48:51][V][modbus:223]: Modbus write: 01.03.00.02.00.01.25.CA (8)
[18:48:51][V][modbus_controller:569]: Command sent 3 0x2 1 send_count: 3
[18:48:51][V][modbus:035]: Clearing buffer of 1 bytes - timeout
[18:48:51][V][modbus:042]: Stop waiting for response from 1
[18:48:51][V][modbus_controller:044]: Sending next modbus command to device 1 register 0x02 count 1
[18:48:51][V][modbus:223]: Modbus write: 01.03.00.02.00.01.25.CA (8)
[18:48:51][V][modbus_controller:569]: Command sent 3 0x2 1 send_count: 4
[18:48:52][V][modbus:035]: Clearing buffer of 1 bytes - timeout
[18:48:52][V][modbus:042]: Stop waiting for response from 1
[18:48:52][V][modbus_controller:044]: Sending next modbus command to device 1 register 0x02 count 1
[18:48:52][V][modbus:223]: Modbus write: 01.03.00.02.00.01.25.CA (8)
[18:48:52][V][modbus_controller:569]: Command sent 3 0x2 1 send_count: 5
[18:48:52][V][modbus:035]: Clearing buffer of 1 bytes - timeout
[18:48:52][V][modbus:042]: Stop waiting for response from 1
[18:48:52][D][modbus_controller:040]: Modbus command to device=1 register=0x02 no response received - removed from send queue
[18:48:54][W][modbus:125]: Modbus CRC Check failed! 9255!=100
[18:48:54][V][modbus:026]: Clearing buffer of 8 bytes - parse failed
[18:48:54][W][modbus:125]: Modbus CRC Check failed! 3071!=00
[18:48:54][V][modbus:026]: Clearing buffer of 5 bytes - parse failed
[18:48:54][V][modbus:035]: Clearing buffer of 9 bytes - timeout
[18:48:54][W][modbus:125]: Modbus CRC Check failed! CDB1!=1003
[18:48:54][V][modbus:026]: Clearing buffer of 5 bytes - parse failed
[18:48:55][V][modbus:035]: Clearing buffer of 18 bytes - timeout
[18:48:55][W][modbus:125]: Modbus CRC Check failed! E291!=603
[18:48:55][V][modbus:026]: Clearing buffer of 5 bytes - parse failed
[18:48:55][V][modbus:035]: Clearing buffer of 8 bytes - timeout
[18:48:55][W][modbus:125]: Modbus CRC Check failed! DED8!=801
[18:48:55][V][modbus:026]: Clearing buffer of 8 bytes - parse failed
[18:48:55][V][modbus:035]: Clearing buffer of 2 bytes - timeout
[18:48:56][W][modbus:125]: Modbus CRC Check failed! 9255!=100
[18:48:56][V][modbus:026]: Clearing buffer of 8 bytes - parse failed
[18:48:56][W][modbus:125]: Modbus CRC Check failed! 3071!=00
[18:48:56][V][modbus:026]: Clearing buffer of 5 bytes - parse failed
[18:48:56][V][modbus:035]: Clearing buffer of 9 bytes - timeout
[18:48:56][W][modbus:125]: Modbus CRC Check failed! CDB1!=1003
[18:48:56][V][modbus:026]: Clearing buffer of 5 bytes - parse failed
[18:48:56][V][modbus:035]: Clearing buffer of 18 bytes - timeout
[18:48:57][W][modbus:125]: Modbus CRC Check failed! E291!=603
[18:48:57][V][modbus:026]: Clearing buffer of 5 bytes - parse failed
[18:48:57][V][modbus:035]: Clearing buffer of 8 bytes - timeout
[18:48:57][W][modbus:125]: Modbus CRC Check failed! DED8!=801
[18:48:57][V][modbus:026]: Clearing buffer of 8 bytes - parse failed
[18:48:57][V][modbus:035]: Clearing buffer of 2 bytes - timeout
[18:48:58][W][modbus:155]: Got Modbus frame from unknown address 0x20! 
[18:48:58][V][modbus:159]: Clearing buffer of 7 bytes - parse succeeded
[18:48:58][V][modbus:035]: Clearing buffer of 9 bytes - timeout
[18:48:58][W][modbus:155]: Got Modbus frame from unknown address 0x20! 
[18:48:58][V][modbus:159]: Clearing buffer of 7 bytes - parse succeeded
[18:48:59][V][modbus:035]: Clearing buffer of 9 bytes - timeout
[18:48:59][V][modbus:035]: Clearing buffer of 1 bytes - timeout
[18:49:00][V][modbus:035]: Clearing buffer of 4 bytes - timeout
[18:49:00][V][modbus:035]: Clearing buffer of 1 bytes - timeout
[18:49:01][V][modbus:035]: Clearing buffer of 1 bytes - timeout

It means that the Intesis module does not send data to ESP32?

What is “current system”??

The bail industrie at the left of the first picture

I’m not able to follow your description about your setup that seems to change between posts.
Your yaml on your OP had about 100 errors.
If you run the code I wrote, with your Esp device connected to IntensisBox A+ to A+ and B- to B-, what you get in your esphome log??

With your code and the ESP connected to the Intesis module I have :

[18:16:30][D][modbus_controller:040]: Modbus command to device=1 register=0x02 no response received - removed from send queue

Then you probably have bad wiring or wrong slave address/baud rate. Check the dip switches for address and baud and your wiring.

According to dip switches the address is 32 so 0x20. I have now :

[19:32:01][V][modbus_controller:232]: Updating modbus component
[19:32:01][V][modbus_controller:199]: Range : 2 Size: 1 (3) skip: 0
[19:32:01][V][modbus_controller:044]: Sending next modbus command to device 32 register 0x02 count 1
[19:32:01][V][modbus:223]: Modbus write: 20.03.00.02.00.01.23.7B (8)
[19:32:01][V][modbus_controller:569]: Command sent 3 0x2 1 send_count: 1
[19:32:01][V][modbus_controller:081]: Modbus response queued
[19:32:01][V][modbus:159]: Clearing buffer of 6 bytes - parse succeeded
[19:32:01][V][modbus_controller:089]: Process modbus response for address 0x2 size: 2
[19:32:01][V][modbus_controller:170]: data for register address : 0x2 : 
[19:32:01][D][modbus_controller.sensor:025]: Sensor new state: 3.00
[19:32:01][V][sensor:043]: 'Fan Speed': Received new state 3.000000
[19:32:01][D][sensor:094]: 'Fan Speed': Sending state 3.00000  with 0 decimals of accuracy
[19:32:01][V][modbus:035]: Clearing buffer of 4 bytes - timeout
[19:32:01][V][modbus:035]: Clearing buffer of 1 bytes - timeout
[19:32:02][V][modbus:035]: Clearing buffer of 1 bytes - timeout
[19:32:02][V][modbus:035]: Clearing buffer of 1 bytes - timeout
[19:32:03][V][modbus:035]: Clearing buffer of 4 bytes - timeout
[19:32:03][V][modbus:035]: Clearing buffer of 1 bytes - timeout
[19:32:04][V][modbus:035]: Clearing buffer of 1 bytes - timeout
[19:32:04][W][modbus:125]: Modbus CRC Check failed! 9255!=100
[19:32:04][V][modbus:026]: Clearing buffer of 8 bytes - parse failed

So 3 for the fan speed, guess that communication works now. Given that my initial code is incorrect, how can I fix it to control the system using the register values provided in the documentation? Thanks for the help

Repeat the sensor code for other addresses you have on your protocol sheet.

but what is this?

I don’t know, maybe it’s the other system (bail industrie) that sent data?

Ahh, you have that connected… Modbus RTU can have only one master, so you need to disconnect it…

Yeah I will remove it :slight_smile:

So in example, to power on/off the AC, is this code good ? :

switch:
  - platform: modbus_controller
    modbus_controller_id: modbus_device
    name: "Turn AC On/Off"
    id: turn_ac_on_off
    register_type: holding
    address: 0x0000
    lambda: |-
      if (x) {
        return 1;  // Turn ON
      } else {
        return 0;  // Turn OFF
      }

Try.
I haven’t tried switch with holding registers. Might work even without that lamda, or might need some tuning.
Observe what you get on log.