How to avoid this peak in my solar production?

Hi,

This is what I want to avoid :

I know the reason, but I don’t know how to avoid it…

I have a helper in HA that holds the produced energy of my solar panel : input_number.number_solar_panel_1

In made a ESPHome device that counts the energy produced :

  - platform: pulse_counter
    pin: GPIO25
    id: t1
    unit_of_measurement: 'W'
    accuracy_decimals: 1
    name: 'Solar Panel Power Counter 1'
    update_interval: 10s
    filters:
      - multiply: 60    
    # - multiply: 0.06 gives kW
    total:  
      unit_of_measurement: 'kWh'
      accuracy_decimals: 3
      name: 'Solar Panel Energy Counter 1'
      id: t1_total
      filters:
        - multiply: 0.001

So I get this sensor in HA : sensor.solar_panel_energy_counter_1

When I add these together I get my total produced energy :

- sensor:
    - name: Energy Solar Panel 1
      unique_id: energy_solar_panel_1
      state: "{{ ((states('sensor.solar_panel_energy_counter_1') | float(0)) + (states('input_number.number_solar_panel_1') | float(0))) | round(1) }}"
      unit_of_measurement: "kWh"

At midnight (or when I have to update my ESPHome device) I initialize my counters (I use a zone input_number.number_solar_panel_initialisation_1) :

          - data:
              value: "{{ states('input_number.number_solar_panel_initialisation_1') }}"
            target:
              entity_id: input_number.number_solar_panel_1
            action: input_number.set_value
          - data:
              new_pulse_total: 0
            target: {}
            action: esphome.solar_panels_set_pulse_total1

The problem is that the sensor.energy_solar_panel_1 first jumps (because input_number.number_solar_panel_1 increases) and than reduces back to the correct value (because sensor.solar_panel_energy_counter_1 is set to zero).

Any idea how to avoid this ?

I don’t understand the need for the input number.

In my garage I have a physical counter like this (not the same, but it’s the idea) :

When there was no solar production I copied the number of that physical counter to my input_number.number_solar_panel_1, that’s my start value.
The solar production after that is hold by sensor.solar_panel_energy_counter_1

Delete this:

And in ESPHome change your sensor to this:

 - platform: pulse_counter
    pin: GPIO25
    id: t1
    unit_of_measurement: 'W'
    accuracy_decimals: 1
    name: 'Solar Panel Power Counter 1'
    update_interval: 10s
    filters:
      - multiply: 60    
    # - multiply: 0.06 gives kW
    total:  
      unit_of_measurement: 'kWh'
      accuracy_decimals: 3
      name: 'Solar Panel Energy Counter 1'
      id: t1_total
      filters:
        - multiply: 0.001
        - offset: 42424242 # your initialisation value here whenever you update

The other way you could do it is to use a utility meter, either in YAML or via the UI in the helpers section:

utility_meter:
  solar_energy:
    name: Solar Energy
    source: sensor.solar_panel_energy_counter_1

You can then use the utility_meter.calibration action to set the value to whatever you want. You can do this in an automation at midnight or manually in Developer Tools → Actions

- action: utility_meter.calibrate
  entity_id: sensor.solar_energy
  value: 4242424242

Thank you Tom, I will have a look at that this evening.

What I already wonder, is it possible to put the calibration value (4242424242) in a helper and use that helper in that action (avoiding hard coded) ? Like this :

          - action: utility_meter.calibrate
            entity_id: sensor.solar_energy_counter_1
            value: "{{ states('input_number.number_solar_panel_initialisation_1') }}"

Why?

That just seems like adding needless complexity.

Well, when there is an update of Esphome builder it automatically updates my esphome devices.

I know that in that case the counter in my esphome device is set to zero.

input_number.number_solar_panel_initialisation_1 contains the right calibration value, so…

No it doesn’t. You have to manually initiate that, just be fore you do update the calibration value in the esphome file instead of using an extra helper.

However if the ESPHome sensor is reset to 0 and you set it to some larger value that will always glitch the energy dashboard. Just setting to 0 is ok, it’s the setting to some larger value that is the problem.

The same glitch will happen in the Utility Meter.

Why do the two meters have to match?

The energy dashboard only cares about relative changes.

Hi Tom,

I still owed you an answer, but wanted to wait a bit until I was sure everything worked…

The government gives me money for every 1000 kWh that my solar panels produce. So I also use that counter to automate this.

In the meantime I have found how I wanted it and it works perfectly! On the one hand I keep track of the total in a helper. When my ESPHome device comes “from unavailable” (such as during an update), I do a calibration with the help of my helper.

Thank you very much for the help!

But you only need to know how much you produced per billing period, not the absolute meter readings.