MODBUS data from SMA Inverter

Hi,
I would like to say thanks to all who send their yaml codes. With this I have successfully access via modbus to my 12 years old SMA inverter via Sunny Webbox. If one of you have also a Webbox please note some values only available on the Webbox UnitID 2. Here my code in configuration.yaml:

# SMA Modbus ST10000-10 via Sunny Webbox
modbus:
 - name: SMA
   type: tcp
   host: 192.168.xxx.xx
   port: 502
   sensors:
      - name: "SMA_Power_AC"
        state_class: measurement
        device_class: energy
        unit_of_measurement: W
        slave: 3
        address: 30775
        data_type: uint32
        scan_interval: 60
      - name: "SMA Betriebszeit"
        state_class: measurement
        unit_of_measurement: h
        slave: 3
        address: 30541
        scan_interval: 60
        data_type: uint32
      - name: "SMA Betriebszeit Total"
        state_class: measurement
        unit_of_measurement: h
        slave: 3
        address: 30543
        scan_interval: 60
        data_type: uint32
      - name: "SMA_PV_Daily_Yield"
        unit_of_measurement: kWh
        device_class: energy
        state_class: total_increasing
        slave: 2
        address: 30517
        scan_interval: 60
        scale: 0.001
        precision: 3
        data_type: int64
      - name: "SMA_PV_Total_Production"
        unit_of_measurement: MWh
        device_class: energy
        state_class: total_increasing
        slave: 2
        address: 30513
        scan_interval: 60
        scale: 0.000001
        precision: 3
        data_type: int64
      - name: "SMA Grid Voltage"
        unit_of_measurement: V
        slave: 3 
        address: 30783
        scan_interval: 60
        scale: 0.01
        precision: 2
        data_type: int32
      - name: "SMA Grid frequency"
        unit_of_measurement: Hz
        slave: 3 
        address: 30803
        scan_interval: 60
        scale: 0.01
        precision: 2
        data_type: uint32
      - name: "SMA_temp"
        unit_of_measurement: °C
        slave: 3
        address: 30953
        scan_interval: 60
        scale: 0.1
        precision: 1
        data_type: int32
      - name: "SMA_status"
        slave: 3
        address: 30201
        scan_interval: 60
        data_type: int32
      - name: "SMA_grid"
        slave: 3
        address: 30217
        scan_interval: 60
        data_type: uint32
      - name: "SMA_Insulation"
        slave: 3
        address: 30225
        scan_interval: 60
        scale: 0.001
        unit_of_measurement: kOhms
        data_type: int32
      - name: "SMA_Residual_current"
        slave: 3
        address: 31247
        scan_interval: 60
        scale: 1
        unit_of_measurement: mA
        data_type: int32
      - name: "SMA Apparent Power"
        unit_of_measurement: VA
        slave: 3
        address: 30813
        scan_interval: 60
        scale: 1
        precision: 0
        data_type: int32
      - name: "SMA Reactive Power"
        unit_of_measurement: VAr
        slave: 3
        address: 30805
        scan_interval: 60
        scale: 1
        precision: 0
        data_type: int32
      - name: "SMA WEBBOX Serial No"
        slave: 1
        address: 30057
        scan_interval: 60
        scale: 1
        precision: 0
        data_type: uint32
      - name: "SMA Modbus Version No"
        slave: 1
        address: 30001
        scan_interval: 60
        scale: 1
        precision: 0
        data_type: uint32
sensor:
  - platform: template
    sensors:
      #Summation of generated energy from new and old inverter
	  pv_solar_erzeugung_summe:
          friendly_name: "PV Solar Erzeugung Summe"
          unit_of_measurement: 'W'
          value_template: "{{ states('sensor.sma_power_ac') |float + states('sensor.inverter_pv_1_current') | float * states('sensor.inverter_pv_1_voltage') | float}}"
      modbus_sma_pv_power:
        friendly_name: 'SMA Power Output'
        value_template: >-
            {% if states('sensor.sma_power_ac')|float < 0 or states('sensor.sma_power_ac')|float > 10000 %}
              0
            {% else %}
              {{ states('sensor.sma_power_ac') }}
            {% endif %}
        unit_of_measurement: "W"
        icon_template: mdi:flash-circle
      modbus_sma_pv_power_kw:
        friendly_name: 'Power Output kW'
        value_template: >-
            {% if states('sensor.sma_power_ac')|float < 0 or states('sensor.sma_power_ac')|float > 10000 %}
              0
            {% else %}
              {{ states('sensor.sma_power_ac')|float / 1000 }}
            {% endif %}
        unit_of_measurement: "kW"
        icon_template: mdi:flash-circle
      modbus_sma_pv_apparent_power:
        friendly_name: 'SMA Apparent Power'
        value_template: >-
            {% if states('sensor.sma_apparent_power')|float < 0 or states('sensor.sma_apparent_power')|float > 10000 %}
              0
            {% else %}
              {{ states('sensor.sma_apparent_power') }}
            {% endif %}
        unit_of_measurement: "VA"
        icon_template: mdi:flash-circle
      modbus_sma_pv_reactive_power:
        
        friendly_name: 'SMA Reactive Power'
        value_template: >-
            {% if states('sensor.sma_reactive_power')|float < 0 or states('sensor.sma_reactive_power')|float > 10000 %}
              0
            {% else %}
              {{ states('sensor.sma_reactive_power') }}
            {% endif %}
        unit_of_measurement: "VAr"
        icon_template: mdi:flash-circle
      modbus_sma_pv_residual:
        
        friendly_name: 'SMA Residual Current'
        value_template: >-
            {% if states('sensor.sma_residual_current')|float < 0 or states('sensor.sma_residual_current')|float > 10000 %}
              0
            {% else %}
              {{ states('sensor.sma_residual_current') }}
            {% endif %}
        unit_of_measurement: "mA"
        icon_template: mdi:flash-circle
      modbus_sma_temperature:
        
        friendly_name: 'SMA Inverter Temp'
        value_template: >-
            {% if states('sensor.sma_temp')|float < 0 or states('sensor.sma_temp')|float > 100 %}
              0
            {% else %}
              {{ states('sensor.sma_temp') }}
            {% endif %}
        unit_of_measurement: "°C"
      modbus_grid_frequency:
        
        friendly_name: 'SMA Grid Frequency'
        value_template: >-
            {% if states('sensor.sma_grid_frequency')|float < 30 or states('sensor.sma_grid_frequency')|float > 100 %}
              Not Measured
            {% else %}
              {{ states('sensor.sma_grid_frequency') }}
            {% endif %}
        unit_of_measurement: "Hz"
      modbus_grid_voltage:
        
        friendly_name: 'SMA Grid Voltage'
        value_template: >-
            {% if states('sensor.sma_grid_voltage')|float < 180 or states('sensor.sma_grid_voltage')|float > 300 %}
              Not Measured
            {% else %}
              {{ states('sensor.sma_grid_voltage') }}
            {% endif %}
        unit_of_measurement: "V"
      modbus_inverter_status:
        
        friendly_name: 'SMA Inverter Status'
        value_template: >-
            {% if is_state('sensor.sma_status', '307' ) %}
              OK
            {% elif is_state('sensor.sma_status', '303' ) %}
              Off
            {% elif is_state('sensor.sma_status', '455' ) %}
              Warning
            {% elif is_state('sensor.sma_status', '35' ) %}
              Fault
            {% endif %}
      modbus_grid_contactor:
        
        friendly_name: 'SMA Grid contactor'
        value_template: >-
            {% if is_state('sensor.sma_grid', '51' ) %}
              Closed
            {% else %}
              Open
            {% endif %}   

br,
Stephan

1 Like

Hello there,

I have a Sunny Tripower 20000 and Iam not able to get continuously data from it.

I use SunSpec, I activated Modbus via the SunnyExplorer. If i reload SunSpec during daylight I get the data from current production. After sunset the sensors shut off (?) and I just get “This entity is no longer being provided by the sunspec integration. If the entity is no longer in use, delete it in settings.”
The next morning I does not start again and Iam stuck with no data.

Does anyone has the Tripower 20k and is able to get their data?

Hi Stephan,
is my understanding correct that you managed to integrate a Sunny Webbox in home assistant. I have also a Webbox can you support me for integration?

best regards
Chris

Hi Lugia,
Would you mind posting your configurations for the Tripower 25000TL inverter please? I have spent over 6 days trying everything possible and can’t get these working in HA. I have 5 to connect with and can confirm Modbus connection with the same computer running HA, but not through HA itself.
Many thanks.

Hi Braxx,
lI have the exact same installation. Do you have found a solution.
Regards,
Krobbe

Try the EMHASS project:
https://community.home-assistant.io/t/emhass-an-energy-management-for-home-assistant/338126

But I think you’ll have to figure out yourself how to control the battery (maybe ask SMA).

@krobbe

Here you go. This goes into a modbus.yaml or with prefix “modbus:” into the configuration.yaml

- name: "sma"
  type: tcp
  host: 192.168.x.x # ip address of sma inverter
  port: 502
  sensors:
    - name: "SMA Energy Total"
      slave: 3
      data_type: uint64
      address: 30513
      scan_interval: 10
      unit_of_measurement: "Wh"
      state_class: 'total'
      device_class: 'energy'
    - name: "SMA Energy Today"
      slave: 3
      data_type: uint64
      address: 30517
      scan_interval: 10
      unit_of_measurement: "Wh"
    - name: "SMA Current Power"
      slave: 3
      data_type: int32
      address: 30775
      scan_interval: 10
      unit_of_measurement: "W"
    - name: "SMA Internal Temperature"
      slave: 3
      data_type: int32
      scale: 0.1
      address: 30953
      scan_interval: 10
      unit_of_measurement: "°C"
    - name: "SMA Status Code"
      slave: 3
      data_type: uint32
      address: 30201
      scan_interval: 10

hey

Did you find something to make it works?
I would try the same,
I can read all the data from my Sunnyboy, but I cant write or change data in the sunnyboy with modbus.
If it is working by you, would you share your way how to get it working?

kind regards,
Frederik

Thanks to this thread I managed to get lots of data from my Sunny tripower inverter.
There’s only one thing that doesn’t work and that’s the A Current phase L1, L2 and L3.
I use address 30797, 30799 and 30801 for this, but the data remains zero.

This is my piece of code from conf yaml:

      - name: "SMA Fasestroom L1"
        unique_id: "fa400021008"
        state_class: "measurement"
        device_class: "current"
        unit_of_measurement: "A"
        slave: 3
        address: 30797
        data_type: "int32"
        scale: 0.001
        precision: 2
        min_value: 0
      - name: "SMA Fasestroom L2"
        unique_id: "fa400021009"
        state_class: "measurement"
        device_class: "current"
        unit_of_measurement: "A"
        slave: 3
        address: 30799
        data_type: "int32"
        scale: 0.001
        precision: 2
        min_value: 0
      - name: "SMA Fasestroom L3"
        unique_id: "fa400021010"
        state_class: "measurement"
        device_class: "current"
        unit_of_measurement: "A"
        slave: 3
        address: 30801
        data_type: "int32"
        scale: 0.001
        precision: 2
        min_value: 0

Hi, I’m looking to download data from my 2011 SMA Sunny Boy 4000TL, in particular the daily generation total. Is that what you are collecting with your ‘SMA Energy Total’ and ‘SMA Energy Today’ Wh sensors?

address 30517 (data_type uint64) is total daily yield in Wh,
address 30513 (also uint64) is total yield in Wh of the SMA from the initial start.

1 Like

