You welcome, im glad i could help you
On to something else: Is it possible to give energy measurement devices a “class” so i can see a breakdown of my energy use (example, having energy going to heating being colored in red in the bar, and the rest having the standard blue color?) or eventually coloring different individual devices in a different color?
Well u probably could use grafana to do this together with influx db.
Or just use code editor.
for example: By assign the current sensor.energy to blue and other sensor.energy to red, so classes are not needed.
Or use the attributes of a sensor if they have one, containing your data what u need
You ask too much for a v1.0 version of an integration. But you can open a Feature Request on github.
Remember that an official integration can never cover all use-cases, but it has to be structured in a flexible way, so that everybody can use data as they prefer. And I think they’re on the right track.
Since data is in the statistics long-term db, I’m sure you will be able to do many things by yourself, with grafana and other tools.
Hi all.
I have few question about this integration that I can’t find answers in documentation.
- According to documentation one of the possible state_class values should be “total_increasing” which would be perfect as I assume most energy measuring devices (at least the ones I encountered) provide only cumulative reading for kWh. But I can’t get it to work. Anyone had any luck wit it?
- What data does HA expect when state_class i set to “measurement”? I would assume that given that kWh is time related value it would just sum all the measurements over the hour as they come in to get a total for an hour. But I’ve seen people here talking about converting real time W readout to kWh which is not really possible without taking time between measurements into account.
Never tried it. I use lifetime sensors, they always increase, and I use state_class: measurement and total_reset attribute set to UNIX epoch time 0.
Read this: Sensor Entity | Home Assistant Developer Docs
In my opinion, the definition of messurement and total_increasing is ambiguous: for the former they write “accumulated energy consumption” and for the latter “amount of consumed energy”, which practically is the same thing.
I never tried total_increasing, but I think it’d be more appropriate for a lifetime sensor, and probably it would also imply that last_reset is not needed. But if you say it doesn’t work, I’ll stick to measurement+last_reset combo.
They are probably referring to the Riemann sum integral integration to calculate that.
Thanks for the answer. I’ll try the measurement class with the settings you suggested.
total_increasing
only works on the dev versions right now and is scheduled for release with 2021.9, so you’ll need to make sure you are running a dev version for it to work
Thanks for the info!
I think I misunderstood the documentation. I thought that the way Energy integration accumulates data depends on the state_class value. But I just got my first stat in the Energy panel and it looks like it just registered the increase over the time and not the accumulated sensor value.
That is what I would expect from integration like this but the documentation threw me off the track and made me overthink things.
If you know pvoutput.org, it works the same way: when you configure the sensor you specify what kind of sensor it is through those attributes so the integration knows how to interpret and manage the values.
it’s more simple than it seems at first glance.
good to know, when it’ll be official, it will also be documented so I will switch to total_increasing. thanks.
I’m not familiar with pvoutput.org yet but probably will in the near future - we just got our PV system installed and now we are waiting for the grid operator to accept the paperwork and install a new meter so we can get it online. It’s why I started playing with the energy integration (I was initially planing to set up something using template sensors but since it’s there why not use it )
Thanks for the help again, it works like expected
Great to know it’s working now. I’ve had a PV system for 10y, If you need any help feel free to ping me.
How do i disable this?
I am having trouble in HA to let me select the entities to monitor.
It only shows some of them.
The big issue is that the KwH sensor is made by the sum of two sensors, and that sensor is not displaying.
- platform: template
sensors:
# Energia TOTAL
shelly_total_consumption:
friendly_name: Energía Total
icon_template: mdi:counter
device_class: energy
unit_of_measurement: "KWh"
value_template: "{{(states('sensor.shelly_shem_c5d7_1_total_consumption') | float + states('sensor.shelly_shem_4b4a_1_total_consumption') | float) | round(2)}}"
availability_template: >
{% if is_state("sensor.shelly_shem_c5d7_1_total_consumption", "unavailable") %}
false
{% elif is_state("sensor.shelly_shem_4b4a_1_total_consumption", "unavailable") %}
false
{% else %}
true
{%- endif %}
# Consumo actual TOTAL
shelly_current_consumption:
friendly_name: Consumo Total
icon_template: mdi:flash-outline
device_class: energy
unit_of_measurement: "W"
value_template: "{{(states('sensor.shelly_shem_c5d7_1_current_consumption') | float + states('sensor.shelly_shem_4b4a_1_current_consumption') | float) | round(0)}}"
availability_template: >
{% if is_state("sensor.shelly_shem_c5d7_1_current_consumption", "unavailable") %}
false
{% elif is_state("sensor.shelly_shem_4b4a_1_current_consumption", "unavailable") %}
false
{% else %}
true
{%- endif %}
I have added the line:
device_class: energy
But in the system tools I get:
unit_of_measurement: KWh
friendly_name: Energía Total
icon: mdi:counter
device_class: energy
What do I need to do in order to get it to be able to be selected on the energy settings panel.
device_class
is not enough, you also need state_class
. Read this, a few posts above yours: Home Energy Management in 2021.8 - #105 by alexdelprete
The unit of measurement is wrong: if device_class is energy, unit must be Wh or kWh.
Make sure all power/energy sensors have the correct unit of measurement, the correct device_class, the correct state_class.
Hi to all,
i’ve just configured my energy panel on Home Assistant.
Like the image below i think there is an issue in solar energy consumed.
I don’t know why but it’s impossibile that i’ve consumed a few watts of solar energy.
I’ve three template sensors:
- grid_import in kwh
- grid_export in kwh
- solar prodution
Any ideas?
Thank you so much for any help.
Regards,
Alessandro
I can’t see the values on the image, too small. You should show the Sources table of the energy card, below that one you showed, to see the overall values.
What are the values of the 3 sensors? Are they different vs the card? If the values of the sensors are what you see on the card, the problem is in the sensors.
Thanks for reply Alessandro!
This is my sources part:
…and all my sensor templates:
grid_export_khw:
- platform : template
sensors:
grid_export:
friendly_name: "Grid Export"
icon_template: mdi:flash
unit_of_measurement: "W"
value_template: >
{% if (states('sensor.shelly_shem_b9e60b_1_current_consumption') | int - states('sensor.power_ac_fronius_inverter_1_http_192_168_1_102') | int) > 0 %}
0
{% else -%}
{{ (states('sensor.shelly_shem_b9e60b_1_current_consumption') | int - states('sensor.power_ac_fronius_inverter_1_http_192_168_1_102') | int) | abs }}
{% endif %}
grid_import:
- platform: template
sensors:
grid_import:
friendly_name: "Grid Import"
icon_template: mdi:flash
unit_of_measurement: "W"
value_template: >
{% if (states('sensor.shelly_shem_b9e60b_1_current_consumption') | int - states('sensor.power_ac_fronius_inverter_1_http_192_168_1_102') | int) > 0 %}
{{ (states('sensor.shelly_shem_b9e60b_1_current_consumption') | int - states('sensor.power_ac_fronius_inverter_1_http_192_168_1_102') | int) }}
{% else -%}
0
{% endif %}
solar_production:
- platform: template
sensors:
solar_production:
friendly_name: "Produzione Fotovoltaico"
icon_template: mdi:flash
unit_of_measurement: "W"
value_template: >
{% if (states('sensor.power_ac_fronius_inverter_1_http_192_168_1_102') | float(default=0) | round(2, default=0)) > 0 %}
{{ (states('sensor.power_ac_fronius_inverter_1_http_192_168_1_102') | float(default=0) | round(2, default=0)) }}
{% else -%}
0.00
{% endif %}
That’s all.
Thanks for your support.
Regards,
Alessandro