Hello,
i have the problem that home assistant energy is showing wrong values.
For example if my photovoltaic produced 2.4kWh, import/bought 1.24kWh and exported nothing it shows wrong values like in the screenshot. The data is coming over mqtt.
there is the customize.yaml file:
sensor.pv_energy_today:
last_reset: '1970-01-01T00:00:02+00:00'
device_class: energy
state_class: measurement
sensor.energy_import:
last_reset: '1970-01-01T00:00:02+00:00'
device_class: energy
state_class: measurement
sensor.energy_export:
last_reset: '1970-01-01T00:00:02+00:00'
device_class: energy
state_class: measurement
I didn’t found a solution so far.
How can i fix it?
10k-resistor
tom_l
August 16, 2021, 5:43am
2
The problem is that your solar consumption energy sensor is resetting to 0 rather than continuously increasing.
You are using the daily PV yield sensor instead of the total PV yield sensor.
1 Like
volkus
(Volkus)
August 16, 2021, 8:23am
3
I have the same problem. But I set the last_reset value each day to the correct date time value. That has no influence.
galamarco
(Marco Galassi)
August 16, 2021, 10:25am
4
I have the same problem of negative data without solar device, how can I solve it?
1 Like
tom_l
August 16, 2021, 10:26am
5
As I said:
You need to use the total yield sensor. Not the daily yield sensor.
1 Like
tom_l
August 16, 2021, 1:52pm
6
There have been some changes to the attributes that should allow you to use a daily sensor like that once they have been merged:
OzGav
(Oz Gav)
August 17, 2021, 11:33pm
7
I’m currently using pvoutput to get my solar energy generation. Since that only returns a daily running total I have knocked up an automation and some sensors to track the running total Is there a better way than this?
template:
- sensor:
- name: "Power Generation"
unit_of_measurement: "W"
state_class: "measurement"
device_class: "power"
unique_id: pvoutput_power_generation
state: '{% if is_state_attr("sensor.pvoutput", "power_generation", "NaN") %}0{% else %}{{ states.sensor.pvoutput.attributes.power_generation }}{% endif %}'
- sensor:
- name: "Solar Energy Running Total"
unit_of_measurement: "kWh"
state_class: "measurement"
device_class: "energy"
attributes:
last_reset: "1970-01-01T00:00:00+00:00"
unique_id: solar_energy_running_total
state: 0
input_number:
solar_generation_daily_last_update:
step: .001
unit_of_measurement: kWh
min: 0
max: 30
automation:
- alias: calculate_running_solar_generation
id: calculate_running_solar_generation
trigger:
- platform: state
entity_id: sensor.energy_generation
action:
- service: python_script.set_state
data_template:
entity_id: sensor.solar_energy_running_total
state: "{{ (states('sensor.solar_energy_running_total') | float) + (states('sensor.energy_generation') | float) - (states('input_number.solar_generation_daily_last_update') | float) }}"
- service: input_number.set_value
target:
entity_id: input_number.solar_generation_daily_last_update
data:
value: "{{ states('sensor.energy_generation') }}"
Python script from here How to manually set state/value of sensor? - #3 by rodpayne
dheat
(Dan)
August 17, 2021, 11:37pm
8
There are three main inputs - solar, grid usage (or ‘in from the grid’) and energy export (or ‘out to the grid’). Should any of these be negative? Right now I have all of mine set to result as positive (I use IotaWatt and can modify if the result shows negative or positive).
galamarco
(Marco Galassi)
August 26, 2021, 9:40am
9
I’m using a sensor.boiler_energy (from “Meross LAN” integration):
state_class: measurement
last_reset: '1970-01-01T00:00:00+00:00'
unit_of_measurement: Wh
friendly_name: Boiler - energy
device_class: energy
Here the abnormal data in Energy tab: https://www.webg.it/images/articoli/2021-08/Screenshot_22.png
This is the graph of this sensor: https://www.webg.it/images/articoli/2021-08/Screenshot_21.png
You need to use the total yield sensor
Ok, how can I collect data in a new sensor compatible with Energy? Can you give me an example please?
Thanks
Marco
tom_l
August 26, 2021, 9:50am
10
Wait for the next release of Home Assistant. This should fix the last_reset
issues.
galamarco
(Marco Galassi)
August 26, 2021, 10:24am
11
The next release will prevent resetting data every day?
tom_l
August 26, 2021, 10:46am
12
No, but it will deal with those resets better.
ihr
(Ignacio Hernandez-Ros)
August 26, 2022, 9:15am
13
I created this topic today, I think I know a little bit about the origin of the negative values
Hi,
I found out today something “incorrect” in my statistics but I think I know what happened. I’m sending this email as feedback to the HA team for them to take a look at this and maybe fix the calculation of the “sum” column in the database.
The history:
I’ve a binary sensor installed in the gas counter. It counts every turn of the counter using a magnet.
I’ve one automation counting on-off transitions of that counter and accumulating the values in a counter
That counter is used as the sou…
ottelo
September 1, 2022, 3:43pm
14
I’ve the same problem but its very weird. In the “Year” view I see the negative consumption in may. If I go to May in the Month view I cant see negative values but there is very low consumption for 1-4 May and for 5. there is always 0 if I check via developer → statistics → total_in entity.
Year View
Month View
If I look at the consumption for May I got very high values.
I can edit the values for the 5. May but they will not be accepted (stay 0).