Home Energy Management in 2021.8

Yes, as far as the Jinja2 processor is concerned but then the string is assigned a type based on its appearance (the ‘native typing’ introduced several versions ago). My mistake was hanging around templates for too long and doing silly stuff like
whatever: "{{ 'cat' }}"
instead of simply
whatever: 'cat'

Luckily I’m still “young” in HA world, so I learned soon you can do whatever: 'cat'. That’s about the only advantage of not being an expert like you, I don’t yet have old habits. :slight_smile:

you should of course adapt it to your own entity naming. Since I named my energy sensors with that suffix, it was an easy customize. you can use the exact same anchor on an individual entity, or even a fake entity, and inject it with the * anywhere.

for anyone struggling with the mqtt last_reset topic (and the techniques as explained in the docs dont work): see Can't set last_reset value for MQTT sensor · Issue #53988 · home-assistant/core · GitHub

tip from BergCyrill in the core issue: publish payload “1970-01-01T00:00:00+00:00” with retain flag to a fake topic and use that as retain topic in your mqtt sensor config:

     unit_of_measurement: kWh
     value_template: >
       {{value|round(2)}}
     last_reset_topic: 'fake/last_reset'
#      last_reset_value_template: >
#        {{'1970-01-01T00:00:00+00:00'}}
#        {{as_datetime(0|timestamp_utc).isoformat()}}
     device_class: energy
     state_class: measurement
2 Likes

Thanks for sharing, I consider this to be a workaround as well, like the customize_glob method. So I’ll just stick with that for now :slight_smile:

yes, I’ll revert to my previous workaround too, because Ive just restarted my system, and though the retained topic is still there, all mqtt sensors fail the last_reset once again… grr

UPDATE:

the topic shouldn’t be quoted…

and proof of the correctness of that in a state topic:

and again in all entities with the aforementioned config

still needing the customization

      last_reset: '1970-01-01T00:00:00+00:00'
      state_class: measurement

for template entities, because these variables aren’t yet supported for the template integration

I’ve made an energy template sensor with a last_reset attribute of ‘1970-01-01T00:00:00+00:00’ and have done a quick check to see that the Home Energy Management System sees this sensor in its list and it does!

However in reality, that meter actually resets at midnight. So I’m actually trying to figure out what the template for last_reset should look like. Any ideas?

EDIT/UPDATE:
What seems to work is the following:

last_reset: '{{ now().replace(hour=0).replace(minute=10).replace(second=0).replace(microsecond=0).isoformat() }}'

The meter I use does cloud polling so it actually does not get reset at midnight but some number of minutes after that. However, since it appears the Home Energy Management does an update around 12 minutes after the hour, I decided on minute=10, but again minute = 0 will probably work as well.

I have configured the cards, but I would like to view the consumption of the last 5 days at the same time without having to change the date.
Do you say it is possible?
alternatively, can I put 5 sensors that take the data from the home assistant db or from a csv file that saves me the total consumption every night?

I am trying to configure the Energy configuration. I have a ‘Used’ Energy counter which counts up and down depending on Energy consumed v.s. returned. This value is a ‘lifetime’ counter which is now negative (-1400 kWh). I configured this as ‘Grid consumption’ and added the solar to ‘Solar production’ but don’t know how to configure ‘Return to grid’.
A it is now it only shows the Solar energy flowing to ‘Home’ and not the consumption and delivery to the grid. Any ideas?

1 Like

how can i get the gauge metter on the energy dashboard ?

Maybe i oversee this topic too simple, but:
why not just enable anyone to add any sensor to the config for monitoring?

E.g. i use several Shelly (Plugs) and other additions which also monitor energy, these also show up as entities.
At least for me, this would be more sinmple to just add from the whole entities list.
Yes, i know this may show more as needed, but it would be more simple at least to me without adding specific config lines…

/ Ralf

1 Like

maybe because the energy integration needs those attributes? How do you think it can calculate daily stuff without last_reset etc.? Developers aren’t stupid, if they filter sensors based on those attributes it’s because it’s a prerequisite for the correct functioning of the integration, not because the list would get too crowded. :slight_smile:

Hello,
i just found this tread - i posted my question in another tread regarding energy management.

I have some trouble setting up the new Energy Dashboard.
I can not select the entity.

Here the Configuration:

I tried many approaches from several treads but i cant get it to work.

What did i do wrong?

Thank You!

1 Like

please show the screenshot of the total_in sensor from dev tools, want to check the attributes from HA’s point of view.

The unit of measurement shouldn’t have a space, and doesn’t need quotes, it should be like this:

unit_of_measurement: kWh

just modify unit of measurement…I don’t see other issues.

can i do this by editing customize.yaml?

sorry - i am not that experienced.

This is your customize.yaml, just modify the unit_of_measurement like I told you, then restart and post the dev tools screenshot again:

i just shared my thoughts with nthis topic as beeing new to energy. So no need of beeing that attackable, please.

I thought that it would do time coun ting itself (e.g. as with power meters from a light sensor). But now i undestand there is more insights i did not think of. Understood better now.

Will try to achieve same with the configs explained above.

/ Ralf

I didn’t attack you, I even explicitly put a smile at the end of the post just in case…but I see it didn’t work. Sorry if you interpreted like that, it was just ironic, not aggressive at all. :slight_smile: