Interface Home battery Blauhoff or Ecactus via esphome and modbus

Dear community,
I am testing a home battery which has a rs485 / modbus connection. Atm i am able to read values like soc, pv power etc via a esp32 and rs485 converter. But i am not able to create any kind of switch to change settings. Could someone help me please?

update: i am able to take local control of the BMS, read values and push settings. I hope it helps someone
Tested on Blauhoff all in one home battery probably ecactus all in one and copia work as well (not tested)

1 Like

Glad you found something to interface between the two. You should plan a trip to Las Vegas and see if your luck stays with you. This may or may not be the case for you but, its surprisingly common to see people go drop 100’s of dollars or more for some device and only after they have it in hand do they do any due diligence on integrating the thing with HA or esphome. Its nice to have the capabilites but, most modern BMS wiill manage the batteries automatically based on those initial settings so, I suspect that once you do the initial setup you probably wont find much of a need to actively change settings in HA.

Thanks for your reply, i think i skip vegas :grinning:
You are right that this should be standard. However, I live in the Netherlands where dynamic energy rates are available (price per hour). The app provided with the home battery cannot now handle that. But it is possible in HA. In addition, local control is now an option. And not unimportantly, it was an educational project.

Aahh, yes you have a point there. I actually keep forgetting there is a large swath of people who are punished with higher energy prices depending on the time of day they need it. That isnt really a thing here in the USA to my knowledge. Unfortunately the wise leadership here in the Home of the Brave and Land of Bad ideas. Theyd just rather not burden us with the choice, so they’re trying to make the case for a " smart grid" where the government or Utility companies can send “kill signals” to individual homes or regionally and shut off peoples heating/A/C, water heaters, or any devices that they wany to be able to controm.

Almost 100 years ago we split the atom and harnessed the power of the sun. Over 50 years ago we sent men to the moon and brought them back safely. In 2023 we are in a race to having the most expensive energy insecure economies by phasing out 50% cleaner base load power plants for intermittent and more expensive sources of energy. Whats brilliant about it and on the level of splitting the atom is how thoroughly they’ve exploited the natural fear of death each of us has.

Dear Driesk,
Just followed your procedure on an ecactus all-in-one, works like a charm. A big thank you !!!

As I got 2 PV array connected to the all-in-one, I made a little modification on the yml config file of the esp32 by try and error.
How did you get the addresses of the BMS values? I would like to try to add other infos for fun :wink:

1 Like

I have all running on an eCactus, but communication over modbus doesn’t go well…
Any ideas?
Log:

INFO ESPHome 2024.6.6
INFO Reading configuration /config/esphome/thuisaccu.yaml...
INFO Starting log output from 192.168.1.2 using esphome API
INFO Successfully connected to thuisaccu @ 192.168.1.2 in 0.035s
INFO Successful handshake with thuisaccu @ 192.168.1.2 in 0.099s
[12:15:40][I][app:100]: ESPHome version 2024.6.6 compiled on Jul 14 2024, 11:25:50
[12:15:40][C][wifi:599]: WiFi:
[12:15:40][C][wifi:427]:   Local MAC: xx:xx:xx:xx:xx:xx
[12:15:40][C][wifi:432]:   SSID: [redacted]
[12:15:40][C][wifi:435]:   IP Address: 192.168.1.2
[12:15:40][C][wifi:439]:   BSSID: [redacted]
[12:15:40][C][wifi:440]:   Hostname: 'thuisaccu'
[12:15:40][C][wifi:442]:   Signal strength: -61 dB ▂▄▆█
[12:15:40][C][wifi:446]:   Channel: 11
[12:15:40][C][wifi:447]:   Subnet: 255.255.255.0
[12:15:40][C][wifi:448]:   Gateway: 192.168.1.1
[12:15:40][C][wifi:449]:   DNS1: 0.0.0.0
[12:15:40][C][wifi:450]:   DNS2: 0.0.0.0
[12:15:40][C][logger:185]: Logger:
[12:15:40][C][logger:186]:   Level: DEBUG
[12:15:40][C][logger:188]:   Log Baud Rate: 115200
[12:15:40][C][logger:189]:   Hardware UART: UART0
[12:15:40][C][uart.arduino_esp32:137]: UART Bus 1:
[12:15:40][C][uart.arduino_esp32:138]:   TX Pin: GPIO17
[12:15:40][C][uart.arduino_esp32:139]:   RX Pin: GPIO16
[12:15:40][C][uart.arduino_esp32:141]:   RX Buffer Size: 256
[12:15:40][C][uart.arduino_esp32:143]:   Baud Rate: 115200 baud
[12:15:40][C][uart.arduino_esp32:144]:   Data Bits: 8
[12:15:40][C][uart.arduino_esp32:145]:   Parity: NONE
[12:15:40][C][uart.arduino_esp32:146]:   Stop bits: 1
[12:15:40][C][modbus:152]: Modbus:
[12:15:40][C][modbus:154]:   Send Wait Time: 250 ms
[12:15:40][C][modbus:155]:   CRC Disabled: NO
[12:15:40][C][template.sensor:022]: Template Sensor 'Home power'
[12:15:40][C][template.sensor:022]:   State Class: ''
[12:15:40][C][template.sensor:022]:   Unit of Measurement: 'W'
[12:15:40][C][template.sensor:022]:   Accuracy Decimals: 0
[12:15:41][C][template.sensor:022]:   Icon: 'mdi:home-lightning-bolt-outline'
[12:15:41][C][template.sensor:023]:   Update Interval: 60.0s
[12:15:41][C][template.select:065]: Template Select 'Workmode Selector'
[12:15:41][C][template.select:066]:   Update Interval: 60.0s
[12:15:41][C][template.select:069]:   Optimistic: YES
[12:15:41][C][template.select:070]:   Initial Option: normal mode
[12:15:41][C][template.select:071]:   Restore Value: NO
[12:15:41][C][template.select:065]: Template Select 'Batt Min Capacity Selector'
[12:15:41][C][template.select:066]:   Update Interval: 60.0s
[12:15:41][C][template.select:069]:   Optimistic: YES
[12:15:41][C][template.select:070]:   Initial Option: 10%
[12:15:41][C][template.select:071]:   Restore Value: NO
[12:15:41][C][template.select:065]: Template Select 'Max Feedin Selector'
[12:15:41][C][template.select:066]:   Update Interval: 60.0s
[12:15:41][C][template.select:069]:   Optimistic: YES
[12:15:41][C][template.select:070]:   Initial Option: 100%
[12:15:41][C][template.select:071]:   Restore Value: NO
[12:15:41][D][modbus_controller:040]: Modbus command to device=1 register=0xEA61 countdown=0 no response received - removed from send queue
[12:15:41][C][template.select:065]: Template Select 'VPP Time Selector'
[12:15:41][C][template.select:066]:   Update Interval: 60.0s
[12:15:41][C][template.select:069]:   Optimistic: YES
[12:15:41][C][template.select:070]:   Initial Option: 30 sec
[12:15:41][C][template.select:071]:   Restore Value: NO
[12:15:41][C][template.select:065]: Template Select 'VPP timer on/off'
[12:15:41][C][template.select:066]:   Update Interval: 60.0s
[12:15:41][C][template.select:069]:   Optimistic: YES
[12:15:41][C][template.select:070]:   Initial Option: VPP timer off
[12:15:41][C][template.select:071]:   Restore Value: NO
[12:15:41][C][template.select:065]: Template Select 'power ref selector'
[12:15:41][C][template.select:066]:   Update Interval: 60.0s
[12:15:41][C][template.select:069]:   Optimistic: YES
[12:15:41][C][template.select:070]:   Initial Option: 0
[12:15:41][C][template.select:071]:   Restore Value: NO
[12:15:41][C][modbus_controller:341]: ModbusController:
[12:15:41][C][modbus_controller:342]:   Address: 0x01
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensorModbus Controller Sensor 'PV power'
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensor  State Class: ''
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensor  Unit of Measurement: 'W'
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensor  Accuracy Decimals: 0
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensor  Icon: 'mdi:solar-power-variant-outline'
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensorModbus Controller Sensor 'SOC'
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensor  State Class: ''
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensor  Unit of Measurement: '%'
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensor  Accuracy Decimals: 0
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensor  Icon: 'mdi:battery-charging-medium'
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensorModbus Controller Sensor 'Grid power'
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensor  State Class: ''
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensor  Unit of Measurement: 'W'
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensor  Accuracy Decimals: 0
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensor  Icon: 'mdi:transmission-tower'
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensorModbus Controller Sensor 'DSP power'
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensor  State Class: ''
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensor  Unit of Measurement: 'W'
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensor  Accuracy Decimals: 0
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensor  Icon: 'mdi:home-lightning-bolt-outline'
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensorModbus Controller Sensor 'Max Feedin limit'
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensor  State Class: ''
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensor  Unit of Measurement: '%'
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensor  Accuracy Decimals: 0
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensor  Icon: 'mdi:transmission-tower'
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensorModbus Controller Sensor 'Power ref'
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensor  State Class: ''
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensor  Unit of Measurement: 'W'
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensor  Accuracy Decimals: 0
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensor  Icon: 'mdi:battery-outline'
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensorModbus Controller Sensor 'Power ref inv limit'
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensor  State Class: ''
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensor  Unit of Measurement: 'W'
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensor  Accuracy Decimals: 0
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensor  Icon: 'mdi:battery-outline'
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensorModbus Controller Sensor 'VPP timer'
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensor  State Class: ''
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensor  Unit of Measurement: 'sec'
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensor  Accuracy Decimals: 0
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensor  Icon: 'mdi:timer-outline'
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensorModbus Controller Sensor 'VPP timer enable'
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensor  State Class: ''
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensor  Unit of Measurement: '1=on'
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensor  Accuracy Decimals: 0
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensor  Icon: 'mdi:timer-off-outline'
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensorModbus Controller Sensor 'Battery min capacity'
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensor  State Class: ''
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensor  Unit of Measurement: '%'
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensor  Accuracy Decimals: 0
[12:15:41][C][modbus_controller.sensor:010]: modbus_controller.sensor  Icon: 'mdi:battery-minus-outline'
[12:15:41][C][modbus_controller.text_sensor:012]: Modbus Controller Text Sensor 'Serial number inverter'
[12:15:41][C][modbus_controller.text_sensor:012]:   Icon: 'mdi:numeric'
[12:15:41][C][modbus_controller.text_sensor:012]: Modbus Controller Text Sensor 'DSP1 version'
[12:15:41][C][modbus_controller.text_sensor:012]:   Icon: 'mdi:numeric'
[12:15:41][C][modbus_controller.text_sensor:012]: Modbus Controller Text Sensor 'DSP2 version'
[12:15:41][C][modbus_controller.text_sensor:012]:   Icon: 'mdi:numeric'
[12:15:41][C][modbus_controller.text_sensor:012]: Modbus Controller Text Sensor 'EMS version'
[12:15:41][C][modbus_controller.text_sensor:012]:   Icon: 'mdi:numeric'
[12:15:41][C][modbus_controller.text_sensor:012]: Modbus Controller Text Sensor 'BMS version'
[12:15:41][C][modbus_controller.text_sensor:012]:   Icon: 'mdi:numeric'
[12:15:41][C][modbus_controller.text_sensor:012]: Modbus Controller Text Sensor 'Runmode'
[12:15:41][C][modbus_controller.text_sensor:012]:   Icon: 'mdi:cog'
[12:15:41][C][modbus_controller.text_sensor:012]: Modbus Controller Text Sensor 'Workmode'
[12:15:41][C][modbus_controller.text_sensor:012]:   Icon: 'mdi:cog'
[12:15:41][C][captive_portal:088]: Captive Portal:
[12:15:41][C][mdns:115]: mDNS:
[12:15:41][C][mdns:116]:   Hostname: thuisaccu
[12:15:41][C][esphome.ota:073]: Over-The-Air updates:
[12:15:41][C][esphome.ota:074]:   Address: 192.168.1.2:3232
[12:15:41][C][esphome.ota:075]:   Version: 2
[12:15:41][C][esphome.ota:078]:   Password configured
[12:15:41][C][safe_mode:018]: Safe Mode:
[12:15:41][C][safe_mode:020]:   Boot considered successful after 60 seconds
[12:15:41][C][safe_mode:021]:   Invoke after 10 boot attempts
[12:15:41][C][safe_mode:023]:   Remain in safe mode for 300 seconds
[12:15:41][C][api:139]: API Server:
[12:15:41][C][api:140]:   Address: 192.168.1.2:6053
[12:15:41][C][api:142]:   Using noise encryption: YES
[12:15:42][W][modbus_controller:179]: Duplicate modbus command found: type=0x3 address=60003 count=3
[12:15:42][W][modbus_controller:179]: Duplicate modbus command found: type=0x3 address=60007 count=3
[12:15:42][W][modbus_controller:179]: Duplicate modbus command found: type=0x4 address=36112 count=1
[12:15:42][W][modbus_controller:179]: Duplicate modbus command found: type=0x4 address=36131 count=2
[12:15:42][W][modbus_controller:179]: Duplicate modbus command found: type=0x4 address=36138 count=2
[12:15:42][W][component:237]: Component modbus_controller took a long time for an operation (55 ms).
[12:15:42][W][component:238]: Components should block for at most 30 ms.
[12:15:42][D][modbus_controller:040]: Modbus command to device=1 register=0x8D10 countdown=0 no response received - removed from send queue
[12:15:43][D][modbus_controller:040]: Modbus command to device=1 register=0xEA63 countdown=0 no response received - removed from send queue
[12:15:44][W][modbus_controller:179]: Duplicate modbus command found: type=0x3 address=60007 count=3
[12:15:44][W][modbus_controller:179]: Duplicate modbus command found: type=0x4 address=36131 count=2
[12:15:44][W][modbus_controller:179]: Duplicate modbus command found: type=0x4 address=36138 count=2
[12:15:45][D][modbus_controller:040]: Modbus command to device=1 register=0x8D23 countdown=0 no response received - removed from send queue
[12:15:46][D][modbus_controller:040]: Modbus command to device=1 register=0xEA67 countdown=0 no response received - removed from send queue
[12:15:46][W][modbus_controller:179]: Duplicate modbus command found: type=0x3 address=60003 count=3
[12:15:46][W][modbus_controller:179]: Duplicate modbus command found: type=0x4 address=36101 count=1
[12:15:46][W][modbus_controller:179]: Duplicate modbus command found: type=0x4 address=36112 count=1
[12:15:46][W][modbus_controller:179]: Duplicate modbus command found: type=0x4 address=36138 count=2
[12:15:47][D][modbus_controller:040]: Modbus command to device=1 register=0x8D05 countdown=0 no response received - removed from send queue
[12:15:48][W][modbus_controller:179]: Duplicate modbus command found: type=0x3 address=60003 count=3
[12:15:48][W][modbus_controller:179]: Duplicate modbus command found: type=0x3 address=60007 count=3

