MODBUS data from SMA Inverter

Copy your configuration.yaml into my yaml file, but unfortunately no improvement. I see the entities, but with a warning

well no such luck for me, all network protocols are enabled in my sunnyboy 3000TL-21, but whatever I try or do, I always get unexpected error or unable to connect as error.
I tried putting the sma modbus code in yaml, tried the SMA integration same nothing happens.
Dead end for me, shame, I guess my sunnyboy is way too old is from 2013 and then they placed the first version of the webconnect, sure my internet site from sma works, sure my sunny explorer does too, but i can not open a webpage in a browser directly to the sunnyboy, and i think somewhere in that is the problem, a webconnect from the first batch not manageable
enough. short version it sucks big time that I am unable to integrate it in HA.

after upgrading to core-2022.4.0 i’ve started to get this error on Modbus immagine

and all the sensor related are in status “unavailable” does anyone know how to solve the problem?
from the updating it started to log an incorrect int,float format in the configuration yaml that i’ve solved defining int32 as data_type

yes, you have to replace int or uint with int32 if you receive 4 byte else int64 for 8 bytes.
I solved with this code:

modbus:
  name: sma
  type: tcp
  host: 192.168....
  port: 502
  sensors:
    - name: SMA Power AC
      unit_of_measurement: W
      slave: 3
      address: 30775
      count: 2
      data_type: uint32
    - name: SMA Daily Yield
      unit_of_measurement: Wh
      slave: 3
      address: 30517
      count: 4
      data_type: int64
    - name: SMA Total
      unit_of_measurement: MWh
      slave: 3
      address: 30513
      count: 4
      data_type: int64
    - name: SMA Volt
      unit_of_measurement: V
      slave: 3
      address: 30783
      count: 2
      data_type: int32
    - name: SMA Power L1 AC
      unit_of_measurement: W
      slave: 3
      address: 30777
      count: 2
      data_type: uint32
    - name: SMA Power L2 AC
      unit_of_measurement: W
      slave: 3
      address: 30779
      count: 2
      data_type: uint32
    - name: SMA Power L3 AC
      unit_of_measurement: W
      slave: 3
      address: 30781
      count: 2
      data_type: uint32
1 Like

thanks Roberto, in my case i had to adjust some of the data_type

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
1 Like

Thanks, that was really helpful for my config as well!

Hello, do you have to change this in the template sensors or does it not matter?

Hi, Modbus doesn’t work from a few days. I didn’t change my modbus configuration. I don’t know if the cause is the new version of HA (Home Assistant 2022.4.7).
Can you help me to fix it?

In the log appear these messages:
Logger: pymodbus.client.sync
Source: /usr/local/lib/python3.9/site-packages/pymodbus/client/sync.py:218
First occurred: 06:36:41 (1555 occurrences)
Last logged: 09:06:54
Connection to (192.168.1.7, 502) failed: timed out
Logger: homeassistant.components.modbus.modbus
Source: components/modbus/modbus.py:304
Integration: Modbus (documentation, issues)
First occurred: 06:37:03 (1 occurrences)
Last logged: 06:37:03
Pymodbus: sma: Modbus Error: [Connection] Failed to connect[ModbusTcpClient(192.168.1.7:502)]
2022-04-27 09:10:57 ERROR (SyncWorker_6) [pymodbus.client.sync] Connection to (192.168.1.7, 502) failed: timed out
2022-04-27 09:10:57 DEBUG (SyncWorker_6) [homeassistant.components.modbus.modbus] Pymodbus: sma: Modbus Error: [Connection] Failed to connect[ModbusTcpClient(192.168.1.7:502)]

This is my configuration:
modbus:

  • type: tcp
    host: 192.168.XX.X # SMA Inverter
    port: 502
    name: “sma”
    close_comm_on_error: true
    delay: 5
    timeout: 5
    retries: 10
    retry_on_empty: true
    message_wait_milliseconds: 750
    sensors:
    • name: Model
      slave: 3
      address: 30053
      count: 2
      data_type: uint32
    • name: Serial Number
      slave: 3
      address: 30057
      count: 2
      data_type: int32

HA and Inverter are on the same net and nmap on HA show me:

nmap -p 502 192.168.XX.XX
Nmap scan report for 192.168.XX.XX
Host is up (0.0065s latency)
Port State Service
502/tcp filtered mbap
MAC Address: XX:XX:XX:XX:XX:XX… (SMA…)
Nmap done: 1 IP address (1 host up) scanned in 1.76 seconds

