I hope you can help me out with this. I think the issue is mainly me not understanding how the Energy dashboard is working and therefore not able to understand how to solve the situation.
Some context to all of these. Lately we have been having a lot of storms around and unfortunately it came with few power loss for the whole house.
I have a dongle connected directly to the power meter that feeds data to my HA, that in turn is used for the Energy Dashboard. When the Power meter loses power, so does the dongle.
More details:
I’m using Z2M (latest version, don’t think it matters)
My HA is connected to an UPS therefore continues to work and receive data during the power loss. I think this is where the problem lies to be fair but you (attentive and hopefully more knowledgeable reader) will hopefully correct me.
This is an example of what happens if I look at the sensor:
Every time I lose power, the sensor goes to 0 momentarily then back to the original value. This obviously results in crazy values like these:
Can someone help me understand the logic behind the Energy Dashboard so that I can come up with an answer to my problem. I’ve been reading some similar issues that mention the solution would be Riemann sum integral sensor, but since I don’t understand the root cause, I don’t want to do things blind.
If you have reached the end of this, thank you! (even if you don’t have an answer for me)
If your sensor goes from some total to zero then back to the total, then that total amount is added to your dashboard.
If your sensor goes from some total to unavailable/unknown then back to the total, then that total amount is not added to your dashboard.
If you can’t make this happen with the integration you are using to connect your sensor then you need to filter the values using a template sensor and feed that to the energy dashboard instead. There are many topics on doing this.
template:
- sensor:
- name: "Grid Consumption High Fare"
unit_of_measurement: "kWh"
device_class: energy
state_class: total
icon: "mdi:transmission-tower-export"
state: >
{% set energy_gchf = states('sensor.lixee_easf02') | float(none) %}
{% if energy_gchf is not none %}
{{ energy_gchf }}
{% else %}
None
{% endif %}
- name: "Grid Consumption Low Fare"
unit_of_measurement: "kWh"
device_class: energy
state_class: total
icon: "mdi:transmission-tower-export"
state: >
{% set energy_gclf = states('sensor.lixee_easf01') | float(none) %}
{% if energy_gclf is not none %}
{{ energy_gclf }}
{% else %}
None
{% endif %}
- name: "Return to Grid"
unit_of_measurement: "kWh"
device_class: energy
state_class: total
icon: "mdi:transmission-tower-import"
state: >
{% set energy_rtg = states('sensor.lixee_eait') | float(none) %}
{% if energy_rtg is not none %}
{{ energy_rtg }}
{% else %}
None
{% endif %}
- name: "Current Solar Production"
unit_of_measurement: "Wh"
device_class: energy
state_class: total
icon: "mdi:solar-power-variant-outline"
state: >
{% set energy_csp = states('sensor.envoy_122238059516_today_s_energy_production') | float(none) %}
{% if energy_csp >= 0 %}
{{ energy_csp }}
{% else %}
None
{% endif %}
I will test this for a couple of days see if that works out. Tomorrow when I have some data in the middle of the day I will disconnect the dongle to simulate power loss and see if that works.
If someone sees this and cares to comment let me know.
I noticed that with this integration (different from the three other sensors), when there is a power loss, sometimes I have a negative value of -1. That is why I tested for >= 0, I take it from your previous comment it will not work either.
Yes you can but make it strictly greater than 0. Not greater than or equal to zero. remember we want to filter out zeros as well (when the float filter default is applied to non-numeric values).