syssi / esphome-smg-ii

ESPHome configuration to monitor and control a ISolar/EASUN SMG II inverter via RS232
Apache License 2.0
45 stars 8 forks source link

SRNE ASF Support #28

Open Fidcom opened 1 year ago

Fidcom commented 1 year ago

Hi, this may be off topic, but out of all your inverter integrations, this one is the most similar for the srne inverter, and some settings works better compared to the pdf protocol doc. I was able to get all necessary entities to work, but the ones related to DC voltage such as the float, bulk settings, etc., I can only read them, but not write.

number:
  - platform: modbus_controller
    modbus_controller_id: snre
    name: Bulk Charge Voltage
    id: bulk_voltage
    address: 0xE008
    value_type: U_WORD
    register_type: holding
    unit_of_measurement: "V"
    min_value: 48
    max_value: 58.4
    step: 0.4
    lambda: "return  x * 0.4; "      
    write_lambda: "return  x * 2.5; "   
    use_write_multiple: true

  - platform: modbus_controller
    modbus_controller_id: snre
    name: Float Charge Voltage 
    id: float_voltage
    address: 0xE009
    value_type: U_WORD
    register_type: holding
    unit_of_measurement: "V"
    min_value: 48
    max_value: 58.4
    step: 0.4
    lambda: "return  x * 0.4; "      
    write_lambda: "return  x * 2.5; "

When I try to adjust the slider, the error I receive is the following, and the next one if I dont use the "use_write_multiple" function.

Modbus error function code: 0x90 exception: 11 
[21:46:53][E][modbus_controller:068]: Modbus error function code: 0x10 exception: 11 
[21:46:53][E][modbus_controller:077]: Modbus error - last command: function code=0x10 register address = 0xE008 registers count=1 payload size=2

[21:55:48][D][modbus:119]: Modbus error function code: 0x86 exception: 11
[21:55:48][E][modbus_controller:068]: Modbus error function code: 0x6 exception: 11 
[21:55:48][E][modbus_controller:077]: Modbus error - last command: function code=0x6  register address = 0xE009  registers count=1 payload size=2

I don't have this problem with other settings to adjust charge current, etc. Therefore, do you have any idea what the problem might be based on the modbus error? Thank you!

syssi commented 1 year ago

Could you explain why do you multiple the input value by 2.5f? If you try to set the bulk charge voltage to 48V the command payload will be something like: Set register 0xE008 to 120.

Do you like to contribute your full configuration? I would like to add to the project.

Fidcom commented 1 year ago

image

This is the reason, the values needs to be converted to 12V

Fidcom commented 1 year ago

I'm still testing some entities to see which ones are useful for me but this is the configuration I'm using together with the jk bms

substitutions:
  name: inverter
  device_description: "Monitor and control a JK-BMS via UART-TTL"
  external_components_source: github://syssi/esphome-jk-bms@main
  tx_pin: GPIO03
  rx_pin: GPIO01
  mac_address: C8:47:8C:E9:2C:58
  # Defaults to "JK02"
  # Please use "JK02_32S" if you own a JK-B2A8S20P >= hardware version 11+ (f.e. JK-B2A8S20P hw 11.XW, sw 11.26)
  # Please use "JK04" if you have some old JK-BMS <= hardware version 3 (f.e. JK-B2A16S hw 3.0, sw. 3.3.0)
  protocol_version: JK02_32S

esphome:
  name: ${name}
  comment: ${device_description}
  project:
    name: "syssi.esphome-jk-bms"
    version: 1.4.0

esp32:
  board: esp32dev
  framework:
    type: esp-idf

external_components:
  - source: github://syssi/esphome-jk-bms@main
    refresh: 0s

logger:
  baud_rate: 0
#  level: DEBUG

api:

ota:

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

esp32_ble_tracker:
  on_ble_advertise:
    then:
      - lambda: |-
          if (x.get_name().rfind("JK-", 0) == 0) {
            ESP_LOGI("ble_adv", "New JK-BMS found");
            ESP_LOGI("ble_adv", "  Name: %s", x.get_name().c_str());
            ESP_LOGI("ble_adv", "  MAC address: %s", x.address_str().c_str());
            ESP_LOGD("ble_adv", "  Advertised service UUIDs:");
            for (auto uuid : x.get_service_uuids()) {
              ESP_LOGD("ble_adv", "    - %s", uuid.to_string().c_str());
            }
          }

ble_client:
  - mac_address: ${mac_address}
    id: client0

jk_bms_ble:
  - ble_client_id: client0
    protocol_version: ${protocol_version}
    throttle: 5s
    id: bms0

uart:
  - id: mod_bus
    tx_pin: 16
    rx_pin: 17
    baud_rate: 9600
    data_bits: 8
    stop_bits: 1

modbus:
  uart_id: mod_bus
  send_wait_time: 200ms
#  flow_control_pin: 5
  id: modbus1

modbus_controller:
  - id: snre
    ## the Modbus device addr
    address: '1'
    modbus_id: modbus1
    command_throttle: 200ms
    setup_priority: -10
    update_interval: 5s

binary_sensor:
  - platform: jk_bms_ble
    balancing:
      name: "${name} balancing"
    charging:
      name: "${name} charging"
    discharging:
      name: "${name} discharging"
    online_status:
      name: "${name} online status"

button:
  - platform: jk_bms_ble
    retrieve_settings:
      name: "${name} retrieve settings"
    retrieve_device_info:
      name: "${name} retrieve device info"

sensor:

  - platform: jk_bms_ble
    jk_bms_ble_id: bms0
    min_cell_voltage:
      name: "${name} min cell voltage"
    max_cell_voltage:
      name: "${name} max cell voltage"
    min_voltage_cell:
      name: "${name} min voltage cell"
    max_voltage_cell:
      name: "${name} max voltage cell"
    delta_cell_voltage:
      name: "${name} delta cell voltage"
    average_cell_voltage:
      name: "${name} average cell voltage"
    cell_voltage_1:
      name: "${name} cell voltage 1"
    cell_voltage_2:
      name: "${name} cell voltage 2"
    cell_voltage_3:
      name: "${name} cell voltage 3"
    cell_voltage_4:
      name: "${name} cell voltage 4"
    cell_voltage_5:
      name: "${name} cell voltage 5"
    cell_voltage_6:
      name: "${name} cell voltage 6"
    cell_voltage_7:
      name: "${name} cell voltage 7"
    cell_voltage_8:
      name: "${name} cell voltage 8"
    cell_voltage_9:
      name: "${name} cell voltage 9"
    cell_voltage_10:
      name: "${name} cell voltage 10"
    cell_voltage_11:
      name: "${name} cell voltage 11"
    cell_voltage_12:
      name: "${name} cell voltage 12"
    cell_voltage_13:
      name: "${name} cell voltage 13"
    cell_voltage_14:
      name: "${name} cell voltage 14"
    cell_voltage_15:
      name: "${name} cell voltage 15"
    cell_voltage_16:
      name: "${name} cell voltage 16"
#    cell_resistance_1:
#      name: "${name} cell resistance 1"

    total_voltage:
      name: "${name} total voltage"
    current:
      name: "${name} current"
    power:
      name: "${name} power"
    charging_power:
      name: "${name} charging power"
    discharging_power:
      name: "${name} discharging power"
    temperature_sensor_1:
      name: "${name} temperature sensor 1"
    temperature_sensor_2:
      name: "${name} temperature sensor 2"
    power_tube_temperature:
      name: "${name} power tube temperature"
    state_of_charge:
      name: "${name} state of charge"
    capacity_remaining:
      name: "${name} capacity remaining"
    total_battery_capacity_setting:
      name: "${name} total battery capacity setting"
    charging_cycles:
      name: "${name} charging cycles"
    total_charging_cycle_capacity:
      name: "${name} total charging cycle capacity"
    total_runtime:
      name: "${name} total runtime"
    balancing_current:
      name: "${name} balancing current"
    errors_bitmask:
      name: "${name} errors bitmask"

#INFO  
#  - platform: modbus_controller
#    modbus_controller_id: snre
#    name: "Software Version"
#    id: software_version
#    register_type: holding
#    address: 0x014
#    register_count: 2
#    value_type: U_DWORD
#    skip_updates: 1

#  - platform: modbus_controller
#    modbus_controller_id: snre
#    name: "Serial Number"
#    id: serial_number
#    register_type: holding
#    address: 0x016
#    register_count: 2
#    value_type: U_DWORD
#    skip_updates: 1

#Controller Data Area
#  - platform: modbus_controller
#    modbus_controller_id: snre
#    name: "Battery SOC"
#    id: battery_soc
#    register_type: holding
#    address: 0x100
#    unit_of_measurement: "%"
#    value_type: U_WORD

  - platform: modbus_controller
    modbus_controller_id: snre
    name: "Battery Voltage"
    id: battery_voltage
    address: 0x101
    unit_of_measurement: "V"
    register_type: holding
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
      - multiply: 0.1  

  - platform: modbus_controller
    modbus_controller_id: snre
    name: "Battery Current"
    id: battery_current
    address: 0x102
    unit_of_measurement: "A"
    register_type: holding
    value_type: S_WORD
    accuracy_decimals: 1
    filters:
      - multiply: -0.1

  - platform: template
    name: "Battery Power"
    id: battery_power
    unit_of_measurement: "W"
    lambda: |-
      return (id(battery_voltage).state * id(battery_current).state);
    accuracy_decimals: 1
    device_class: power
    update_interval: 1s

  - platform: modbus_controller
    modbus_controller_id: snre
    name: "MPPT 1 Voltage"
    id: mppt1_voltage
    address: 0x107
    unit_of_measurement: "V"
    register_type: holding
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
      - multiply: 0.1 

  - platform: modbus_controller
    modbus_controller_id: snre
    name: "MPPT 1 Current"
    id: mppt1_current
    address: 0x108
    unit_of_measurement: "A"
    register_type: holding
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
      - multiply: 0.1

  - platform: modbus_controller
    modbus_controller_id: snre
    name: "MPPT 1 Power"
    id: mppt1_power
    address: 0x109
    unit_of_measurement: "W"
    register_type: holding
    value_type: U_WORD
    device_class: Power
    accuracy_decimals: 1

  - platform: modbus_controller
    modbus_controller_id: snre
    name: "Charge Power"
    id: charge_power
    address: 0x10E
    unit_of_measurement: "W"
    register_type: holding
    value_type: U_WORD
    accuracy_decimals: 1

  - platform: modbus_controller
    modbus_controller_id: snre
    name: "MPPT 2 Voltage"
    id: mppt2_voltage
    address: 0x10F
    unit_of_measurement: "V"
    register_type: holding
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
      - multiply: 0.1 

  - platform: modbus_controller
    modbus_controller_id: snre
    name: "MPPT 2 Current"
    id: mppt2_current
    address: 0x110
    unit_of_measurement: "A"
    register_type: holding
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
      - multiply: 0.1

  - platform: modbus_controller
    modbus_controller_id: snre
    name: "MPPT 2 Power"
    id: mppt2_power
    address: 0x111
    unit_of_measurement: "W"
    register_type: holding
    value_type: U_WORD
    device_class: Power
    accuracy_decimals: 1

  - platform: template
    name: "Solar Power"
    id: solar_power
    unit_of_measurement: "W"
    lambda: |-
      return (id(mppt1_power).state + id(mppt2_power).state);
    accuracy_decimals: 0
    device_class: Power
    update_interval: 1s     

#Inverter Data
  - platform: modbus_controller
    modbus_controller_id: snre
    id: battery_rated_voltage
    name: "Rated Voltage"
    address: 0x204
    unit_of_measurement: "V"
    register_type: holding
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
      - multiply: 0.01    

