Unable to Read Data rom SMA Solar Inverter

Guys, I’m trying to read data from my Sunny Boy 7.7TL inverter via Modbus over TCP. I thought I’d try with a single parameter to begin with (to get my feet wet), but I can’t even get that to work!

I can access the inverter using a free (Windows-based) simulator and see data that looks valid (screenshot at the end of post), so I know all is good on the network and inverter-side. However, when I try to read the data in HA, that’s when my problems begin.

I have a simple entry in configuration.yaml to read a single data field - in this case, Power AC. The entry in configuration.yaml is:

  - name: SMA
    type: tcp
    port: 502
      - name: sma_power_ac
        state_class: measurement
        unit_of_measurement: W
        slave: 3
        address: 30775
        count: 2
        data_type: uint32
        scan_interval: 10

In templates.yaml, I have:

- sensor:
    - name: SMA Power
      state: "{{(states('sensor.sma_power_ac') | float(0) + 1.0)}}"
      unit_of_measurement: "W"
      unique_id: c7310e44-451b-11ee-be56-0242ac120003

(The + 1.0 is only there as a sanity check to make sure something is being loaded into the sensor value in the event of zero data from the inverter. It’s purely temporary until I debug this problem.)

This is what I get in the HA States:

So, clearly it’s seeing a value of zero (0) and adding the 1.0.

The question is: why is it zero?

If I run a simulator and interrogate the inverter from my Windows machine, I get:

Screen Shot 2023-09-07 at 1.28.27 PM

which shows a value of 7076, which would be the correct wattage output from my inverter at this time of day.

Really confused and looking for some kind of hint.


It should be straight forward if you’ve proven communication with a client in Windows.

Not sure count: 2 is consistent with uint32 - i’d rather understood they say the same thing. Only uint32 is the equivalent of count:4. Just get rid of count:2… And possibly also uint:32 . I think the default is uint16 anyways and that’s fine if your integer data is held in a single register. I’m no expert though. Floats would need to be uint32 typically for my inverter.

Can’t remember why but I also specify input type: input in my config.

By the way my modbus had gone to hell in a hand cart today with the latest September core update so I’ve had to revert. Modbus bombing out altogether after unpacking errors. Wouldn’t want to be debugging a new setup with that going on in the background.

Thanks for the prompt reply.

  • I commented out data_type line - no change
  • I commented out the count line - no change
  • I added in input_type: input - no change

The Windows-based tool does show:
Count = 2,
Data type = Integer
Input_type = “Holding” (not Input)

Go figure.

Couple of slightly dumb questions - Have you checked the state of sma_power_ac?

And whats your “simulator” up to? I use qmodmaster for the verifying my waveshare rs485 module so I’m not familiar with your screenshot. Is that reading 10 registers starting from 30775? If so would the 7076 response be coming from register 30776?

The simulator is a free Windows-based product. I forget its name, but it was easy to find on Google. (My home is purely 100% Apple, so it runs in a VM on one of my Macs.)

I believe you’re right in that the data is in physical register 30776. But, my base address is 30775 and I’m supposed to be reading two (16-bit) registers concatenated (“count: 2”), so effectively I’m looking at a single 32-bit register…so that shouldn’t be an issue.

I think one of my problems as a newbie is that I don’t understand how to directly access the ‘sensor’ created under the mobus section of my configuration.yaml. (That would be the sensor with the name ‘sma_power_ac’.) If I could do that, then I’d get a better idea of what data HA is actually returning to me and I could then make the determination whether it was an HA problem, or simply my incompeten coding. :grinning:


So is that sensor not showing up in Developer Tools>States? If it was unavailable I think your code would just throw a wobbler so I think it exists with state 0.

I gotta say it looks like you just need to be reading 30776 as uint16 and forget the count thing.

You’re pretty much there I reckon. Keep going - it’s absolutely worth controlling your solar system with modbus. You’ll save significant cash optimising it’s function.

So, I’m having some success. I managed to create a mobus.yaml and put all the requests for data in there, and then in my sensor.yaml, I simply have:

- platform: modbus
    - name: sma_power_generated
      source: sensor.sma_power_generated
    - name: sma_grid_freq
      source: sensor.sma_grid_freq
    - name: sma_total_production
      source: sensor.sma_total_production
    - name: sma_apparent_power
      source: sensor.sma_apparent_power
    - name: sma_reactive_power
      source: sensor.sma_reactive_power
    - name: sma_power_absorbed
      source: sensor.sma_power_absorbed
    - name: sma_daily_yield
      source: sensor.sma_daily_yield
    - name: sma_status
      source: sensor.sma_status

Which returns:

I’m still fighting with the last entry (power absorbed). My windows tool returns a -32768 as a value, and the SMA specs show this as S32 (signed int32, or simply int32 in HA-speak). Not sure what’s going on here. (Maybe it’s some weird SMA error code that says the inverter doesn’t support this parameter, but I doubt it.)

Will keep at it.