SMA modbus values too high

Hi

I have configured a SMA solar inverter via modbus, works great.
But every night the values goes crazy high, and it´s every value configured.

Here´s the config

modbus:
  - type: tcp
    host: 192.168.1.10
    port: 502
    name: "sma"
    close_comm_on_error: true
    delay: 5
    timeout: 5
    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

Anyone knows what is going on?

Maybe it’s an inverter issue.

Use filters or templates

Double check your data_types to ensure they are correct.

same issue since some weeks, I suppose that homeassistant side something is changed on uint32 datatype, something related to zerovalue. if you check when you line is near zero value, you will see the real production.
I didn’t found final solution yet, if I use nodered instead of modbus.yaml it seams working fine.

    delay: 1
    timeout: 3
    retries: 3
    retry_on_empty: true
    message_wait_milliseconds: 250

what is it?

I have the same issue here. To be honest, I think the output values are not the fault of HASS. I used to use emoncms (Open Energy Project) to read the MODBUS registers of my SMA inverter and they produced the same high values once the unit is asleep.

Not all registers do this, for example the Total Yield, Operating Time accumulators and static values such as the serial number, max power configuration all report correctly, but the measurement registers all seem to report the maximum allowable value of the data type during this sleep state.

I don’t want to use NodeRed for this, I’m trying to reduce the number of processes required to gather information into my HASS implementation, hence why I’m trying to move my MODBUS ingest away from EmonCMS (and forwarding via integration) directly into HASS.

In EmonCMS, I had the opportunity to perform some functions on values as they came through, and a simple filter that disallowed negative values (most of the measurement registers are unsigned 32 bit integers and result in -2147483648 during the sleep phase). This worked perfectly as it read the measurements when active, and ignored them / recorded 0 when a negative value was returned.

Question is, how to replicate this in HASS. I could do it with a template, but that means recording the RAW sensor values into HASS and then creating a template with the adjusted values for each measurement register which I’d rather not do if there is a simple way to set the template in the MODBUS configuration.

Anyone know how to apply a template to the sensor configuration?

Found it… The modbus sensors support a min_value: max_value and a NaN_value:

See documentation here:

Couple of sensors sampled from my SMA STP25000-TL30 modbus registers with examples of the settings I’ve used. Hopefully might help someone else who needs to understand all the settings! Spent a few hours working them out myself, so hopefully useful to someone else…

Sleeping registers reporting “unavailable” now when the unit is not measuring…

      - name: SMATripower1_power_L3
        slave: 3
        address: 30781
        data_type: int32
        scale: 1
        unit_of_measurement: W
        device_class: power
        nan_value: -2147483648
      - name: SMATripower1_grid_voltage_L1
        slave: 3
        address: 30783
        data_type: uint32
        scale: 0.01
        unit_of_measurement: V
        device_class: voltage
        nan_value: 4294967295
1 Like

Thank you - you saved my day! :wink: