For some weird reason, my energy dashboard show some negative entities. That do not have negative values. Any good ideas ?
If you look closely at this You will see it is not strictly increasing:
That could be causing your issue.
Is this a template sensor?
If so, please share the configuration.
- sensor:
- name: "Ventilation Laser - Energy Total"
unique_id: ventilation_laser_energy_total
state: >-
{% set sensorventilation_laserstate_total =
[ states('sensor.ventilation_laser_svejs_importenergy_a'),
states('sensor.ventilation_laser_svejs_importenergy_b'),
states('sensor.ventilation_laser_svejs_importenergy_c'),
] | map('float') | sum
%}
{{ sensorventilation_laserstate_total }}
# availability: >-
# {{
# [ states('sensor.shelly_shem_3_244cab41b39c_1_total_consumption'),
# states('sensor.shelly_shem_3_244cab41b39c_2_total_consumption'),
# states('sensor.shelly_shem_3_244cab41b39c_3_total_consumption'),
# ] | map('is_number') | min
# }}
unit_of_measurement: kWh
device_class: energy
state_class: total_increasing
- sensor:
- name: "Ventilation Laser - Energy Usage"
unique_id: ventilation_laser_energy_usage
state: >-
{% set sensorventilation_laserstate_usage =
[ states('sensor.ventilation_laser_svejs_power_a'),
states('sensor.ventilation_laser_svejs_power_b'),
states('sensor.ventilation_laser_svejs_power_c'),
] | map('float') | sum
%}
{## Return 0 if value is negateive ##}
{% if sensorventilation_laserstate_usage > 0 %} {{ sensorventilation_laserstate_usage }} {% else %} 0 {% endif %}
# availability: >-
# {{
# [ states('sensor.shelly_shem_3_244cab41b39c_1_current_consumption'),
# states('sensor.shelly_shem_3_244cab41b39c_2_current_consumption'),
# states('sensor.shelly_shem_3_244cab41b39c_3_current_consumption'),
# ] | map('is_number') | min
# }}
unit_of_measurement: W
device_class: power
state_class: total
If the device is shut off, there’s no consumption. It’s a template sensor.
You definitely need an availability template that ensures all sensors are available.
availability: >
{{
states('sensor.shelly_shem_3_244cab41b39c_1_total_consumption')|is_number and
states('sensor.shelly_shem_3_244cab41b39c_2_total_consumption')|is_number and
states('sensor.shelly_shem_3_244cab41b39c_3_total_consumption')|is_number
}}
Like this
state: >-
{% set sensorventilation_laserstate_total =
[ states('sensor.ventilation_laser_svejs_importenergy_a'),
states('sensor.ventilation_laser_svejs_importenergy_b'),
states('sensor.ventilation_laser_svejs_importenergy_c'),
] | map('float') | sum
%}
{{ sensorventilation_laserstate_total }}
availability: >-
{{
[ states('sensor.ventilation_laser_svejs_importenergy_a'),
states('sensor.ventilation_laser_svejs_importenergy_b'),
states('sensor.ventilation_laser_svejs_importenergy_c'),
] | map('is_number') | min
}}
Yeah that should work, though your indentation is not right. availability:
should be at the same level as state:
.
Of course. I’ll try that
I have the same problem but with some helper.
They where reset to 0 !?!?
how can that happen and how do I get it fixed?
Change the values in the DB? I have a little knowledge about DB queries but not so much.
Tanks a lot in advanced for your help
Lynn
In dev. tools statistics you can correct values. I ended up, discarding all negative and zero values to fix mine
- sensor:
- name: "125 - Energy Total"
unique_id: 125_energy_total
state: >-
{% set incommingValue125 = [
states('sensor.shelly_shem_3_34945474845e_1_total_consumption'),
states('sensor.shelly_shem_3_34945474845e_2_total_consumption'),
states('sensor.shelly_shem_3_34945474845e_3_total_consumption')
]|map('float')|sum|int
%}
{% if incommingValue125 > 0 %}
{{ incommingValue125 }}
{% endif %}
availability: >-
{{
[ states('sensor.shelly_shem_3_34945474845e_1_total_consumption'),
states('sensor.shelly_shem_3_34945474845e_2_total_consumption'),
states('sensor.shelly_shem_3_34945474845e_3_total_consumption'),
] | map('float') | sum > 0
}}
unit_of_measurement: kWh
device_class: energy
state_class: total_increasing