My sensor keeps track of changes in cost. But is showing 0 in energy tab.
Exact same problem here. Problem started after upgrading to 2021.9.
I finally got it working!!
My setup is as follows.
Energy sensors come from MQTT.
I have customized those in my config, otherwise they are not of the proper state_class (In 2021.8 these were configured as state_class: meaurement
, for 2021.9 I had to change that to state_class: total_increasing
:
homeassistant:
customize: !include customize.yaml
# To make sensors show up in Energy Management add-on (since 2021.08)
customize_glob:
sensor.totaal_teruglevering_hoog_tarief:
last_reset: '1970-01-01T00:00:00+00:00'
device_class: energy
state_class: total_increasing
sensor.totaal_teruglevering_laag_tarief:
last_reset: '1970-01-01T00:00:00+00:00'
device_class: energy
state_class: total_increasing
sensor.totaal_verbruik_net_hoog_tarief:
last_reset: '1970-01-01T00:00:00+00:00'
device_class: energy
state_class: total_increasing
sensor.totaal_verbruik_net_laag_tarief:
last_reset: '1970-01-01T00:00:00+00:00'
device_class: energy
state_class: total_increasing
For the cost & compensation part I had a couple of issues:
- customize_glob:defined as wild card (
sensor.totaal*
), so I unwillingly also changed the state_class of the cost and component sensors. Changed this into the individual customisations as listed above. - For some reason only 3 of the 4 entries were automatically created in the MariaDB recorder table
statistics_meta
, so I created the 4th entry manually (using phpmyadmin). Then the cost/compensation started working for the 3 sensors that were created automatically in the MariaDB, The cost sensor I created manually still remained at 0. - Apparently there was also still a customisation rule in my customize.yaml causing that 4rd sensor, I added manually to the MariaDB, still not to work, which also forced the state_class to be measurement. Honestly I can’t really remember having put that there, but I’m getting older, so I probably did so anyway Maybe that rule was also causing the entry not to show up in the database table
statistics_meta
in the first place, Anyway, after removing this customisation also this 4th cost/compensation sensor started to show up properly in the energy dashboard!
Yep. See here – “2021-09-07 17:12:00 WARNING (Recorder) [homeassistant.components.sensor.recorder] The unit of sensor.inverter_energy_spent_cost (ZAR) does not match the unit of already compiled statistics (EUR). Generation of long term statistics will be suppressed unless the unit changes back to EUR”
Changed it to EUR and error has changed to this –
The unit of sensor.inverter_energy_spent_cost is changing, got multiple {‘EUR’, ‘ZAR’}, generation of long term statistics will be suppressed unless the unit is stable and matches the unit of already compiled statistics (EUR)
If you are using MQTT sensors, you shouldn’t need customizations at all, the preferred way is configuring the sensors correctly…
also, you shouldn’t set the last_reset any longer, as that is taken care of by the HA core automatically.
all electrical energy sensors can be configured with:
<<: &energy
unit_of_measurement: kWh
value_template: >
{{value|round(2)}}
device_class: energy
state_class: total_increasing
and all power sensors with:
<<: &power
unit_of_measurement: W
value_template: >
{{value|round(2)}}
device_class: power
state_class: measurement
for gas, use:
unit_of_measurement: m³
value_template: >
{{value|round(2)}}
device_class: gas
state_class: total_increasing
and you’re set
You need to change unit_of_measurement
for that sensor in the database from EUR to ZAR.
Instructions here:
Remember to shut down HA before editing else you may get some corruption !
I see this morning the values are appearing after changing to EUR. I’m not comfortable fiddling with the database. Will leave it as is until the Nabu Casa team release a fix hopefully. Thanks!
I remember, at least with 2021.8, this was not possible. This is one of my mqtt sensors. Can you tell me how this should look then?
platform: mqtt
name: Totaal verbruik net laag tarief
unit_of_measurement: "kWh"
state_topic: "sensors/power/slimme_meter/verbruik_laag_tarief"
value_template: "{{ value|float / 1000 }}"
what is the issue with that config, why are you asking? do you see errors? except for the missing state_class and device_class ofc
I mean, you liked my post above, but dont read it?
They don’t show up as usable sensors in the energy config, without the glob customisation…
thats’s because you didnt configure them correctly
dat is opmerkelijk want: MQTT Sensor - Home Assistant
waar wordt die fout getoond? als dat een screenshot is van VSC dan is dat een bug in die add-on
Yes VSC addon. OK, so I can try it after all. I’ll do that
I’ll report back later, don’t have the time now
OK, so when I update the mqtt sensor definitions and remove the glob customisation, after restarting Hass I get this warning for all 4 associated cost/compensation sensors???
Entity sensor.totaal_verbruik_net_laag_tarief_cost (<class 'homeassistant.components.energy.sensor.EnergyCostSensor'>) with state_class measurement has set last_reset. Setting last_reset is deprecated and will be unsupported from Home Assistant Core 2021.11. Please update your configuration if state_class is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+energy%22
These cost/compensation sensors are created by the energy management integration, I cannot configure them.
I have the same issue. I’m on the latest version of HA. The sensor sensor_name_costs does update
(and i think it is correct, it resets at midnight)
But in the costs overview
Mine has started doing this, I am using a PZEM attached to a Tasmota’d node MCU, I rebuilt the sensor in Template.yaml but it doesn’t seem to make any difference, even giving it a new entity ID doesn’t seem to help. Everything reads zero, interestingly its picking up the data, but doesn’t give detail on hoverover either.
Same issue, would love, some guidance from the Home Assistant team
Same issue here. It was working fine for me a few weeks ago, and then I think stopped after one of the recent updates.
Ran into the same problem here, solved it by changing the config file.
Since my Energymeter is overfluding the database I used a filter. However I could not select the filter in my Energy system, so I had made a custom Glob:
homeassistant:
customize_glob:
sensor.filtered_energy_*
last_reset: '1970-01-01T00:00:00+00:00'
device_class: energy
state_class: total_increasing
As it turns out, this also modificates the “_cost” entity. Changing the Glob so it only modificates the filtered energy entities did the trick.
So I have now several lines like this:
homeassistant:
customize_glob:
sensor.filtered_energy_consumption_tarif_1:
last_reset: '1970-01-01T00:00:00+00:00'
device_class: energy
state_class: total_increasing