Сторінка 1 з 1

Нова версія Aninerel 6.2 kW з RS232. Інтеграція в Home assistant.

Додано: 07 червня 2026, 13:13
bootuse
Нова версія Aninerel 6.2 kW для підключення wifi адаптера має порт RS232.

Сам інвертор - https://s.click.aliexpress.com/e/_c410u0FR

Для підключення потрібен RS232-TTL адаптер та esp32 (я використовую esp32c6 але правильну).
RS232-TTL - https://s.click.aliexpress.com/e/_c33FaVCN
esp32c6 - https://s.click.aliexpress.com/e/_c3HYdofD

Код: Виділити все

substitutions:
  tx_pin: GPIO19
  rx_pin: GPIO20
  name: aninerel

esphome:
  name: aninerel
  friendly_name: Aninerel

esp32:
  board: esp32-c6-devkitm-1
  framework:
    type: esp-idf

# Enable logging
logger:


# Enable Home Assistant API
api:
  encryption:
    key: "хххххххххххххх

ota:
  - platform: esphome
    password: "ххххххххххххххххххх"

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

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Aninerel Fallback Hotspot"
    password: "i0OBdJm3Tafz"

captive_portal:
 

uart:
  id: uart_0
  tx_pin: ${tx_pin}
  rx_pin: 
    number: ${rx_pin}
  baud_rate: 9600
  stop_bits: 1
  debug: 

modbus:
  - id: modbus0
    uart_id: uart_0
    send_wait_time: 200ms

modbus_controller:
  - id: smg0
    address: 0x01
    modbus_id: modbus0
    command_throttle: 200ms
    update_interval: 20s

time:
  - platform: sntp

