MODBUS data from SMA Inverter

Here the code of my setup:

modbus:
  - name: SMA
    type: tcp
    host: mysunnyboyipaddress
    port: 502
    sensors:
      - name: SMA_Power_AC
        unit_of_measurement: W
        slave: 3
        address: 30775
        count: 2
        data_type: uint32
        scan_interval: 60
      - name: PV Daily Yield
        unit_of_measurement: kWh
        slave: 3
        address: 30517
        scan_interval: 60
        scale: 0.001
        precision: 3
        count: 4
        data_type: int64
      - name: PV Total Production
        unit_of_measurement: MWh
        slave: 3
        address: 30513
        scan_interval: 60
        scale: 0.000001
        precision: 3
        count: 4
        data_type: int64
      - name: Grid Voltage
        unit_of_measurement: V
        slave: 3 
        address: 30783
        scan_interval: 60
        count: 2
        scale: 0.01
        precision: 2
        data_type: int32
      - name: Grid frequency
        unit_of_measurement: Hz
        slave: 3 
        address: 30803
        scan_interval: 60
        count: 2
        scale: 0.01
        precision: 2
        data_type: uint32
      - name: SMA_temp
        unit_of_measurement: °C
        slave: 3
        address: 30953
        scan_interval: 60
        count: 2
        scale: 0.1
        precision: 1
        data_type: int32
      - name: SMA_status
        slave: 3
        address: 30201
        scan_interval: 60
        count: 2
        data_type: int32
      - name: SMA_grid
        slave: 3
        address: 30217
        scan_interval: 60
        count: 2
        data_type: uint32
      - name: Insulation
        slave: 3
        address: 30225
        scan_interval: 60
        count: 2
        scale: 0.001
        unit_of_measurement: kOhms
        data_type: int32
      - name: SMA_Residual_current
        slave: 3
        address: 31247
        scan_interval: 60
        count: 2
        scale: 1
        unit_of_measurement: mA
        data_type: int32
      - name: Apparent Power
        unit_of_measurement: VA
        slave: 3
        address: 30813
        scan_interval: 60
        scale: 1
        precision: 0
        count: 2
        data_type: int32
      - name: Reactive Power
        unit_of_measurement: VAr
        slave: 3
        address: 30805
        scan_interval: 60
        scale: 1
        precision: 0
        count: 2
        data_type: int32

You also have to add the template of your sensors:

- platform: template
    sensors:
      modbus_sma_pv_power:
        
        friendly_name: '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_apparent_power:
        
        friendly_name: 'Apparent Power'
        value_template: >-
            {% if states('sensor.apparent_power')|float < 0 or states('sensor.apparent_power')|float > 10000 %}
              0
            {% else %}
              {{ states('sensor.apparent_power') }}
            {% endif %}
        unit_of_measurement: "VA"
        icon_template: mdi:flash-circle
      modbus_sma_pv_reactive_power:
        
        friendly_name: 'Reactive Power'
        value_template: >-
            {% if states('sensor.reactive_power')|float < 0 or states('sensor.reactive_power')|float > 10000 %}
              0
            {% else %}
              {{ states('sensor.reactive_power') }}
            {% endif %}
        unit_of_measurement: "VAr"
        icon_template: mdi:flash-circle
      modbus_sma_pv_residual:
        
        friendly_name: '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: '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: 'Grid Frequency'
        value_template: >-
            {% if states('sensor.grid_frequency')|float < 30 or states('sensor.grid_frequency')|float > 100 %}
              Not Measured
            {% else %}
              {{ states('sensor.grid_frequency') }}
            {% endif %}
        unit_of_measurement: "Hz"
      modbus_grid_voltage:
        
        friendly_name: 'Grid Voltage'
        value_template: >-
            {% if states('sensor.grid_voltage')|float < 180 or states('sensor.grid_voltage')|float > 300 %}
              Not Measured
            {% else %}
              {{ states('sensor.grid_voltage') }}
            {% endif %}
        unit_of_measurement: "V"
      modbus_inverter_status:
        
        friendly_name: '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: 'Grid contactor'
        value_template: >-
            {% if is_state('sensor.sma_grid', '51' ) %}
              Closed
            {% else %}
              Open
            {% endif %}
1 Like

just a general question with a Sunny Tripower 10.0 - does anyone have an idea to check individual strings? One plug toasted itself, and I lost power from one string for a while, no fault raised.

I am able to read out the modbus data - so that is a great success.

What I would need advice on is the following:
at night, when the panels don’t produce, the counter doesn’t go to 0, but this strange number:
image

I tried this code, but it doesnt work. It also doesnt work to change the 307 to status “OK”. Any thoughts on that one as well?

template:
  - sensor:
      - name: "PV Status"
        state: "{% if is_state('sensor.PV_Status', '307' ) %} OK
            {% elif is_state('sensor.PV_Status', '303' ) %} Off
            {% elif is_state('sensor.PV_Status', '455' ) %} Warning
            {% elif is_state('sensor.PV_Status', '35' ) %} Fault
            {% endif %}"
      - name: "PV Leistung"
        unit_of_measurement: "W"
        state: "{% if states('sensor.PV_Leistung')|float < 0 or states('sensor.PV_Leistung')|float > 10000 %} 0
            {% else %}
              {{ states('sensor.PV_Leistung') }}
            {% endif %}"

Hello, this is how it looks to me.
Note the exact spelling and line offset. You can also try Sunspec, works for SMA too.


Some sensors are only correct if the system is also working.

