Error while setting up modbus platform for sensor (SMA Sunny Boy Inverter)

Hello,

I am trying to configure ModBus to read some values from my SMA Sunny Boy inverter it is not working. when I look into the Logs I get this error. Apparently the modbus platform setup is not working. I am running HomeAssistant 2021.1.5 on a RPI 4B.

If I use a modbus simulator I can read the registers of the inverter. So I think the problem is with Home Assistant and not the inverter. Anyone have a hint on this?

Is hub1 the name of your hub?

Sorry. Tried hub1 to see if that was the issue but it stayed the same. Updated the actual error screen capture on top.

I do not have the line hub in the configuration.
From documentation it is optional and the default value is ‘default’

image

It looks like the error has something to do with the hub?

image

What’s the actual name of the hub? Try with this.

I do not have a hub. Not sure what that means or is. Do you know?

Ah okay. No I don’'t know, I’m sorry.

It is working now. For the benefit of others what I had to do was to setup a name in the modbus area and then use that name as the hub for each sensor in the registers section.

See example below:

modbus:
  name: SB7700TL
  type: tcp
  host: 192.168.XXX.XXX        # IP Address for SMA Inverter
  port: 502                    # TCP Port from Sunny Explorer

sensor:
   - platform: modbus
     scan_interval: 10         # Time in seconds for getting values
     registers:
    
    - name: sb_daily_pwr
      hub: SB7700TL
      unit_of_measurement: kWh
      slave: 3
      register_type: holding
      register: 30535
      scale: 0.001
      precision: 3
      count: 2
      data_type: uint

  - platform: template
    sensors:
    
      modbus_sb_daily_pwr:
        friendly_name: 'Day Yield'
        value_template: >-
          {{ states('sensor.sb_daily_pwr') }}
        unit_of_measurement: "KWh"
        icon_template: mdi:flash-circle    
        

Hope this helps!

1 Like