Hello,
Sorry to come late :wink:
Did you manage to get a working system ?
I found some other addresses to complete the actual ones.
Just in case, my yaml file

Cheers

substitutions:
  name: esp-ecactus
  friendly_name: eCACTUS Agave

esphome:
  name: ${name}
  friendly_name: ${friendly_name}
  name_add_mac_suffix: false
  project:
    name: esphome.web
    version: '1.0'

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:
 # level: DEBUG

# Enable Home Assistant API
api:
   encryption:
    key: WM7zt3/G/5aVzP+WOLjjUmjOqW/iH1L6mRquzSKGIkQ=

ota:
  - platform: esphome
    #safe_mode: true
    password: !secret ota_password

wifi:
  ssid: !secret wifi_ssid_kaz
  password: !secret wifi_password_kaz

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "your backup ssid"
    password: "your backup password"

uart:
    id: rs485_uart
    tx_pin: GPIO17
    rx_pin: GPIO16
    baud_rate: 115200
    stop_bits: 1

modbus:
    uart_id: rs485_uart
    id: modbus1

modbus_controller:
    id: modbus_bms
    address: 0x1 # the Modbus device address of the BMS
    modbus_id: modbus1
    update_interval: 1s

switch:
  - platform: restart
    name: "eCactus Restart"

sensor:

  - platform: modbus_controller
    modbus_controller_id: modbus_bms
    name: "DSP power"
    id: dsp_power_sensor
    icon: mdi:home-lightning-bolt-outline
    register_type: read
    address: 36117
    unit_of_measurement: "W"
    register_count: 2
    value_type: U_DWORD
    accuracy_decimals: 0

  - platform: modbus_controller
    modbus_controller_id: modbus_bms
    name: "DSP Voltage"
    id: measure_voltage_dsp
    register_type: read
    address: 36114
    unit_of_measurement: "V"
    accuracy_decimals: 1
    filters:
      - multiply: 0.1

  - platform: modbus_controller
    modbus_controller_id: modbus_bms
    name: "DSP Current"
    id: measure_current_dsp
    register_type: read
    address: 36115
    unit_of_measurement: "A"
    accuracy_decimals: 2
    filters:
      - multiply: 0.1

  - platform: modbus_controller
    modbus_controller_id: modbus_bms
    name: "DSP Frequency"
    id: measure_frequency_dsp
    register_type: read
    address: 36116
    unit_of_measurement: "Hz"
    accuracy_decimals: 0
    filters:
      - multiply: 0.01

  - platform: modbus_controller
    modbus_controller_id: modbus_bms
    name: "Voltage GRID"
    id: measure_voltage_grid
    register_type: read
    address: 36122
    unit_of_measurement: "V"
    accuracy_decimals: 1
    filters:
      - multiply: 0.1

  - platform: modbus_controller
    modbus_controller_id: modbus_bms
    name: "Battery temp max"
    id: temperature_battery_high
    icon: mdi:thermometer-high
    register_type: read
    address: 36161
    unit_of_measurement: "°C"
    skip_updates: 300
    accuracy_decimals: 1
    filters:
      - multiply: 0.1

  - platform: modbus_controller
    modbus_controller_id: modbus_bms
    name: "Battery temp min"
    id: temperature_battery_min
    icon: mdi:thermometer-low
    register_type: read
    address: 36163
    unit_of_measurement: "°C"
    skip_updates: 300
    accuracy_decimals: 1
    filters:
      - multiply: 0.1

  - platform: modbus_controller
    modbus_controller_id: modbus_bms
    name: "PV1 power"
    id: pv1_power_sensor
    icon: mdi:solar-power-variant-outline
    register_type: read
    address: 36112
    unit_of_measurement: "W"

  - platform: modbus_controller
    modbus_controller_id: modbus_bms
    name: "PV1 voltage"
    id: pv1_voltage_sensor
    icon: mdi:solar-power-variant-outline
    register_type: read
    address: 36108
    unit_of_measurement: "V"
    filters:
      - multiply: 0.1

  - platform: modbus_controller
    modbus_controller_id: modbus_bms
    name: "PV1 current"
    id: pv1_current_sensor
    icon: mdi:solar-power-variant-outline
    register_type: read
    address: 36109
    unit_of_measurement: "A"
    accuracy_decimals: 2
    filters:
      - multiply: 0.1

  - platform: modbus_controller
    modbus_controller_id: modbus_bms
    name: "PV2 power"
    id: pv2_power_sensor
    icon: mdi:solar-power-variant-outline
    register_type: read
    address: 36113
    unit_of_measurement: "W"
    on_value:
      - sensor.template.publish:
          id: pv_power_sensor
          state: !lambda 'return (id(pv2_power_sensor).state + id(pv1_power_sensor).state);' # calculate PV Power

  - platform: modbus_controller
    modbus_controller_id: modbus_bms
    name: "PV2 voltage"
    id: pv2_voltage_sensor
    icon: mdi:solar-power-variant-outline
    register_type: read
    address: 36110
    unit_of_measurement: "V"
    filters:
      - multiply: 0.1

  - platform: modbus_controller
    modbus_controller_id: modbus_bms
    name: "PV2 current"
    id: pv2_current_sensor
    icon: mdi:solar-power-variant-outline
    register_type: read
    address: 36111
    unit_of_measurement: "A"
    accuracy_decimals: 2
    filters:
      - multiply: 0.1

  - platform: template
    name: "PV power"
    id: pv_power_sensor
    icon: mdi:solar-power-variant-outline
    unit_of_measurement: "W"
    accuracy_decimals: 0

  - platform: modbus_controller
    modbus_controller_id: modbus_bms
    name: "Total PV"
    id: meter_power_pv
    icon: mdi:solar-power-variant-outline
    register_type: read
    address: 36213
    skip_updates: 60
    unit_of_measurement: "kWh"
    register_count: 2
    value_type: S_DWORD
    accuracy_decimals: 1
    filters:
      - multiply: 0.1

  - platform: modbus_controller
    modbus_controller_id: modbus_bms
    name: "Total to grid"
    id: meter_power_total_to_grid
    icon: mdi:solar-power-variant-outline
    register_type: read
    address: 36209
    skip_updates: 60
    unit_of_measurement: "kWh"
    register_count: 2
    value_type: S_DWORD
    accuracy_decimals: 1
    filters:
      - multiply: 0.1

  - platform: modbus_controller
    modbus_controller_id: modbus_bms
    name: "Total from grid"
    id: meter_power_total_from_grid
    icon: mdi:solar-power-variant-outline
    register_type: read
    address: 36211
    skip_updates: 60
    unit_of_measurement: "kWh"
    register_count: 2
    value_type: S_DWORD
    accuracy_decimals: 1
    filters:
      - multiply: 0.1

  - platform: modbus_controller
    modbus_controller_id: modbus_bms
    name: "Total charge"
    id: meter_power_total_batteru_charge
    icon: mdi:solar-power-variant-outline
    register_type: read
    address: 36201
    skip_updates: 60
    unit_of_measurement: "kWh"
    register_count: 2
    value_type: S_DWORD
    accuracy_decimals: 1
    filters:
      - multiply: 0.1

  - platform: modbus_controller
    modbus_controller_id: modbus_bms
    name: "Total discharge"
    id: meter_power_total_battery_discharge
    icon: mdi:solar-power-variant-outline
    register_type: read
    address: 36203
    skip_updates: 60
    unit_of_measurement: "kWh"
    register_count: 2
    value_type: S_DWORD
    accuracy_decimals: 1
    filters:
      - multiply: 0.1

  - platform: modbus_controller
    modbus_controller_id: modbus_bms
    name: "SOC"
    id: batt_scoc_sensor
    icon: mdi:battery-charging-medium
    register_type: read
    address: 36155
    unit_of_measurement: "%"
    skip_updates: 30 
  
  - platform: modbus_controller
    modbus_controller_id: modbus_bms
    name: "SOH"
    id: batt_scoh_sensor
    icon: mdi:battery-charging-medium
    register_type: read
    address: 36156
    unit_of_measurement: "%"
    skip_updates: 43200 

  - platform: modbus_controller
    modbus_controller_id: modbus_bms
    name: "Grid power"
    id: grid_power_sensor
    icon: mdi:transmission-tower
    register_type: read
    address: 36131
    unit_of_measurement: "W"
    register_count: 2
    value_type: S_DWORD
  
  - platform: modbus_controller
    modbus_controller_id: modbus_bms
    name: "EPS power"
    id: eps_power_sensor
    icon: mdi:home-lightning-bolt-outline
    register_type: read
    address: 36124
    unit_of_measurement: "W"
    register_count: 2
    value_type: S_DWORD
    accuracy_decimals: 2

  - platform: modbus_controller
    modbus_controller_id: modbus_bms
    name: "Battery voltage"
    id: measure_voltage_battery
    icon: mdi:solar-power-variant-outline
    register_type: read
    address: 36151
    unit_of_measurement: "V"
    accuracy_decimals: 1
    filters:
      - multiply: 0.1

  - platform: modbus_controller
    modbus_controller_id: modbus_bms
    name: "Battery power"
    id: battery_power_sensor
    icon: mdi:home-lightning-bolt-outline
    register_type: read
    address: 36138
    unit_of_measurement: "W"
    register_count: 2
    value_type: S_DWORD
    on_value:
      - sensor.template.publish:
          id: home_power_sensor
          state: !lambda 'return (id(battery_power_sensor).state + id(pv_power_sensor).state + id(grid_power_sensor).state);' # calculate Home Power
    
  - platform: template
    name: "Home power"
    id: home_power_sensor
    icon: mdi:home-lightning-bolt-outline
    unit_of_measurement: "W"
    accuracy_decimals: 0

text_sensor:

  - platform: modbus_controller
    skip_updates: 3600
    modbus_controller_id: modbus_bms
    id: DSP1_vers_text
    icon: mdi:numeric
    bitmask: 0
    register_type: read
    address: 36020
    name: "DSP1 version"
    response_size: 12

  - platform: modbus_controller
    skip_updates: 3600
    modbus_controller_id: modbus_bms
    id: DSP2_vers_text
    icon: mdi:numeric
    bitmask: 0
    register_type: read
    address: 36028
    name: "DSP2 version"
    response_size: 12

  - platform: modbus_controller
    skip_updates: 3600
    modbus_controller_id: modbus_bms
    id: EMS_vers_text
    icon: mdi:numeric
    bitmask: 0
    register_type: read
    address: 36036
    name: "EMS version"
    response_size: 12

  - platform: modbus_controller
    skip_updates: 3600
    modbus_controller_id: modbus_bms
    id: BMS_vers_text
    icon: mdi:numeric
    bitmask: 0
    register_type: read
    address: 36044
    name: "BMS version"
    response_size: 12