Hello, since today I have problems with the pv_leistung_emplate sensor, get wrong values. Do you have the same problem?
No negative values ​​but the same number only in positive

nope, still working as expected


Looks like your inverter doesn’t return anything anymore via Modbus

Could it also be a network problem?
I can see values

I’m having the same issue connecting to a Solaredge. It seems that since 2022.7.x something is wrong with async.io.

For me, the Modbus communication was suddenly deactivated in the settings in the inverter, that was the problem, I changed it back and it’s been working again since then.
I actually only came up with it because the yaml sensors didn’t work anymore either.

I am looking at heading down the MODBUS road but would like to know what the time lag is with it as I want to automate process depending on my solar production and usage. For example turn on the gray water pump when excess solar is being produced. At the moment the web portal is only cycling every 15 minutes which makes it useless for trigging things.

Hello everyone,

I’ve had the modbus working before, but since a while it’s not working anymore.
This is the error I have. Does anyone know how to fix this ?

Invalid config for [modbus]: value must be one of [<DataType.CUSTOM: 'custom'>, <DataType.FLOAT16: 'float16'>, <DataType.FLOAT32: 'float32'>, <DataType.FLOAT64: 'float64'>, <DataType.INT16: 'int16'>, <DataType.INT32: 'int32'>, <DataType.INT64: 'int64'>, <DataType.INT8: 'int8'>, <DataType.STRING: 'string'>, <DataType.STRING: 'string'>, <DataType.UINT16: 'uint16'>, <DataType.UINT32: 'uint32'>, <DataType.UINT64: 'uint64'>, <DataType.UINT8: 'uint8'>] for dictionary value @ data['modbus'][0]['sensors'][0]['data_type']. Got 'uint'. (See ?, line ?). Please check the docs at https://www.home-assistant.io/integrations/modbus

I have a SMA sunnyboy 3.6.

If more info is needed please let me know.

you need to specify in your configuration.yaml the data_type adding the lengt in bit, if you have for example

‘data_type: int’ you need to change it in ‘data_type: int8’ or int16 or int32 for all the sensors

I am trying to get this to work, as the other integrations aren’t working for me (the official SMA one, or the Energy Meter Add-On).

Unfortunately, modbus is not getting any results. I have a tripower 10.0, and a Home Manager 2.0.

Maybe a simple question to begin:
the IP address: is that the one I can type into the browser to access the inverter directly, or do I put the IP of the speedwire connection, that I can find in the settings?

To be fair, I tried both, in in neither result the sensors are reporting anything - I copied the code from “@becauseht

Any ideas? I had to deactivate the “webconnect” feature in the SunnyPortal, because then I was able to add the HomeManager 2.0 to my setup.

How do you know what type you have?

This was my setup:

  - name: sma_omvormer
    type: tcp
    host: 192.168.2.78
    port: 502
    sensors:
      - name: SMApwrL1
        unit_of_measurement: kW
        slave: 3
        address: 30777
        count: 2
        data_type: uint
        scale: 0.001
        precision: 2
        scan_interval: 10
      - name: SMAcurL1
        unit_of_measurement: A
        slave: 3
        address: 30977
        count: 2
        data_type: uint
        scale: 0.001
        precision: 2
        scan_interval: 10
      - name: SMAvoltL1
        unit_of_measurement: V
        slave: 3
        address: 30783
        count: 2
        data_type: uint
        scale: 0.01
        precision: 1
        scan_interval: 10        
      - name: SMAnetHZ
        unit_of_measurement: Hz
        slave: 3
        address: 30803
        count: 2
        data_type: uint
        scale: 0.01
        precision: 2
        scan_interval: 10
      - name: SMApwr
        unit_of_measurement: kW
        slave: 3
        address: 30775
        count: 2
        data_type: int
        scale: 0.001
        precision: 2
        scan_interval: 10
      - name: SMAtotal
        unit_of_measurement: MW
        slave: 3
        address: 30529
        count: 2
        data_type: uint
        scale: 0.000001
        precision: 2
        scan_interval: 10
      - name: SMAtoday
        unit_of_measurement: kWh
        slave: 3
        address: 30535
        count: 2
        data_type: uint
        scale: 0.001
        precision: 2
        scan_interval: 10
      - name: SMAdevtype
        slave: 3
        address: 30053
        count: 2
        data_type: int
        scan_interval: 10
      - name: SMAgridrelay
        slave: 3
        address: 30217
        count: 2
        data_type: int  
        scan_interval: 10

Where can I find what is what?