Energy dashboard not populating

So now I have the info in the energy dashboard I have the next problem… Why is this downward spike every day:

You need to use total_increasing.

The sensor’s value may reset to 0, and its value can only increase: state class total_increasing.

https://developers.home-assistant.io/docs/core/entity/sensor/#how-to-choose-state_class-and-last_reset

1 Like

Hi Tom, initially I just gave up. But now I am seeing these spikes again every day I wonder how I can get my energy dashboard functional again.

This is the behavior:

This is the device used:

This happens when the solar converter starts up every morning:

This I tried in the esphome sensor:

    energy_production_day:
      name: "${esp_name} - Today Gen"
      state_class: total
      #state_class: total_increasing # was empty
      # https://developers.home-assistant.io/docs/core/entity/sensor/#how-to-choose-state_class-and-last_reset

both state_class total and increasing both do not get the spikes away (tried a few days).

Is there any other thing to try?

edit:
this is my customize yaml:

sensor.growattmodbus_today_gen:
  #last_reset: '1970-01-01T00:00:00+00:00'
  #state_class: total_increasing
  state_class: total
  device_class: energy

Those spikes after the reset are causing your issue. Why are they occurring?

Cause the inverter is starting up. That only happens if there is “enough” light. And in the beginning there are some points of “just enough” (or not) light.

This is normal behaviour for an intverter.

This is not normal behaviour for an inverter. The integration needs to be fixed or the inverter settings need to be changed.

e.g. SMA inverter:

It is though. An inverter starts with light… and in the shade it sometimes starts but then stops and starts again. Same at the end of the day, it stops and starts a few times.
The pv panels just so not give enough to start and remain started.

Ik have at least 2 friends with other pv inverters (solis and solaredge) who have exactly this startup behavior.

Nevertheless, is there an option to keep the energy dashboard clean with this behavior?

Why is the inverter reporting yesterdays full energy total during these times it starts up intermittently?

Once it resets to 0 it can go on and off all it likes but it should still be reporting 0, or a very small amount at least. Not yesterdays total.

Nope. Garbage data in → garbage data out.

I suppose you could filter it with a template sensor but I’m not sure how.

Where to start to ask to “change this” in the esphome section for growatt modbus?

I used to use the custom component but now I use this code I need to aks the maintainer?

Same problem with and inverter:

Now I will try to reset the value to 0 every night in esp

time:
  - platform: homeassistant
    id: homeassistant_time
    on_time:
      # Every morning on weekdays reset ID todaygen
      - seconds: 0
        minutes: 30
        hours: 1
        days_of_week: MON-SUN
        then:
          - lambda: id(todaygen).publish_state(0);

This did not work. the inverter spits out bogus data in the startup phase. Alternately 0 and previous day gen until the inverter is completely running at 50Hz…

Ok so now I have another problem… the “spikes” are gone:

But I keep getting “spikes” in the energy dashboard. Now I also reset the value of the daily gen on 0:00 to 0 it shows me a negative spike:

What can I do to repair this?

Any help available here? Issue still persistent :unamused:

Hi Tom,

I tried your 2 tips:

  1. the integration needs to be fixed:
    I asked for help here:
    Spikes with integration growatt_solar · Issue #3965 · esphome/issues · GitHub

  2. inverters settings need to be changed:
    I contacted Growatt but I get no reply.

Can you help me on the way please? Is there a way to “filter out” via esphome the startup values?

Most likely in your sensor setup for esphome.

Indeed, but how?

well, start by posting your configuration for that esp device

I have now added some code I found on github. this “skips” the first 20 readings after ESP boot. But I doubt this will work because the ESP is already running when the inverter is starting up in the morning.

the current code:

esphome:

  name: growatt_modbus

  platform: ESP8266

  board: d1_mini

  on_boot:

    # set a default value for the skip counter, otherwise it's nan

    - sensor.template.publish:

        id: ${my_sensor}_skips

        state: 0

substitutions:

  esp_name: Growattmodbus

  my_sensor: my_sensor

wifi:

  ssid: "SSID"

  password: !secret wifi_key

  use_address: 192.168.6.42

  domain: !secret domain

  # Enable fallback hotspot (captive portal) in case wifi connection fails

  ap:

    ssid: "${esp_name} fb Hotspot"

    password: !secret Fallback_Hotspot

captive_portal:

# Enable logging

logger:

#  level: VERBOSE

#  baud_rate: 0

# Enable Home Assistant API

api:

ota:

time:

  - platform: homeassistant

    id: homeassistant_time

    on_time:

      # Every morning on weekdays reset ID todaygen

      - seconds: 0

        minutes: 0

        hours: 0

        #days_of_week: MON-SUN

        then:

          - lambda: id(todaygen).publish_state(0);

uart:

  - id: uart1

    baud_rate: 9600

    tx_pin: D1

    rx_pin: D2

#  stop_bits: 1

modbus:

  uart_id: uart1

 

web_server:

  port: 80