#  - platform: modbus_controller
#    modbus_controller_id: snre
#    id: time_year
#    name: "Time Year"
#    address: 0x020C
#    register_type: holding
#    bitmask: 0xFF00
#    value_type: U_WORD

  - platform: modbus_controller
    modbus_controller_id: snre
    id: grid_voltage
    name: "Grid Voltage"
    address: 0x213
    unit_of_measurement: "V"
    register_type: holding
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
      - multiply: 0.1      

  - platform: modbus_controller
    modbus_controller_id: snre
    id: grid_current_a
    name: "Grid Current A"
    address: 0x214
    unit_of_measurement: "A"
    register_type: holding
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
      - multiply: 0.1 

  - platform: modbus_controller
    modbus_controller_id: snre
    id: grid_frequency
    name: "Grid Frequency"
    address: 0x215
    unit_of_measurement: "Hz"
    register_type: holding
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
      - multiply: 0.01 

  - platform: modbus_controller
    modbus_controller_id: snre
    id: inverter_frequency
    name: Inverter Frequency
    address: 0x218
    unit_of_measurement: "Hz"
    register_type: holding
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
      - multiply: 0.01 

  - platform: modbus_controller
    modbus_controller_id: snre
    id: inverter_load_a
    name: "Inverter Load A"
    address: 0x021B
    unit_of_measurement: "W"
    register_type: holding
    value_type: U_WORD
    accuracy_decimals: 0
    filters:
      - multiply: 1

#  - platform: modbus_controller
#    modbus_controller_id: snre
#    id: grid_voltage_b
#    name: "Grid Voltage B"
#    address: 0x022A
#    unit_of_measurement: "V"
#    register_type: holding
#    value_type: U_WORD
#    accuracy_decimals: 1
#    filters:
#      - multiply: 0.1      
#
#  - platform: modbus_controller
#    modbus_controller_id: snre
#    id: grid_current_b
#    name: "Grid Current B"
#    address: 0x022E
#    unit_of_measurement: "A"
#    register_type: holding
#    value_type: U_WORD
#    accuracy_decimals: 1
#    filters:
#      - multiply: 0.1 

  - platform: template
    name: "Grid Power"
    id: grid_power
    unit_of_measurement: "W"
    lambda: |-
      return (id(grid_voltage).state * id(grid_current_a).state);
    accuracy_decimals: 0
    update_interval: 1s

  - platform: modbus_controller
    modbus_controller_id: snre
    id: inverter_load_b
    name: "Inverter Load B"
    address: 0x232
    unit_of_measurement: "W"
    register_type: holding
    value_type: U_WORD
    accuracy_decimals: 0
    filters:
      - multiply: 1

  - platform: template
    name: "Inverter Load"
    id: inverter_load
    unit_of_measurement: "W"
    lambda: |-
      return (id(inverter_load_a).state + id(inverter_load_b).state);
    accuracy_decimals: 0
    update_interval: 1s       