Hi there!
I sucessfully integrated my SMA inverter in HomeAssistant via Modbus TCP. The model is the Sunny Tripower 25000TL.
The data seems to come in fine. However when I take a look at the power-graph, I get “spikes” where the power is reduced. I can also measure these spike with my energy meter (elgris ZERO), so they are real. The data from the energy meter is also fetched via Modbus TCP. The spikes are really “ugly” when you for example look at the graph for a whole day. Now when I want to look at the consumption, I have to substract the measured power (energy meter) from the current production (inverter). Now the problem is that the measurements from the energy meter and the data from the inverter is not synchronous so in the consumption graph you get two spikes…

So I have a few questions:

Thanks and best regards!

Hello, everyone,
I have an SMA tripower 10 smart energy inverter. Is anyone already using this? If so, could I see the configuration?

1 Like

What data help do you need ?

Hi KeLco Yes im have this Produkt and i will give you some Data

Hi schparc,
can you send me your config? How did you get this to work?

I have two inverters in operation. A SunnyBoy 3.6 and a Tripower 10.0 Smart Energy, the SunnyBoy works great with the SMA integration, no entities are displayed with the Tripower…

Dear All,
I have installed the following hardware:

  • Solar Inverter: Solar Edge
  • Battery Inverter SMA Sunny Boy 5.0
  • SMA Home Manager 2.0
  • Calor Pump Daikin Altherma 3
  • Lan Adapter Daikin brp069a62 with Smart Grid plug
    I would configure the Smart Grid function but I don’t know where to start.
    I’ve installed the “SMA Solar App” but I cannot recognize the sensor/state of the supply to grid in order trigger somehow the warm power of the calor pump when I have an excess of energy production. Do you have some tips?
    Thanks,
    Davide
1 Like

Hi All,

I managed to read all data from my inverter using the YAML files in this topic but the sensors are only appearing as entities. How can I group them into one device?

Hi all,

I have a SMA Sunnyboy storage 5 with a BYD HVM 11kWh battery

I am looking for a way to manualy charge/discharge the battery contolled by HA looking to dynamic prices in Belgium. The goal is to charge from the grid at low price and to discharge at high prices.
I’ve managed to get the dynamic prices in HA & I’ve managed to get all the data from the SMA SBS integration in to HA, but there is minimal to none control of the battery.
I think it could be controled by modbus, but I don’t find the codes in the modbus list.

I would like to program 4 modes:

  • automatic (full auto self consumption like it is now)
  • manualy charge @ xxxx W (xxxx needs to be configurable)
  • manualy discharge @ xxxx W (xxxx needs to be configurable)
  • manualy off (stay standby)

could anyone help me with this or point me in the right direction?

Tnx in advance

Hello @becauseht
Your post helped me a lot my Sunny Boy 5000 tl 21.
I Can see Daily Yield and Totl Production now.
THANK YOU VERY MUCH !

I am now looking for the “Cherry on the cake” : integrate values as Solar Energy for the Energy Dashboard…
It looks like values does not have a unique ID, so we can’t add them in the energy dashboard through the UI :expressionless:

image

Would be great if possible !!!

Thx for anyone who could enlighten …

I don’t use the data from the Sunny boy because i have an external energy smart meter, but i could suggest to try to use the “power output” instead of daily yeld. You need to integrate the value so put in you configuration.yaml something like this:

- platform: integration
    source: sensor.modbus_sma_pv_power
    name: a_name_you_want
    unit_time: h
    round: 2
    method: left

After a reboot you will may find in energy dashboard the name you used, if it still not working you need to create a customize.yaml where you have to put :

sensor.a_name_you_want:
  state_class: total_increasing
  device_class: energy
  unit_of_measurement: kWh
  last_reset: '2021-08-09T11:47:23.862268+00:00'

as unit_of_measurement you need to use kWh or Wh accordingly to your inverter data.
Reboot last time and it would be available in Energy dashboard as “a_name_you_want”.

Thank you for your help.

It looks like I don’t understand what to do in configuration.yaml :thinking:
It have put the integration code in the yaml, but anywhere else than under default_config breaks the config file :expressionless:
image

So the source modbus sensor is defined below (maybe the reason ?)

  - name: PV_Total_Production_kWh
    unit_of_measurement: kWh
    state_class: measurement
    slave: 3
    address: 30513
    scan_interval: 60
    scale: 0.001
    precision: 3
    count: 4
    data_type: int64   

I assume the result would have to see “Production_Solaire” in the dashboard first ?

Best regards

The code need to be pasted under sensor section you will probably already have this section if you don’t simply paste the code below

sensor:
  - platform: integration    
    source: sensor.fv_produzione
    name: Production_Solaire
    unit_time: h
    round: 2
    method: left

And you need to create a customize.yaml where you need to paste this code:

sensor.Production_Solaire:
  state_class: total_increasing
  device_class: energy
  unit_of_measurement: kWh
  last_reset: '2021-08-09T11:47:23.862268+00:00'

Originally the device_class would be “measurement” but they changed something in HA and i had to change in “energy” to make it works.

Whohoo Great !!! It appears now and is available in the Energy Dashborad

A first look at the new Sensor values (Production_Solaire) shown increases even faster than the Daily production
But the Energy Dashboard seems not to see any production at all (0 in graph etc, maybe need to wait for 2 hours)

I think I need some rest, couldn’t sleep yesterday lol

i think you picked up the wrong sensor, you don’t have to use the PV_Total_Production but the PV_Power.
And yes in energy dashboard you will need to wait at least 1 or 2 hour before saw something.
image

you need to change the source: using sensor.PV_Power

Acknowledged ! => On My Way …

Due to my poor knowledge of Electricity, I was wondering kWh were needed as source :man_facepalming:

So from the Modbus I found this value is 30775, Power (in Watts)
By default the Scan Interval is 1 minute (hope it’s ok)