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).
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
- 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
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 :
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.
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.