sensor:
  - platform: total_daily_energy
    name: "${name} Battery discharge today"
    restore: true
    device_class: energy
    power_id: smg0_discharging_power
    filters:
      # Multiplication factor from W to kW is 0.001
      - multiply: 0.001
    unit_of_measurement: kWh

  - platform: total_daily_energy
    name: "${name} Battery charge today"
    restore: true
    device_class: energy
    power_id: smg0_charging_power
    filters:
      # Multiplication factor from W to kW is 0.001
      - multiply: 0.001
    unit_of_measurement: kWh

  - platform: template
    name: "${name} discharging power"
    id: smg0_discharging_power
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement
    icon: mdi:battery-arrow-down
    # Gets updated on value of smg0_battery_average_power
    update_interval: never
    lambda: |-
      if (isnan(id(smg0_battery_average_power).state)) {
        return {};
      }
      auto power = id(smg0_battery_average_power).state;
      return (power < 0.0f) ? -power : 0.0f;

  - platform: template
    name: "${name} charging power"
    id: smg0_charging_power
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement
    icon: mdi:battery-charging
    # Gets updated on value of smg0_battery_average_power
    update_interval: never
    lambda: |-
      if (isnan(id(smg0_battery_average_power).state)) {
        return {};
      }
      auto power = id(smg0_battery_average_power).state;
      return (power > 0.0f) ? power : 0.0f;

  ## Fault code                                                    ULong 100 2 R
  # - platform: modbus_controller
  #   modbus_controller_id: smg0
  #   name: "${name} fault code"
  #   address: 100
  #   register_type: holding
  #   value_type: U_DWORD
  #   accuracy_decimals: 0

  # Warning code                                                  ULong 108 2 R
  # - platform: modbus_controller
  #   modbus_controller_id: smg0
  #   name: "${name} warning code"
  #   address: 108
  #   register_type: holding
  #   value_type: U_DWORD
  #   accuracy_decimals: 0


  # Device Type	 	UInt	171	1	R
  # - platform: modbus_controller
  #   modbus_controller_id: smg0
  #   name: "${name} Device Type"
  #   address: 171
  #   register_type: holding
  #   value_type: U_WORD
  #   accuracy_decimals: 0

  # Protocol Number	 	UInt	184	1	R	The protocol number of this protocol is 0x02
  # - platform: modbus_controller
  #   modbus_controller_id: smg0
  #   name: "${name} Protocol Number"
  #   address: 171
  #   register_type: holding
  #   value_type: U_WORD
  #   accuracy_decimals: 0

  # Operation Mode                                                UInt  201 1 R 0: Power On
  #                                                                             1: Standby
  #                                                                             2: Mains
  #                                                                             3: Off-Grid
  #                                                                             4: Bypass
  #                                                                             5: Charging
  #                                                                             6: Fault
  # - platform: modbus_controller
  #   modbus_controller_id: smg0
  #   name: "${name} operation mode id"
  #   address: 201
  #   register_type: holding
  #   value_type: U_WORD
  #   accuracy_decimals: 0

  # Effective mains voltage                              0.1V     Int   202 1 R
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} ac voltage"
    address: 202
    register_type: holding
    value_type: S_WORD
    unit_of_measurement: "V"
    device_class: voltage
    state_class: measurement
    accuracy_decimals: 1
    filters:
      - multiply: 0.1

  # Mains Frequency                                      0.01Hz   Int   203 1 R
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} ac frequency"
    address: 203
    register_type: holding
    value_type: S_WORD
    unit_of_measurement: "Hz"
    device_class: frequency
    state_class: measurement
    accuracy_decimals: 2
    filters:
      - multiply: 0.01

  # Average mains power                                  1W       Int   204 1 R
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} average mains power"
    address: 204
    register_type: holding
    value_type: S_WORD
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement
    accuracy_decimals: 0

  # Effective inverter voltage                           0.1V     Int   205 1 R
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} effective inverter voltage"
    address: 205
    register_type: holding
    value_type: S_WORD
    unit_of_measurement: "V"
    device_class: voltage
    state_class: measurement
    accuracy_decimals: 1
    filters:
      - multiply: 0.1

  # Effective inverter current                           0.1A     Int   206 1 R
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} effective inverter current"
    address: 206
    register_type: holding
    value_type: S_WORD
    unit_of_measurement: "A"
    device_class: current
    state_class: measurement
    accuracy_decimals: 1
    filters:
      - multiply: 0.1

  # Inverter frequency                                   0.01Hz   Int   207 1 R
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} inverter frequency"
    address: 207
    register_type: holding
    value_type: S_WORD
    unit_of_measurement: "Hz"
    device_class: frequency
    state_class: measurement
    accuracy_decimals: 2
    filters:
      - multiply: 0.01

  # Average inverter power                               1W       Int   208 1 R Positive numbers indicate inverter output, negative numbers indicate inverter input
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} average inverter power"
    address: 208
    register_type: holding
    value_type: S_WORD
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement
    accuracy_decimals: 0

  # Inverter charging power                              1W       Int   209 1 R
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} inverter charging power"
    address: 209
    register_type: holding
    value_type: S_WORD
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement
    accuracy_decimals: 0
    icon: mdi:battery-charging

  # Output effective voltage                             0.1V     Int   210 1 R
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} output effective voltage"
    address: 210
    register_type: holding
    value_type: S_WORD
    unit_of_measurement: "V"
    device_class: voltage
    state_class: measurement
    accuracy_decimals: 1
    filters:
      - multiply: 0.1

  # Output effective Current                             0.1A     Int   211 1 R
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} output effective Current"
    address: 211
    register_type: holding
    value_type: S_WORD
    unit_of_measurement: "A"
    device_class: current
    state_class: measurement
    accuracy_decimals: 1
    filters:
      - multiply: 0.1

  # Output frequency                                     0.01Hz   Int   212 1 R
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} output frequency"
    address: 212
    register_type: holding
    value_type: S_WORD
    unit_of_measurement: "Hz"
    device_class: frequency
    state_class: measurement
    accuracy_decimals: 2
    filters:
      - multiply: 0.01

  # Output active power                                  1W       Int   213 1 R
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} output active power"
    address: 213
    register_type: holding
    value_type: S_WORD
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement
    accuracy_decimals: 0

  # Output apparent power                                1VA      Int   214 1 R
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} output apparent power"
    address: 214
    register_type: holding
    value_type: S_WORD
    unit_of_measurement: "VA"
    device_class: apparent_power
    state_class: measurement
    accuracy_decimals: 0

  # Battery average voltage                              0.1V     Int   215 1 R
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} battery average voltage"
    address: 215
    register_type: holding
    value_type: S_WORD
    unit_of_measurement: "V"
    device_class: voltage
    state_class: measurement
    accuracy_decimals: 1
    filters:
      - multiply: 0.1

  # Battery average Current                              0.1A     Int   216 1 R
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} battery average current"
    address: 216
    register_type: holding
    value_type: S_WORD
    unit_of_measurement: "A"
    device_class: current
    state_class: measurement
    accuracy_decimals: 1
    icon: mdi:current-dc
    filters:
      - multiply: 0.1

  # Battery average power                                1W       Int   217 1 R
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} battery average power"
    id: smg0_battery_average_power
    address: 217
    register_type: holding
    value_type: S_WORD
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement
    accuracy_decimals: 0
    on_value:
      - component.update: smg0_discharging_power
      - component.update: smg0_charging_power

  # PV average voltage                                   0.1V     Int   219 1 R
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} pv average voltage"
    address: 219
    register_type: holding
    value_type: S_WORD
    unit_of_measurement: "V"
    device_class: voltage
    state_class: measurement
    accuracy_decimals: 1
    icon: mdi:solar-power
    filters:
      - multiply: 0.1

  # PV average current                                   0.1A     Int   220 1 R
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} pv average current"
    address: 220
    register_type: holding
    value_type: S_WORD
    unit_of_measurement: "A"
    device_class: current
    state_class: measurement
    accuracy_decimals: 1
    icon: mdi:solar-power
    filters:
      - multiply: 0.1

  # PV average power                                     1W       Int   223 1 R
  - platform: modbus_controller
    modbus_controller_id: smg0
    id: smg0_pv_average_power
    name: "${name} pv average power"
    address: 223
    register_type: holding
    value_type: S_WORD
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement
    accuracy_decimals: 0
    icon: mdi:solar-power

  # PV charging average power                            1W       Int   224 1 R
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} pv charging average power"
    address: 224
    register_type: holding
    value_type: S_WORD
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement
    accuracy_decimals: 0
    icon: mdi:solar-power

  # Load percentage                                      1%       Int   225 1 R
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} load percentage"
    address: 225
    register_type: holding
    value_type: S_WORD
    unit_of_measurement: "%"
    state_class: measurement
    accuracy_decimals: 0
    icon: mdi:percent


  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} output2 current"
    address: 236
    register_type: holding
    value_type: S_WORD
    unit_of_measurement: "A"
    device_class: current
    state_class: measurement
    accuracy_decimals: 1
    filters:
      - multiply: 0.1

  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} output2 apparent power"
    address: 239
    register_type: holding
    value_type: S_WORD # Змінено на знакове 16-бітне число
    unit_of_measurement: "VA"
    device_class: apparent_power
    state_class: measurement
    accuracy_decimals: 0

  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} output2 active power"
    address: 240
    register_type: holding
    value_type: U_WORD
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement
    accuracy_decimals: 0

  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} output2 load percentage"
    address: 243
    register_type: holding
    value_type: U_WORD
    unit_of_measurement: "%"
    state_class: measurement
    accuracy_decimals: 0
    icon: mdi:percent

  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} output2 voltage"
    address: 244
    register_type: holding
    value_type: U_WORD
    unit_of_measurement: "V"
    device_class: voltage
    state_class: measurement
    accuracy_decimals: 1
    filters:
      - multiply: 0.1


  # DCDC Temperature                                     1°C      Int   226 1 R
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} dcdc temperature"
    address: 226
    register_type: holding
    value_type: S_WORD
    unit_of_measurement: "°C"
    device_class: temperature
    state_class: measurement
    accuracy_decimals: 0

  # Inverter Temperature                                 1°C      Int   227 1 R
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} inverter temperature"
    address: 227
    register_type: holding
    value_type: S_WORD
    unit_of_measurement: "°C"
    device_class: temperature
    state_class: measurement
    accuracy_decimals: 0

  # PV temperature                                       1°C      Int   228 1 R
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} PV temperature"
    address: 228
    register_type: holding
    value_type: S_WORD
    unit_of_measurement: "°C"
    device_class: temperature
    state_class: measurement
    accuracy_decimals: 0

  # Battery state of charge                              1%       UInt  229 1 R
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} battery state of charge"
    address: 229
    register_type: holding
    value_type: U_WORD
    unit_of_measurement: "%"
    device_class: battery
    state_class: measurement
    accuracy_decimals: 0

  # Power flow status                                     --       UInt  231 1 R
  # bit0~1 0: PV is not connected to the system          1: PV is connected to the system
  # bit2~3 0: Mains power is not connected to the system 1: Mains power is connected to the system  2: Inverter is connected to the grid
  # bit4~5 0: Battery neither charged nor discharged     1: Battery charging 2: Battery discharging
  # bit6~7 0: The system does not output load            1: The system outputs load
  # bit8   0: Not charged by AC power                    1: Charged by AC power
  # bit9   0: PV not charging                            1: PV charging
  # bit10  0: Battery icon on                            1: Battery icon off
  # bit11  0: PV icon is on                              1: PV icon is off
  # bit12  0: Mains icon is on                           1: Mains icon is off
  # bit13  0: Load icon is on                            1: Load icon is off
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} power flow status"
    address: 231
    register_type: holding
    value_type: U_WORD
    accuracy_decimals: 0
    icon: mdi:transmission-tower

  # Battery average current                              0.1A     Int   232 1 R Positive number means charging, negative number means discharging
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} battery average current2"
    address: 232
    register_type: holding
    value_type: S_WORD
    unit_of_measurement: "A"
    device_class: current
    state_class: measurement
    accuracy_decimals: 1
    icon: mdi:current-dc
    filters:
      - multiply: 0.1

  # Inverter charging average current                    0.1A     Int   233 1 R
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} inverter charging average current"
    address: 233
    register_type: holding
    value_type: S_WORD
    unit_of_measurement: "A"
    device_class: current
    state_class: measurement
    accuracy_decimals: 1
    icon: mdi:current-dc
    filters:
      - multiply: 0.1

  # PV charging average current                          0.1A     Int   234 1 R
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} pv charging average current"
    address: 234
    register_type: holding
    value_type: S_WORD
    unit_of_measurement: "A"
    device_class: current
    state_class: measurement
    accuracy_decimals: 1
    icon: mdi:solar-power
    filters:
      - multiply: 0.1


  # Power generation on the day                            0.01Kwh  Uint   443 1 R
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} PV energy today"
    address: 443
    register_type: holding
    value_type: U_WORD
    unit_of_measurement: "kWh"
    icon: mdi:solar-power
    device_class: energy
    state_class: "total_increasing"
    accuracy_decimals: 1
    filters:
      - multiply: 0.01

  ## Rated power                                           W       Uint  643 1 R
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} rated power"
    address: 643
    register_type: holding
    value_type: U_WORD
    unit_of_measurement: "W"
    device_class: power
     #state_class: measurement
    accuracy_decimals: 0

  # Поточний поріг вимкнення другого виходу за SOC
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} Output 2 Cut-Off SOC Status"
    address: 344
    register_type: holding
    value_type: U_WORD
    unit_of_measurement: "%"
    icon: "mdi:battery-arrow-down-vertical"

  # Поріг попередження про перевантаження OP2
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} OP2 Overload Warning Status"
    address: 353
    register_type: holding
    value_type: U_WORD
    unit_of_measurement: "%"
    icon: "mdi:alert-speedometer-outline"

  # Час активації батареї в секундах
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} Battery Activation Time Status"
    address: 356
    register_type: holding
    value_type: U_WORD
    unit_of_measurement: "s"
    icon: "mdi:timer-outline"


select:
  # Output priority                                               Uint  301 1 R/W 0: Utility-PV-Battery, 1: PV-Utility-Battery, 2: PV-Battery-Utility
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} output priority"
    use_write_multiple: true
    address: 301
    value_type: U_WORD
    icon: mdi:cog
    entity_category: config
    optionsmap:
      # "PV-Utility-Battery (SUB)": 1
      # "PV-Battery-Utility (SBU)": 2
      # "PV-Utility-Battery (SUF)": 3
      # "Zero Export To CT (SUF)": 4
      "Utility-PV-Battery (UTI)": 0
      "PV-Bat-Uti(on-demand) (SOL)": 1
      "PV-Bat-Uti (SBU)": 2
      "PV-Uti-Bat (SUB)": 3
      "PV-Uti-Bat (SUF)": 4



  # Input voltage range                                           Uint  302 1 R/W 0: Wide range, 1: Narrow range
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} input voltage range"
    use_write_multiple: true
    address: 302
    value_type: U_WORD
    icon: mdi:cog
    entity_category: config
    optionsmap:
      "APL": 0
      "UPS": 1
      "GNT": 2

  # Buzzer mode                                                   Uint  303 1 R/W 0: Mute in all situations, 1: Sound when the input source is changed or there is a specific warning or fault, 2: Sound when there is aspecific warning or fault, 3: Sound when fault occurs
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} buzzer mode"
    use_write_multiple: true
    address: 303
    value_type: U_WORD
    icon: mdi:cog
    entity_category: config
    optionsmap:
      "Silent": 0
      "Beep on input source changes, warnings and faults": 1
      "Beep on warnings and faults": 2
      "Beep on faults": 3

  # LCD backlight                                                 Uint  305 1 R/W 0: Timed off, 1: Always on
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} lcd backlight"
    use_write_multiple: true
    address: 305
    value_type: U_WORD
    icon: mdi:cog
    entity_category: config
    optionsmap:
      "Timed off": 0
      "Always on": 1


  # Battery Type                                                 Uint  322 1 R/W
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} battery type"
    address: 322
    value_type: U_WORD
    icon: mdi:cog
    entity_category: config
    optionsmap:
      "AGM": 0
      "FLD": 1
      "USER": 2
      "Li2": 4  # PYLON US2000
      "Li4": 6
      "Lib": 8

  # Battery charging priority                                     Uint  331 1 R/W 0: Utility priority, 1: PV priority, 2: PV is at the same level as the Utility, 3: Only PV charging is allowed
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} battery charging priority"
    use_write_multiple: true
    address: 331
    value_type: U_WORD
    icon: mdi:cog
    entity_category: config
    optionsmap:
      # "PV priority (SOF) ": 1
      # "PV and mains at the same level (SNU)": 2
      # "Only PV charging is allowed (OSO)": 3
      # "PV priority meets the remaining output charge (SOR)": 4
      "PV (CSO) ": 1
      "PV + Uti (SNU)": 2
      "PV only (OSO)": 3
      "PV priority meets the remaining output charge (SOR)": 4

  # Turn on mode                                                  Uint  406 1 R/W 0: Can be turn-on locally or remotely, 1: Only local turn-on, 2: Only remote turn-on
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} turn on mode"
    use_write_multiple: true
    address: 406
    value_type: U_WORD
    icon: mdi:cog
    entity_category: config
    optionsmap:
      "Local and remotely turn-on allowed": 0
      "Local turn-on only": 1
      "Remote turn-on only": 2

switch:
  # LCD automatically returns to the homepage                     Uint  306 1 R/W 0: Do not return automatically, 1: Automatically return after 1 minute
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} lcd automatically returns to the homepage"
    use_write_multiple: true
    address: 306
    register_type: holding
    bitmask: 1
    icon: mdi:toggle-switch

  # Energy-saving mode                                            Uint  307 1 R/W 0: Energy-saving mode is off, 1: Energy-saving mode is on
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} energy-saving mode"
    use_write_multiple: true
    address: 307
    register_type: holding
    bitmask: 1
    icon: mdi:toggle-switch

  # Overload automatic restart                                    Uint  308 1 R/W 0: Overload failure will not restart, 1: Automatic restart after overload failure
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} overload automatic restart"
    use_write_multiple: true
    address: 308
    register_type: holding
    bitmask: 1
    icon: mdi:toggle-switch

  # Over temperature automatic restart                            Uint  309 1 R/W 0: Over temperature failure will not restart, 1: Automatic restart after over-temperature fault
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} over temperature automatic restart"
    use_write_multiple: true
    address: 309
    register_type: holding
    bitmask: 1
    icon: mdi:toggle-switch

  # Overload transfer to bypass enabled                           Uint  310 1 R/W 0: Disable, 1: Enable
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} overload transfer to bypass enabled"
    use_write_multiple: true
    address: 310
    register_type: holding
    bitmask: 1
    icon: mdi:toggle-switch

  # Parallel PV detection mode                                   Uint  311 1 R/W 0: Disable, 1: Enable
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} parallel PV detection mode"
    use_write_multiple: true
    address: 311
    register_type: holding
    bitmask: 1
    icon: mdi:toggle-switch

  # Battery Eq mode is enabled                                    Uint  313 1 R/W 0: Disable, 1: Enable
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} battery Eq mode is enabled"
    use_write_multiple: true
    address: 313
    register_type: holding
    bitmask: 1
    icon: mdi:toggle-switch

  # Automatic mains output enable                                Uint   338 1 R/W 0: No AC power output if the power button is not pressed  1: Automatic AC power output if the power button is not pressed
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} Automatic mains output enable"
    use_write_multiple: true
    address: 338
    register_type: holding
    bitmask: 1
    icon: mdi:toggle-switch

  # Island detection enable                                       Uint  352 1 R/W 0: Disable island detection 1: Enable island detection
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} island detection"
    use_write_multiple: true
    address: 352
    register_type: holding
    bitmask: 1
    icon: mdi:toggle-switch

  # Remote switch                                                 Uint  420 1 R/W 0: Remote shutdown, 1: Remote turn-on
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} remote switch"
    use_write_multiple: true
    address: 420
    register_type: holding
    bitmask: 1
    icon: mdi:toggle-switch

  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} OP2 Output Enable"
    address: 354
    register_type: holding
    bitmask: 0x0001
    use_write_multiple: true
    icon: mdi:power-plug-outline

text_sensor:
  # Fault code                                                    ULong 100 2 R
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} fault"
    address: 100
    register_type: holding
    register_count: 2
    response_size: 4
    raw_encode: HEXBYTES
    icon: mdi:alert-circle
    lambda: |-
      static const uint8_t FAULTS_SIZE = 29;
      static const char *const FAULTS[FAULTS_SIZE] = {
          "Over temperature of inverter module",                     // 0000 0000 0000 0000 0000 0000 0000 0001 (1)
          "Over temperature of PV module",                           // 0000 0000 0000 0000 0000 0000 0000 0010 (2)
          "Over temperature of DCDC module",                         // 0000 0000 0000 0000 0000 0000 0000 0100 (3)
          "Battery over voltage",                                    // 0000 0000 0000 0000 0000 0000 0000 1000 (4)
          "PV module over temperature",                              // 0000 0000 0000 0000 0000 0000 0001 0000 (5)
          "Output short circuit",                                    // 0000 0000 0000 0000 0000 0000 0010 0000 (6)
          "Inverter over voltage",                                   // 0000 0000 0000 0000 0000 0000 0100 0000 (7)
          "Output over load",                                        // 0000 0000 0000 0000 0000 0000 1000 0000 (8)
          "Bus over voltage",                                        // 0000 0000 0000 0000 0000 0001 0000 0000 (9)
          "Bus soft start timed out",                                // 0000 0000 0000 0000 0000 0010 0000 0000 (10)
          "PV over current",                                         // 0000 0000 0000 0000 0000 0100 0000 0000 (11)
          "PV over voltage",                                         // 0000 0000 0000 0000 0000 1000 0000 0000 (12)
          "Battery over current",                                    // 0000 0000 0000 0000 0001 0000 0000 0000 (13)
          "Inverter over current",                                   // 0000 0000 0000 0000 0010 0000 0000 0000 (14)
          "Bus low voltage",                                         // 0000 0000 0000 0000 0100 0000 0000 0000 (15)
          "Reserve (Bit 15)",                                        // 0000 0000 0000 0000 1000 0000 0000 0000 (16)
          "Inverter DC component is too high",                       // 0000 0000 0000 0001 0000 0000 0000 0000 (17)
          "Reserve (Bit 17)",                                        // 0000 0000 0000 0010 0000 0000 0000 0000 (18)
          "The zero bias of output current is too large",            // 0000 0000 0000 0100 0000 0000 0000 0000 (19)
          "The zero bias of inverter current is too large",          // 0000 0000 0000 1000 0000 0000 0000 0000 (20)
          "The zero bias of battery current is too large",           // 0000 0000 0001 0000 0000 0000 0000 0000 (21)
          "The zero bias of PV current is too large",                // 0000 0000 0010 0000 0000 0000 0000 0000 (22)
          "Inverter low voltage",                                    // 0000 0000 0100 0000 0000 0000 0000 0000 (23)
          "Inverter negative power protection",                      // 0000 0000 1000 0000 0000 0000 0000 0000 (24)
          "The host in the parallel system is lost",                 // 0000 0001 0000 0000 0000 0000 0000 0000 (25)
          "Synchronization signal abnormal in the parallel system",  // 0000 0010 0000 0000 0000 0000 0000 0000 (26)
          "The battery type is incompatible",                        // 0000 0100 0000 0000 0000 0000 0000 0000 (27)
          "Parallel versions are incompatible",                      // 0000 1000 0000 0000 0000 0000 0000 0000 (28)
          "External CT setup duplication",                           // 0001 0000 0000 0000 0000 0000 0000 0000 (29)
      };
      std::string values = "";

      uint32_t mask = modbus_controller::dword_from_hex_str(x, 0);
      if (mask) {
        for (int i = 0; i < FAULTS_SIZE; i++) {
          if (mask & (1 << i)) {
            values.append(FAULTS[i]);
            values.append(";");
          }
        }
        if (!values.empty()) {
          values.pop_back();
        }
      }
      return values;

  # Warning code                                                  ULong 108 2 R
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} warning"
    address: 108
    register_type: holding
    register_count: 2
    response_size: 4
    raw_encode: HEXBYTES
    icon: mdi:alert-circle
    lambda: |-
      static const uint8_t WARNINGS_SIZE = 22;
      static const char *const WARNINGS[WARNINGS_SIZE] = {
          "Mains zero loss",                                             // 0000 0000 0000 0000 0000 0000 0000 0001 (1)
          "Mains waveform abnormal",                                     // 0000 0000 0000 0000 0000 0000 0000 0010 (2)
          "Mains overvoltage",                                           // 0000 0000 0000 0000 0000 0000 0000 0100 (3)
          "Mains low voltage",                                           // 0000 0000 0000 0000 0000 0000 0000 1000 (4)
          "Mains over frequency",                                        // 0000 0000 0000 0000 0000 0000 0001 0000 (5)
          "Mains low frequency",                                         // 0000 0000 0000 0000 0000 0000 0010 0000 (6)
          "PV low voltage",                                              // 0000 0000 0000 0000 0000 0000 0100 0000 (7)
          "Over temperature",                                            // 0000 0000 0000 0000 0000 0000 1000 0000 (8)
          "Battery low voltage",                                         // 0000 0000 0000 0000 0000 0001 0000 0000 (9)
          "Battery is not connected",                                    // 0000 0000 0000 0000 0000 0010 0000 0000 (10)
          "Overload",                                                    // 0000 0000 0000 0000 0000 0100 0000 0000 (11)
          "Battery Eq charging",                                         // 0000 0000 0000 0000 0000 1000 0000 0000 (12)
          "Battery undervoltage",                                        // 0000 0000 0000 0000 0001 0000 0000 0000 (13)
          "Output power derating",                                       // 0000 0000 0000 0000 0010 0000 0000 0000 (14)
          "Fan blocked",                                                 // 0000 0000 0000 0000 0100 0000 0000 0000 (15)
          "PV energy is too low to be use",                              // 0000 0000 0000 0000 1000 0000 0000 0000 (16)
          "Parallel communication interrupted",                          // 0000 0000 0000 0001 0000 0000 0000 0000 (17)
          "Output mode of Single and Parallel systems inconsistent",     // 0000 0000 0000 0010 0000 0000 0000 0000 (18)
          "Battery voltage difference of parallel system is too large",  // 0000 0000 0000 0100 0000 0000 0000 0000 (19)
          "Lithium battery communication abnormality",                   // 0000 0000 0000 1000 0000 0000 0000 0000 (20)
          "The battery discharge current exceeds the set value",         // 0000 0000 0001 0000 0000 0000 0000 0000 (21)
          "Island",                                                      // 0000 0000 0010 0000 0000 0000 0000 0000 (22)
      };
      std::string values = "";

      uint32_t mask = modbus_controller::dword_from_hex_str(x, 0);
      if (mask) {
        for (int i = 0; i < WARNINGS_SIZE; i++) {
          if (mask & (1 << i)) {
            values.append(WARNINGS[i]);
            values.append(";");
          }
        }
        if (!values.empty()) {
          values.pop_back();
        }
      }
      return values;

  ## Device Name                                                  ASC   172 12 R/W Device name, written or read in ASCII format
  # - platform: modbus_controller
  #   modbus_controller_id: smg0
  #   name: "${name} Device Name"
  #   address: 172
  #   register_type: holding
  #   raw_encode: ANSI
  #   register_count: 12
  #   response_size: 12

  ## Device serial number                                         ASC   186 12 R
  # - platform: modbus_controller
  #   modbus_controller_id: smg0
  #   name: "${name} Device serial number"
  #   address: 186
  #   register_type: holding
  #   raw_encode: ANSI
  #   register_count: 12
  #   response_size: 12

  # Operation Mode                                                UInt  201 1 R 0: Power On, 1: Standby, 2: Mains, 3: Off-Grid, 4: Bypass, 5: Charging, 6: Fault
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} operation mode"
    address: 201
    register_type: holding
    raw_encode: HEXBYTES
    icon: mdi:information
    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");

  ## Program Version                                                 ASC   626 8 R
  # - platform: modbus_controller
  #   modbus_controller_id: smg0
  #   name: "${name} Program Version"
  #   address: 626
  #   register_type: holding
  #   raw_encode: ANSI
  #   register_count: 8
  #   response_size: 8
  
  
  
  

number:
  # Output voltage                                                0.1V    Uint  320 1 R/W
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} output voltage"
    use_write_multiple: true
    address: 320
    register_type: holding
    value_type: U_WORD
    min_value: 0.0
    # max_value: 100.0
    step: 0.1
    unit_of_measurement: "V"
    entity_category: config
    icon: mdi:cog
    lambda: "return x * 0.1f;"
    write_lambda: |-
      return x * 10.0f;

  # Output frequency setting                                      0.01Hz  Uint  321 1 R/W
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} output frequency setting"
    use_write_multiple: true
    address: 321
    register_type: holding
    value_type: U_WORD
    min_value: 0.0
    # max_value: 100.0
    step: 0.01
    unit_of_measurement: "Hz"
    entity_category: config
    icon: mdi:cog
    lambda: "return x * 0.01f;"
    write_lambda: |-
      return x * 100.0f;

  # [A] Battery overvoltage protection point                          0.1V    Uint  323 1 R/W
  # Range: ( B + 1v * J ) ~ 16.5v * J
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} battery overvoltage protection point"
    use_write_multiple: true
    address: 323
    register_type: holding
    value_type: U_WORD
    min_value: 0.0
    # max_value: 100.0
    step: 0.1
    unit_of_measurement: "V"
    entity_category: config
    icon: mdi:battery-high
    lambda: "return x * 0.1f;"
    write_lambda: |-
      return x * 10.0f;

  # [B]Max charging voltage                                          0.1V    Uint  324 1 R/W
  # Range: C ~ ( A - 1v)
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} max charging voltage"
    use_write_multiple: true
    address: 324
    register_type: holding
    value_type: U_WORD
    min_value: 0.0
    max_value: 100.0
    step: 0.1
    unit_of_measurement: "V"
    entity_category: config
    icon: mdi:battery-high
    lambda: "return x * 0.1f;"
    write_lambda: |-
      return x * 10.0f;

  # [C] Floating charging voltage                                     0.1V    Uint  325 1 R/W
  # Range: (12v * J ) ~ B
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} floating charging voltage"
    use_write_multiple: true
    address: 325
    register_type: holding
    value_type: U_WORD
    min_value: 0.0
    # max_value: 100.0
    step: 0.1
    unit_of_measurement: "V"
    entity_category: config
    icon: mdi:battery
    lambda: "return x * 0.1f;"
    write_lambda: |-
      return x * 10.0f;

  # Battery discharge recovery point in mains mode                0.1V    Uint  326 1 R/W
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} battery discharge recovery point in mains mode"
    use_write_multiple: true
    address: 326
    register_type: holding
    value_type: U_WORD
    min_value: 0.0
    # max_value: 100.0
    step: 0.1
    unit_of_measurement: "V"
    entity_category: config
    icon: mdi:battery
    lambda: "return x * 0.1f;"
    write_lambda: |-
      return x * 10.0f;

  # Battery low voltage protection point in mains mode            0.1V    Uint  327 1 R/W
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} battery low voltage protection point in mains mode"
    use_write_multiple: true
    address: 327
    register_type: holding
    value_type: U_WORD
    min_value: 0.0
    # max_value: 100.0
    step: 0.1
    unit_of_measurement: "V"
    entity_category: config
    icon: mdi:battery-low
    lambda: "return x * 0.1f;"
    write_lambda: |-
      return x * 10.0f;

  # Battery low voltage protection point in off-grid mode          0.1V           Uint  329 1 R/W
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} battery low voltage protection point in off-grid mode"
    use_write_multiple: true
    address: 329
    register_type: holding
    value_type: U_WORD
    min_value: 0.0
    # max_value: 100.0
    step: 0.1
    unit_of_measurement: "V"
    entity_category: config
    icon: mdi:battery-low
    lambda: "return x * 0.1f;"
    write_lambda: |-
      return x * 10.0f;

  # Maximum charging current                                      0.1A    Uint  332 1 R/W
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} maximum charging current"
    use_write_multiple: true
    address: 332
    register_type: holding
    value_type: U_WORD
    min_value: 0.0
    max_value: 120.0
    step: 0.1
    unit_of_measurement: "A"
    entity_category: config
    icon: mdi:current-dc
    lambda: "return x * 0.1f;"
    write_lambda: |-
      return x * 10.0f;

  # Maximum mains charging current                                0.1A    Uint  333 1 R/W
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} maximum mains charging current"
    use_write_multiple: true
    address: 333
    register_type: holding
    value_type: U_WORD
    min_value: 0.0
    max_value: 80.0
    step: 0.1
    unit_of_measurement: "A"
    entity_category: config
    icon: mdi:battery-charging
    lambda: "return x * 0.1f;"
    write_lambda: |-
      return x * 10.0f;

  # Eq Charging voltage                                           0.1V    Uint  334 1 R/W
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} Eq Charging voltage"
    use_write_multiple: true
    address: 334
    register_type: holding
    value_type: U_WORD
    min_value: 0.0
    max_value: 100.0
    step: 0.1
    unit_of_measurement: "V"
    entity_category: config
    icon: mdi:battery
    lambda: "return x * 0.1f;"
    write_lambda: |-
      return x * 10.0f;

  # Battery equalization time                                     min     Uint  335 1 R/W Range: 0~900
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} battery equalization time"
    use_write_multiple: true
    address: 335
    register_type: holding
    value_type: U_WORD
    min_value: 0.0
    max_value: 900.0
    step: 1
    unit_of_measurement: "min"
    entity_category: config
    icon: mdi:timer

  # Equalization Timeout exit                                     min     Uint  336 1 R/W Range: 0~900
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} equalization Timeout exit"
    use_write_multiple: true
    address: 336
    register_type: holding
    value_type: U_WORD
    min_value: 0.0
    max_value: 900.0
    step: 1
    unit_of_measurement: "min"
    entity_category: config
    icon: mdi:timer

  # Two equalization charging intervals                           day     Uint  337 1 R/W Range: 1~90
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} two equalization charging intervals"
    use_write_multiple: true
    address: 337
    register_type: holding
    value_type: U_WORD
    min_value: 0.0
    max_value: 90.0
    step: 1
    unit_of_measurement: "day"
    entity_category: config
    icon: mdi:timer

  # Battery discharge SOC protection value in AC mode [K]           1%    Uint   341 1 R/W Range: 20%~50%
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} Battery discharge SOC protection value in AC mode [K]"
    use_write_multiple: true
    address: 341
    register_type: holding
    value_type: U_WORD
    min_value: 20.0
    max_value: 50.0
    step: 1
    unit_of_measurement: "%"
    entity_category: config
    icon: mdi:shield-check

  # Battery discharge SOC recovery value in AC mode                  1%    Uint   342 1 R/W Range: 60%~100%
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} Battery discharge SOC recovery value in AC mode"
    use_write_multiple: true
    address: 342
    register_type: holding
    value_type: U_WORD
    min_value: 60.0
    max_value: 100.0
    step: 1
    unit_of_measurement: "%"
    entity_category: config
    icon: mdi:shield-check

  # Off-grid mode battery discharge SOC protection value              1%    Uint   343 1 R/W Range: 3%~Min( K , 30%)
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} Off-grid mode battery discharge SOC protection value"
    use_write_multiple: true
    address: 343
    register_type: holding
    value_type: U_WORD
    min_value: 3.0
    max_value: 50.0
    step: 1
    unit_of_measurement: "%"
    entity_category: config
    icon: mdi:shield-check

  # PV grid-connected maximum power                                    1w    Uint   344 1 R/W Range: 200w~ rated power
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} PV grid-connected maximum power"
    use_write_multiple: true
    address: 344
    register_type: holding
    value_type: U_WORD
    min_value: 200.0
    max_value: 6200.0
    step: 1
    device_class: power
    unit_of_measurement: "W"
    entity_category: config
    icon: mdi:chart-line

  # Maximum discharge current protection                                1A    Uint   351 1 R/W Maximum discharge current protection value in stand-alone mode
  - platform: modbus_controller
    modbus_controller_id: smg0
    name: "${name} maximum discharge current protection"
    use_write_multiple: true
    address: 351
    register_type: holding
    value_type: U_WORD
    min_value: 50.0
    max_value: 500.0
    step: 1
    device_class: current
    unit_of_measurement: "A"
    entity_category: config
    icon: mdi:shield-check


Re: Нова версія Aninerel 6.2 kW з RS232. Інтеграція в Home assistant.

Додано: 12 червня 2026, 16:01
bootuse