#  ################# Battery voltage sensors ##########
#    
#          ########  1 ########
#
#  - platform: modbus_controller
#    modbus_controller_id: snre
#    id: over_voltage_threshold
#    name: ${name}_over_voltage_threshold
#    address: 0xE005
#    register_type: holding
#    value_type: U_WORD
#    accuracy_decimals: 1
#    unit_of_measurement: "V"
#    skip_updates: 1
#    # filters:
#    #   - multiply: 0.1
#    lambda: |-
#      return x*0.4;  
# 
#          ########  2 ########
#
#  - platform: modbus_controller
#    modbus_controller_id: snre
#    id: charging_voltage_limit
#    name: ${name}_charging_voltage_limit
#    address: 0xE006
#    register_type: holding
#    value_type: U_WORD
#    accuracy_decimals: 1
#    unit_of_measurement: "V"
#    skip_updates: 1
#    # filters:
#    #   - multiply: 0.1
#    lambda: |-
#      return x*0.4;          
#
#              ########  3 ########
#  
#  - platform: modbus_controller
#    modbus_controller_id: snre
#    id: equalizing_charge_voltage
#    name: ${name}_equalizing_charge_voltage
#    address: 0xE007
#    register_type: holding
#    value_type: U_WORD
#    accuracy_decimals: 1
#    unit_of_measurement: "V"
#    skip_updates: 1
#    # filters:
#    #   - multiply: 0.1
#    lambda: |-
#      return x*0.4;      
#
#            ########  4 ########        
#  
#  - platform: modbus_controller
#    modbus_controller_id: snre
#    id: boost_voltage
#    name: ${name}_boost_voltage
#    address: 0xE008
#    register_type: holding
#    value_type: U_WORD
#    accuracy_decimals: 1
#    unit_of_measurement: "V"
#    skip_updates: 1
#    # filters:
#    #   - multiply: 0.1
#    lambda: |-
#      return x*0.4;  
#
#          ######## 5 ########
#   
#  - platform: modbus_controller
#    modbus_controller_id: snre
#    id: float_voltage
#    name: ${name}_float_voltage
#    address: 0xE009
#    register_type: holding
#    value_type: U_WORD
#    accuracy_decimals: 1
#    unit_of_measurement: "V"
#    skip_updates: 1
#    # filters:
#    #   - multiply: 0.1
#    lambda: |-
#      return x*0.4;  
#
#            ######## 6 ########
#
#  - platform: modbus_controller
#    modbus_controller_id: snre
#    id: boost_charging_recovery_voltage
#    name: ${name}_boost_charging_recovery_voltage
#    address: 0xE00A
#    register_type: holding
#    value_type: U_WORD
#    accuracy_decimals: 1
#    unit_of_measurement: "V"
#    skip_updates: 1
#    # filters:
#    #   - multiply: 0.1
#    lambda: |-
#      return x*0.4;  
#
#              ######## 7 ########
#
#  - platform: modbus_controller
#    modbus_controller_id: snre
#    id: over_discharge_recovery_voltage
#    name: ${name}_over_discharge_recovery_voltage
#    address: 0xE00B
#    register_type: holding
#    value_type: U_WORD
#    accuracy_decimals: 1
#    unit_of_measurement: "V"
#    skip_updates: 1
#    # filters:
#    #   - multiply: 0.1
#    lambda: |-
#      return x*0.4;  
#
#            ######## 8 ########
#
#  - platform: modbus_controller
#    modbus_controller_id: snre
#    id: under_voltage_warning
#    name: ${name}_under_voltage_warning
#    address: 0xE00C
#    register_type: holding
#    value_type: U_WORD
#    accuracy_decimals: 1
#    unit_of_measurement: "V"
#    skip_updates: 1
#    # filters:
#    #   - multiply: 0.1
#    lambda: |-
#      return x*0.4;  
#
#        ######## 9 ########
#
#  - platform: modbus_controller
#    modbus_controller_id: snre
#    id: over_discharge_voltage
#    name: ${name}_over_discharge_voltage
#    address: 0xE00D
#    register_type: holding
#    value_type: U_WORD
#    accuracy_decimals: 1
#    unit_of_measurement: "V"
#    skip_updates: 1
#    # filters:
#    #   - multiply: 0.1
#    lambda: |-
#      return x*0.4;  
#
#        ######## 10 ########
#
#  - platform: modbus_controller
#    modbus_controller_id: snre
#    id: discharge_limit_voltage
#    name: ${name}_discharge_limit_voltage
#    address: 0xE00E
#    register_type: holding
#    value_type: U_WORD
#    accuracy_decimals: 1
#    unit_of_measurement: "V"
#    skip_updates: 1
#    # filters:
#    #   - multiply: 0.1
#    lambda: |-
#      return x*0.4;      

  - platform: modbus_controller
    modbus_controller_id: snre
    id: inverter_to_grid
    name: "Inverter to Grid"
    address: 0xE01B
    register_type: holding
    value_type: U_WORD
    accuracy_decimals: 1
    unit_of_measurement: "V"
    skip_updates: 1
    # filters:
    #   - multiply: 0.1
    lambda: |-
      return x*0.4;  
    icon: mdi:sine-wave

  - platform: modbus_controller
    modbus_controller_id: snre
    id: grid_to_inverter
    name: "Grid to Inverter"
    address: 0xE022
    register_type: holding
    value_type: U_WORD
    accuracy_decimals: 1
    unit_of_measurement: "V"
    skip_updates: 1
    # filters:
    #   - multiply: 0.1
    lambda: |-
      return x*0.4;  
    icon: mdi:sine-wave

##Power Statics##
  - platform: modbus_controller
    modbus_controller_id: snre
    id: solar_today
    name: "Solar Power Today"
    address: 0x0F02F
    unit_of_measurement: "kWh"
    register_type: holding
    value_type: U_WORD
    accuracy_decimals: 1
    device_class: "Energy"
    state_class: "total"
    filters:
      - multiply: 0.1

  - platform: modbus_controller
    modbus_controller_id: snre
    id: load_today
    name: "Load Power Today"
    address: 0x0F030
    unit_of_measurement: "kWh"
    register_type: holding
    value_type: U_WORD
    accuracy_decimals: 1
    device_class: "Energy"
    state_class: "total"
    filters:
      - multiply: 0.1

  - platform: modbus_controller
    modbus_controller_id: snre
    id: grid_today
    name: "Grid Power Today"
    address: 0x0F03D
    unit_of_measurement: "kWh"
    register_type: holding
    value_type: U_WORD
    accuracy_decimals: 1
    device_class: "energy"
    state_class: "total"
    filters:
      - multiply: 0.1

  - platform: modbus_controller
    modbus_controller_id: snre
    id: solar_accumulated
    name: "Accumulated Solar Power"
    address: 0x0F038
    unit_of_measurement: "kWh"
    register_type: holding
    value_type: U_WORD
    accuracy_decimals: 1
    device_class: "Energy"
    state_class: "total"
    filters:
      - multiply: 0.1

  - platform: modbus_controller
    modbus_controller_id: snre
    id: load_accumulated
    name: "Accumulated Load Power"
    address: 0x0F03A
    unit_of_measurement: "kWh"
    register_type: holding
    value_type: U_WORD
    accuracy_decimals: 1
    device_class: "Energy"
    state_class: "total"
    filters:
      - multiply: 0.1

  - platform: modbus_controller
    modbus_controller_id: snre
    id: grid_accumulated
    name: "Accumulated Grid Power"
    address: 0x0F048
    unit_of_measurement: "kWh"
    register_type: holding
    value_type: U_WORD
    accuracy_decimals: 1
    device_class: "Energy"
    state_class: "total"
    filters:
      - multiply: 0.1

  - platform: modbus_controller
    modbus_controller_id: snre
    id: bypass_time
    name: "Bypass Time"
    address: 0x0F03F
    unit_of_measurement: "min"
    register_type: holding
    value_type: U_WORD
    accuracy_decimals: 1

number:

#Inverter Parameters
  - platform: modbus_controller
    modbus_controller_id: snre
    name: "Inverter to Grid Voltage" 
    id: inverter_togrid_bvoltage
    address: 0xE01B
    value_type: U_WORD
    register_type: holding
    unit_of_measurement: "V"
    min_value: 40
    max_value: 60
    step: 0.1
    lambda: "return  x * 0.4; "      
    write_lambda: "return  x * 2.5; " 

  - platform: modbus_controller
    modbus_controller_id: snre
    name: "Grid to Inverter Voltage" 
    id: grid_toinverter_bvoltage
    address: 0xE022
    value_type: U_WORD
    register_type: holding
    unit_of_measurement: "V"
    min_value: 40
    max_value: 60
    step: 0.1
    lambda: "return  x * 0.4; "      
    write_lambda: "return  x * 2.5; " 

  - platform: modbus_controller
    modbus_controller_id: snre
    name: Bulk Charge Voltage
    id: bulk_voltage
    address: 0xE008
    value_type: U_WORD
    register_type: holding
    unit_of_measurement: "V"
    min_value: 48
    max_value: 58.4
    step: 0.4
    lambda: "return  x * 0.4; "      
    write_lambda: "return  x * 2.5; "   
    use_write_multiple: true  

  - platform: modbus_controller
    modbus_controller_id: snre
    name: Float Charge Voltage 
    id: float_voltage
    address: 0xE009
    value_type: U_WORD
    register_type: holding
    unit_of_measurement: "V"
    min_value: 48
    max_value: 58.4
    step: 0.4
    lambda: "return  x * 0.4; "      
    write_lambda: "return  x * 2.5; "

  - platform: modbus_controller
    modbus_controller_id: snre
    name: Grid Charge Current 
    address: 0xE205
    value_type: U_WORD
    register_type: holding
    unit_of_measurement: "A"
    min_value: 0
    max_value: 120
    step: 1
    multiply: 0.1

  - platform: modbus_controller
    modbus_controller_id: snre
    name: Total Charge Current 
    address: 0xE20A
    value_type: U_WORD
    register_type: holding
    unit_of_measurement: "A"
    min_value: 10
    max_value: 200
    step: 10
    lambda: "return  x * 0.1; "      
    write_lambda: "return  x * 10; "  

  - platform: jk_bms_ble
    jk_bms_ble_id: bms0
    balance_trigger_voltage:
      name: "${name} balance trigger voltage"
    cell_count:
      name: "${name} cell count"
    total_battery_capacity:
      name: "${name} total battery capacity"
    cell_voltage_overvoltage_protection:
      name: "${name} cell voltage overvoltage protection"
    cell_voltage_overvoltage_recovery:
      name: "${name} cell voltage overvoltage recovery"
    cell_voltage_undervoltage_protection:
      name: "${name} cell voltage undervoltage protection"
    cell_voltage_undervoltage_recovery:
      name: "${name} cell voltage undervoltage recovery"
    balance_starting_voltage:
      name: "${name} balance starting voltage"
    voltage_calibration:
      name: "${name} voltage calibration"
    current_calibration:
      name: "${name} current calibration"
    power_off_voltage:
      name: "${name} power off voltage"
    max_balance_current:
      name: "${name} max balance current"
    max_charge_current:
      name: "${name} max charge current"
    max_discharge_current:
      name: "${name} max discharge current"

select:
#Inverter Parameters
  - platform: modbus_controller
    modbus_controller_id: snre
    name: "Output Priority"
    id: output_priority
    address: 0xE204
    value_type: U_WORD
    optionsmap:
      "Solar": 0
      "Utlity": 1
      "Solar-Battery": 2

  - platform: modbus_controller
    modbus_controller_id: snre
    name: "AC Input Voltage Range"
    address: 0xE20B
    value_type: U_WORD
    optionsmap:
      "Appliance": 0
      "UPS": 1

  - platform: modbus_controller
    modbus_controller_id: snre
    name: "ECO Mode"
    id: ecomode
    address: 0xE20C
    value_type: U_WORD
    optionsmap:
      "Disable": 0
      "Enable": 1      

  - platform: modbus_controller
    modbus_controller_id: snre
    name: "overload_restart"
    address: 0xE20D
    value_type: U_WORD
    optionsmap:
      "Disable": 0
      "Enable": 1  

#  - platform: modbus_controller
#    modbus_controller_id: snre
#    name: "Alarm"
#    address: 0xE210
#    value_type: U_WORD
#    optionsmap:
#      "Disable": 0
#      "Enable": 1

  - platform: modbus_controller
    modbus_controller_id: snre
    name: "Charge Priority"
    address: 0xE20F
    value_type: U_WORD
    optionsmap:
      "Solar and Utility": 0
      "Utility-Solar": 1
      "Solar-Utility": 2
      "Solar Only": 3      

  - platform: modbus_controller
    modbus_controller_id: snre
    name: "Overload Bypass"
    address: 0xE212
    value_type: U_WORD
    optionsmap:
      "Disable": 0
      "Enable": 1

switch:
  - platform: safe_mode
    name: "Living Room Restart (Safe Mode)"

  - platform: modbus_controller
    use_write_multiple: true
    modbus_controller_id: snre
    name: AlarmS
    register_type: holding
    address: 0xE210
    bitmask: 1
    entity_category: config
    icon: "mdi:toggle-switch"  

  - platform: jk_bms_ble
    charging:
      name: "${name} charging"
    discharging:
      name: "${name} discharging"
    balancer:
      name: "${name} balancer"

  - platform: ble_client
    ble_client_id: client0
    name: "${name} enable bluetooth connection"    