Thank you. I have a 485 Data Module and a Waveshare RS485 to Ethernet converter on their way. The installation instructions for the module make it look fairly simple (hopefully).

@Crash123Crash123 I also have a 3600, I added your config, checked modbus was all ok in the SunnyBoy app but HA just chucks out loads in the error log

nvalid config for 'modbus' at configuration.yaml, line 108: SMA_grid: `count` illegal with `data_type: uint32` 'modbus->0->sensors->6', got {'name': 'SMA_grid', 'slave': 3, 'address': 30217, 'scan_interval': 60, 'count': 2, 'data_type': 'uint32'}
Invalid config for 'modbus' at configuration.yaml, line 114: SMA_Insulation: `count` illegal with `data_type: DataType.INT16` 'modbus->0->sensors->7', got {'name': 'SMA_Insulation', 'slave': 3, 'address': 30225, 'scan_interval': 120, 'count': 2}
Invalid config for 'modbus' at configuration.yaml, line 53: SMA_Power_AC: `count` illegal with `data_type: uint32` 'modbus->0->sensors->0', got {'name': 'SMA_Power_AC', 'state_class': 'measurement', 'unit_of_measurement': 'W', 'slave': 3, 'address': 30775, 'count': 2, 'data_type': 'uint32', 'scan_interval': 10}
Invalid config for 'modbus' at configuration.yaml, line 61: SMA_PV_Daily_Yield: `count` illegal with `data_type: int64` 'modbus->0->sensors->1', got {'name': 'SMA_PV_Daily_Yield', 'unit_of_measurement': 'kWh', 'state_class': 'measurement', 'slave': 3, 'address': 30517, 'scan_interval': 60, 'scale': 0.001, 'precision': 3, 'count': 4, 'data_type': 'int64'}
Invalid config for 'modbus' at configuration.yaml, line 71: SMA_PV_Total_Production: `count` illegal with `data_type: int64` 'modbus->0->sensors->2', got {'name': 'SMA_PV_Total_Production', 'unit_of_measurement': 'MWh', 'state_class': 'measurement', 'slave': 3, 'address': 30513, 'scan_interval': 3600, 'scale': 1e-06, 'precision': 3, 'count': 4, 'data_type': 'int64'}
Invalid config for 'modbus' at configuration.yaml, line 81: SMA_Grid Voltage: `count` illegal with `data_type: int32` 'modbus->0->sensors->3', got {'name': 'SMA_Grid Voltage', 'unit_of_measurement': 'V', 'slave': 3, 'address': 30783, 'scan_interval': 120, 'count': 2, 'scale': 0.01, 'precision': 2, 'data_type': 'int32'}
Invalid config for 'modbus' at configuration.yaml, line 90: SMA_Grid frequency: `count` illegal with `data_type: uint32` 'modbus->0->sensors->4', got {'name': 'SMA_Grid frequency', 'unit_of_measurement': 'Hz', 'slave': 3, 'address': 30803, 'scan_interval': 120, 'count': 2, 'scale': 0.01, 'precision': 2, 'data_type': 'uint32'}
Invalid config for 'modbus' at configuration.yaml, line 99: SMA_temp: `count` illegal with `data_type: int32` 'modbus->0->sensors->5', got {'name': 'SMA_temp', 'unit_of_measurement': '°C', 'slave': 3, 'address': 30953, 'scan_interval': 60, 'count': 2, 'scale': 0.1, 'precision': 1, 'data_type': 'int32


Unfortunately i do not have a SMA anymore.

1 Like

Same here, I think development changed MODBUS, I read something about not accepting a single device in its config. I think they killed it.
No SMA MODBUS guess a new breaking news. I think it wil affect a lot of people with older SMA inverters, for they can not use the webcon module of those inverters.
I hope they roll back the change or come with a solution.

I’m having a SMA 7000-TL, MODBUS is just working fine with 2024.4 core. I still get my present yield and daily total yield. So I don’t think MODBUS is broken.
(for info: I use MODBUS over tcp)

I can not use the integrated MODBUS option, for my older SMA inverter only understands the MODBUS in configuration.yaml, not the integrations option, that never did work.

modbus:
  - name: SMA
    type: tcp
    host: 192.168.0.xxx
    port: 502
    sensors:
      - name: SMA_Power_AC
        unique_id: SMA_Power_AC
        state_class: measurement
        device_class: "power"
        unit_of_measurement: W
        slave: 3
        address: 30775
        #        count: 2
        data_type: uint32
        scan_interval: 10
      - name: SMA_PV_Daily_Yield
        unique_id: SMA_PV_Daily_Yield
        unit_of_measurement: kWh
        state_class: measurement
        device_class: "energy"
        slave: 3
        address: 30517
        scan_interval: 60
        scale: 0.001
        precision: 3
        #        count: 4
        data_type: int64
      - name: SMA_PV_Total_Production
        unique_id: SMA_PV_Total_Production
        unit_of_measurement: MWh
        device_class: "energy"
        state_class: measurement
        slave: 3
        address: 30513
        scan_interval: 3600
        scale: 0.000001
        precision: 3
        #        count: 4
        data_type: int64
      - name: SMA_Grid_Voltage
        unique_id: SMA_Grid_Voltage
        unit_of_measurement: V
        slave: 3
        address: 30783
        scan_interval: 120
        #        count: 2
        scale: 0.01
        precision: 2
        data_type: int32
      - name: SMA_Grid_frequency
        unique_id: SMA_Grid_frequentie
        state_class: "measurement"
        device_class: "frequency"
        unit_of_measurement: Hz
        slave: 3
        address: 30803
        scan_interval: 120
        #        count: 2
        scale: 0.01
        precision: 2
        data_type: uint32
      - name: SMA_temp
        unique_id: SMA_temp
        state_class: "measurement"
        device_class: "temperature"
        unit_of_measurement: °C
        slave: 3
        address: 30953
        scan_interval: 60
        #        count: 2
        scale: 0.1
        precision: 1
        data_type: int32
      - name: SMA_status
        unique_id: SMA_status
        slave: 3
        address: 30201
        scan_interval: 10
        #        count: 2
        data_type: int32
      - name: SMA_grid
        unique_id: SMA_grid
        slave: 3
        address: 30217
        scan_interval: 60
        #        count: 2
        data_type: uint32
      - name: SMA_Power_L1
        unique_id: SMA_Power_L1
        state_class: measurement
        device_class: power
        unit_of_measurement: W
        slave: 3
        address: 30777
        scan_interval: 120
        #        count: 2
        data_type: int32

This is my config in configurations, it worked very well up to core 2024.4.4 What do I need to change to get this running again.

Like you, I’m only using MODBUS in the configuration.yaml, never tried the integration.
This is my Modbus configuration

- name: sma
  type: tcp
  host: 192.168.178.100
  port: 502
  sensors:
    - name: SMA_Power_AC
      unique_id: SMA_Power_AC
      state_class: measurement
      device_class: "power"
      unit_of_measurement: W
      slave: 3
      address: 30775
      data_type: int32
      min_value: 0
    - name: SMA_Power_Day
      unique_id: SMA_Power_Day
      state_class: total
      device_class: "energy"
      unit_of_measurement: Wh
      slave: 3
      address: 30517
      data_type: uint64
      min_value: 0

Only noticable differences I see: datatypes are different, I don’t use scan_interval, default is then every 30 seconds.
Hope this helps.

I tried without the Scan_intervals but it did not fix the issue. I have some uint32 and uint64 too but, changing them did not fix the problem either.
Thank you for answering, I hope there is another way to get this solved?

My only guess is that there is a problem with one of the items and therefore modbus configuration is failing.

I would try with a new configuration, start with one item first and see if that works. Then continue with one item per try, maybe in this way you could find and solve the problem.