SBFspot sma inverter, MQTT and wrong energy dashboard values

I am using Home Assistant with the latest release (2022.08).
Also I am using SBFspot on a pi to collect data from my solar inverters via LAN (not bluetooth).
I used instructions like these

It’s working so far. The data I got are correct.

But when I am integrate the sensor in the energy dashboard the values are wrong during the day.
3 or 4 hours a day the kWh output is far too high and I do not know why that’s happening. On my west side I have 3,2 kWp solar power. So 17 kWh in one hour is not possible :wink:
Attached a screenshot from today.

Also my configurations:

sensor Solar:
 - platform: mqtt
    state_topic: "sbfspot_"ID""
    name: "Ost - WR Total Leistung"
    value_template: "{{ value_json.ETotal }}"
    last_reset_topic: "sbfspot_"ID""
    last_reset_value_template: '1970-01-01T00:00:00+00:00'
    unit_of_measurement: kWh
    device_class: energy
    state_class: total_increasing
    icon: mdi:solar-power


    name: SMA Inverter
     - sensor.ost_wr_total_leistung

sensor.ost_wr_total_leistung is my sensor for the solar energy dashboard.

What is wrong here?
Why are some hours the produced solar power calculated wrong?

Thanks in advanced

Mh… I do not know what you mean.
Yaml for the sensor?

Today were 9 hours with wrong values.
Energy dashboard counted 98.376,1 kWh power :smiley:
But the east site produced 12 kWh today.

I have also a sensor for “today total power”.
But the values are also wrong for some hours a day as with the total value.

Could I use in some way the current power?
It’s counted in Watts.
So caluclating that in one hour I should geht kWh and use that for the energy dashboard?!

Sorry ignore my earlier question it was late…

Your last reset value template is not finding its target, and being ignored i think (there might be an error in logs.)

last_reset_value_template string (optional)
Defines a template to extract the last_reset. Available variables: entity_id. The entity_id can be used to reference the entity’s attributes.

mqtt had some rearrangement not so long ago.

MQTT Sensor - Home Assistant

Old style
  - platform: mqtt
    state_topic: "home/bedroom/temperature"

New style
    - state_topic: "home/bedroom/temperature"

This is how I set up my energy total - example SBFspot sensors

         - name: "SMA Total Energy"
           state_topic: "homeassistant/sbfspot_YourPlantName/sbfspot_YourSerial"
           value_template: '{{ value_json.ETotal }}'
           unit_of_measurement: "kWh"
           device_class: energy
           state_class: total_increasing
1 Like

Thanks a lot.
Changed it.
We will see tomorrow.

I don’t know whats going on here.
I changed it like your example.
Removed entries in groups.yaml.
Sensors are working. I am getting correct values.
Just the energy dashboard calculates wrong values.
Couple of hours the data are correct and some hours it’s far too high. Over 20 000 kWh and so on.
Here a screenshot from today.
The data are correct here.

And again a screenhot of the energy dashboard

Again my configs:

    - name: "Ost - WR Total Energy"
      state_topic: sbfspot_ID
      value_template: "{{ value_json.ETotal }}"
      unit_of_measurement: kWh
      device_class: energy
      state_class: total_increasing
      icon: mdi:solar-power
    - name: "West - WR Total Energy"
      state_topic: sbfspot_ID
      value_template: "{{ value_json.ETotal }}"
      unit_of_measurement: kWh
      device_class: energy
      state_class: total_increasing
      icon: mdi:solar-power

I guess I let the energy dashboard without PV output.

perhaps a retained value in mqtt. have a look with mqtt explorer.
Retained values make it jump around on restarts.

I think the problem is:
Sometimes there are no values.
Cronjob runs every 5 minutes. And sometimes there are no values, so 0.
And next run there are values again I think the energy dashboard calculates wrong!?

I don’t know why there are sometimes no values …

Looked with mqtt explorer.
One mqtt transmission I saw:

"InvTime": "01/01/1970 01:00:00"
"InvStatus": "?",
"InvTemperature": 0.000,
"InvGridRelay": "?",
"EToday": 0.000,
"ETotal": 0.000,
"PACTot": 0.000,
"UDC1": 0.000,
"UDC2": 0.000,
"IDC1": 0.000,"
IDC2": 0.000,
"PDC1": 0.000,
"PDC2": 0.000}```

Zero values are expected outside of solar production. Eg at 1am 01:00:00

The date time on your inverter shouldn’t be 01/01/1970 01:00:00.

Do you have sync time set? I usually leave it off, but my inverter has the correct time. Does your log of SBFspot show the actual time.

Current Inverter Time: 12/08/2022 09:00:09
Inverter Wake-Up Time: 12/08/2022 07:04:29
Inverter Sleep Time  : 12/08/2022 09:00:11

Similar behavior with my setup. On some days the energy counter adds the total production to the daily production.

I checked the logs of sbfspot on the days, and the messages published to the mqtt topic are normal.

Here my config:

sensor solar:
  - platform: mqtt
    state_topic: "sbfspot_xxx"
    name: "Inverter Total Yield"
    value_template: "{{ value_json.ETotal }}"
    #last_reset_topic: "sbfspot_xxx"
    last_reset_value_template: '1970-01-01T00:00:00+00:00'
    unit_of_measurement: kWh
    device_class: energy
    state_class: total_increasing
    icon: mdi:solar-power

With the hint above to use mqtt explorer, I can see that there is a retained message:

  "Timestamp": "23/08/2022 20:40:01",
  "SunRise": "23/08/2022 06:29:00",
  "SunSet": "23/08/2022 20:25:00",
  "InvSerial": xxx,
  "InvName": "STP 9000TL-20 764",
  "InvTime": "23/08/2022 20:40:08",
  "InvStatus": "Ok",
  "InvTemperature": 0,
  "InvGridRelay": "Information not available",
  "EToday": 52.145,
  "ETotal": 48454.82,
  "PACTot": 0,
  "UDC1": 0,
  "UDC2": 0,
  "IDC1": 0,
  "IDC2": 0,
  "PDC1": 0,
  "PDC2": 0

Can someone help me how to configure the mqtt (by pointing to an article, e.g.)? Shall I stop retaining them? Thank you in advance.

Retained messages don’t play well with statistics/energy dash. Statistics does some maths over a period of time and then outputs the value. Which is why there is a delay in the beginning. When a retained message is found it throws out the maths, because of the diffence in the retained value and the expected value.

The main benefit of retained messages is for when HA restarts. It doesn’t have to wait for a value. So when you look your inverter sensors they don’t all say “unknown”. SBFspot only takes data from your inverter every 5 mins during the day and stops overnight(depending on how it’s setup). So when you restart you will be waiting for a new message to show up before your sensors switch from unknown to a proper value. That could be potentially until morning and the first new day data arrives.

You can use -finq to force an enquiry to get values over night or on boot.

-r is generally the retained flag. Although not sure what you have setup. You can remove the flag and delete the retained message.

Thank you. I removed the -r option and deleted the retained message. Ich will report back n some weeks if another of the wrong values appeared in the dashboard.

I am in the process of adding sensors directly into my SBFspot addon, if you want to test that.

The sensors will become available in the next update… still testing.
It should already be working for Ethernet inverters… that needs testing however.

Open your Home Assistant instance and show the add add-on repository dialog with a specific repository URL pre-filled.

Hmm thinking about it… I may even do a sensor only option…

1 Like

I had some good values the last 3 weeks, when the sun shined the whole day.
Last days we had rainy days and the inverter didn’t work.
When the cronjob runs (every one hour) I got zero values.
So I got wrong values again.

You need to figure out why you are getting 0 values for ETotal. Even if the inverter isn’t producing power it should still be able to send out a non zero ETotal value.

This shouldn’t stop your inverter working… converting solar sure, but it should still work and be able to send values out.

It would probably also be good to filter out the 0 values before you send it to the dashboard.

I don’t know why my sbfspot is doing that.
For sure my inverter still operates but I geht zero values and the date 1970.

How can I filter the 0 values?
So I would just filter the 0 values and that should be fine.

Is your sync time resetting your inverter time or something?
ETotal should be cumulative, it should be putting out energy produced since the day the inverter was installed. I didn’t notice when you posted a few weeks back that ETotal was also putting out zero values.

What do you have in your sync time setting for SBFspot.cfg and what time is on the inverter and what time is it trying to sync to?

Probably best to turn off time sync with sbfspot and set the correct time on your inverter.

To filter you would need to do something like this.
You need to figure out the time thing first though I think, otherwise you can’t really make the filter if you are having daily ETotal values starting at zero.

1 Like