text_sensor:
  - platform: jk_bms_ble
    errors:
      name: "${name} errors"
    total_runtime_formatted:
      name: "${name} total runtime formatted"

  - platform: modbus_controller
    modbus_controller_id: snre
    name: "Inverter State"
    id: inverter_state
    address: 0x0210
    register_type: holding
    raw_encode: HEXBYTES
#    lambda: |-
#      uint16_t value = modbus_controller::word_from_hex_str(x, 0);
#      switch (value) {
#        case 0: return std::string("Power-up delay");
#        case 1: return std::string("Waiting State");
#        case 2: return std::string("Initialization");
#        case 3: return std::string("Soft Start");
#        case 4: return std::string("Mains");
#        case 5: return std::string("Inverter");
#        case 6: return std::string("Inverter to Mains");
#        case 7: return std::string("Mains to Inverter");
#        case 8: return std::string("Battery Active");
#        case 9: return std::string("Shutdown User");
#        case 10: return std::string("Fault");
#      }
#      return std::string("Unknown");      
    lambda: |-
      uint16_t value = modbus_controller::word_from_hex_str(x, 0);
      switch (value) {
        case 0: return std::string("Power On");
        case 1: return std::string("Standby");
        case 2: return std::string("Mains");
        case 3: return std::string("Off-Grid");
        case 4: return std::string("Bypass");
        case 5: return std::string("Charging");
        case 6: return std::string("Fault");
      }
      return std::string("Unknown");

  - platform: modbus_controller
    modbus_controller_id: snre
    name: "Charge State"
    id: charge_state
    address: 0x010B
    register_type: holding
    raw_encode: HEXBYTES
    lambda: |-
      uint16_t value = modbus_controller::word_from_hex_str(x, 0);
      switch (value) {
        case 0: return std::string("Charge Off");
        case 1: return std::string("Quick Charge");
        case 2: return std::string("Cons Volt Charge");
        case 4: return std::string("Float Charge");
        case 5: return std::string("Reserved");
        case 6: return std::string("Li Batt Activate");
        case 7: return std::string("Reserved");
      }
      return std::string("Unknown"); 
syssi commented 1 year ago

I would like to close this issue some day. Could you provide a summary including an updated YAML? What's working and what's not working yet? Thanks in advance!

Fidcom commented 1 year ago

The yaml is the same, I cant solve the problem because i dont know how to solve the modbus errors. The errors only shows when I try to change the dc battery values like float, bulk, cutoff voltages, etc. For the other settings like ac current, charge source, etc, it works ok.

Modbus error function code: 0x90 exception: 11 
[21:46:53][E][modbus_controller:068]: Modbus error function code: 0x10 exception: 11 
[21:46:53][E][modbus_controller:077]: Modbus error - last command: function code=0x10 register address = 0xE008 registers count=1 payload size=2

[21:55:48][D][modbus:119]: Modbus error function code: 0x86 exception: 11
[21:55:48][E][modbus_controller:068]: Modbus error function code: 0x6 exception: 11 
[21:55:48][E][modbus_controller:077]: Modbus error - last command: function code=0x6  register address = 0xE009  registers count=1 payload size=2
syssi commented 1 year ago

Do you know any other (may be official software) which is able to control these values? We could try to sniff/capture some frames to compare the payload with the ESPHome modbus implementation. Do you own a OEM WiFi dongle for example?

Fidcom commented 1 year ago

Currently I do not have the wifi module and I also installed the inverter to a friend, I can only access it remotely through home assistant. I wrote to SRNE several times but never received a response. Searching for SRNE modbus protocol documents I did not find any that were more recent but some older ones. Although the description is more for the charge controller(but the address are the same), in this document is the following:

image

The inverter manual shows:

image

I tested on User and the others lithium settings but I dont remeber if i tested with SLD settings. I will try later with other battery types settings to know if that solve the modbus error, but I need to be there in case of battery settings change that i cant revert remotely.