sensor:

  - platform: wifi_signal

    name: "${esp_name} - ESP WiFi Signal"

    update_interval: 60s

   

  - platform: uptime

    name: "${esp_name} - ESP Uptime"

    icon: mdi:clock-outline

    update_interval: 60s

   

  - platform: growatt_solar

    update_interval: 3s

    protocol_version: RTU2

    inverter_status:

      name: "${esp_name} - Status Code"

      id: inverter_status

    phase_a:

      voltage:

          name: "${esp_name} - AC Voltage"

      current:

          name: "${esp_name} - AC Current"

      active_power:

          name: "${esp_name} - AC Power"

          filters:

            - filter_out: NaN

    pv1:

      voltage:

          name: "${esp_name} - PV1 Voltage"

      current:

          name: "${esp_name} - PV1 Current"

      active_power:

          name: "${esp_name} - PV1 Power"

    pv2:

      voltage:

          name: "${esp_name} - PV2 Voltage"

      current:

          name: "${esp_name} - PV2 Current"

      active_power:

          name: "${esp_name} - PV2 Power"

    active_power:

      state_class: "measurement"

      name: "${esp_name} - Output Power"

      filters:

       - lambda: |-

           if (x <= 5500 && x >= 0) return x;

           else return 0;

       

       #- lambda: |-

       #    if (x <= 5500) return x;

       #    else return {};

    pv_active_power:

      name: "${esp_name} - Input Power"

    frequency:

      name: "${esp_name} - Grid Frequency"

    energy_production_day:

      name: "${esp_name} - Today Gen"

      id: todaygen

      filters:

      # increment a skip counter, this skips the first two measurements

      - lambda: auto s = id(${my_sensor}_skips); if(s->state > 20) { return x; } else { s->publish_state(s->state+1); return {}; }

      #filters:

      # - lambda: |-

      #     if (x >= 0) return x;

      #     else return 0;

         #lambda: |-

         #   if (id(inverter_status).state != 0) {

         #       return x;

         #   }

         #   return {};

      #  - lambda: "if (x - id(todaygen).state) > 0.5) return {}; return x;"

     

      # https://github.com/esphome/feature-requests/issues/607

      #- lambda: auto s = id(${todaygen}_skips); if(s->state > 100) { return x; } else { s->publish_state(s->state+1); return {}; }

    total_energy_production:

      name: "${esp_name} - Total Gen"

      #state_class: "measurement"

      #device_class: energy

      accuracy_decimals: 1

    inverter_module_temp:

      name: "${esp_name} - Temperature"

  # create a skip counter

  - platform: template

    id: ${my_sensor}_skips

    internal: true

    accuracy_decimals: 0

This is the original “problematic” code:

esphome:
  name: growatt_modbus
  platform: ESP8266
  board: d1_mini

substitutions:
  esp_name: Growattmodbus

wifi:
  ssid: "SSID"
  password: !secret wifi_key
  use_address: 192.168.6.42
  domain: !secret domain
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "${esp_name} fb Hotspot"
    password: !secret Fallback_Hotspot

captive_portal:

# Enable logging
logger:
#  level: VERBOSE
#  baud_rate: 0

# Enable Home Assistant API
api:

ota:

time:
  - platform: homeassistant
    id: homeassistant_time
    on_time:
      # Every morning on weekdays reset ID todaygen
      - seconds: 0
        minutes: 0
        hours: 0
        #days_of_week: MON-SUN
        then:
          - lambda: id(todaygen).publish_state(0);

uart:
  - id: uart1
    baud_rate: 9600
    tx_pin: D1
    rx_pin: D2
#  stop_bits: 1

modbus:
  uart_id: uart1
  
web_server:
  port: 80

sensor:
  - platform: wifi_signal
    name: "${esp_name} - ESP WiFi Signal"
    update_interval: 60s
    
  - platform: uptime
    name: "${esp_name} - ESP Uptime"
    icon: mdi:clock-outline
    update_interval: 60s
    
  - platform: growatt_solar
    update_interval: 3s
    protocol_version: RTU2

    inverter_status:
      name: "${esp_name} - Status Code"
      id: inverter_status

    phase_a:
      voltage:
          name: "${esp_name} - AC Voltage"
      current:
          name: "${esp_name} - AC Current"
      active_power:
          name: "${esp_name} - AC Power"
          filters:
            - filter_out: NaN
    pv1:
      voltage:
          name: "${esp_name} - PV1 Voltage"
      current:
          name: "${esp_name} - PV1 Current"
      active_power:
          name: "${esp_name} - PV1 Power"

    pv2:
      voltage:
          name: "${esp_name} - PV2 Voltage"
      current:
          name: "${esp_name} - PV2 Current"
      active_power:
          name: "${esp_name} - PV2 Power"

    active_power:
      state_class: "measurement"
      name: "${esp_name} - Output Power"
      filters:
       - lambda: |-
           if (x <= 5500 && x >= 0) return x;
           else return 0;
       
       #- lambda: |-
       #    if (x <= 5500) return x;
       #    else return {};

    pv_active_power:
      name: "${esp_name} - Input Power"

    frequency:
      name: "${esp_name} - Grid Frequency"

    energy_production_day:
      name: "${esp_name} - Today Gen"
      id: todaygen
      filters:
       - lambda: |-
           if (x >= 0) return x;
           else return 0;
         #lambda: |-
         #   if (id(inverter_status).state != 0) {
         #       return x;
         #   }
         #   return {};

      #  - lambda: "if (x - id(todaygen).state) > 0.5) return {}; return x;"
      
      # https://github.com/esphome/feature-requests/issues/607
      #- lambda: auto s = id(${todaygen}_skips); if(s->state > 100) { return x; } else { s->publish_state(s->state+1); return {}; }

      #state_class: total
      #state_class: total_increasing # was empty
      # https://developers.home-assistant.io/docs/core/entity/sensor/#how-to-choose-state_class-and-last_reset

    total_energy_production:
      name: "${esp_name} - Total Gen"
      #state_class: "measurement"
      #device_class: energy
      accuracy_decimals: 1

    inverter_module_temp:
      name: "${esp_name} - Temperature"