Tried to configure it right away, but unfortunately it won’t let me choose the sensors of my energy meter (Elios4You) that I integrated and used for 1 year (through node-red, that creates all the sensors). It only shows me the utility_meter sensors and the Shelly EM sensors.
This is the sensor for real-time consumption:
But it doesn’t appear in the list of sensors to choose:
I thought there was some attributes missing from sensors I created through node-red, and the only one missing was state_class: measurement, so I added it to all NR sensors, but it still doesn’t pick them up.
I don’t know what is the filter of that list…and I found no additional info/doc about it.
Thanks for any help solving this, I’d be happy to test and use this new feature.
If the time of initialization is unknown and the meter will never reset, set to UNIX epoch 0: homeassistant.util.dt.utc_from_timestamp(0)
{{ 0 | timestamp_utc }} is 1970-01-01 00:00:00, this should work too.
I stand corrected: as @balloob said, customize comes after internal conversion to ISO8601 has already been made, so this works: {{ as_datetime(0|timestamp_utc).isoformat() }} → 1970-01-01T00:00:00
UPDATE: the above works for the scope of last_reset, but in order to be offset-aware, timezone has to be included, so in case you need it:
Although I will wait until 2021.8 is released, I started updating my mqtt and template sensors to include device_class and state_class where appropriate. I came across a quirk (2021.7.4) where my template sensor configured in “Legacy” mode (i.e. sensor: platform: template: sensors) does not allow me to add state_class. Will state_class be added in 2021.8 to “Legacy” mode, or do I have to convert my “Legacy” mode to “Modern” mode (template: -sensor:) in order to add the state_class?
I would advice to use the “modern” syntax. It’s future-proof, and state_class is probably the first example of why it’s better to switch to the new style.
But you could also use this:
homeassistant:
customize_glob:
sensor.*_energy:
last_reset: '1970-01-01T00:00:00+00:00'
device_class: energy
state_class: measurement
I have an ESPHome based telemetry kit for my electrical counter.
I already have implemented the measurement and energy class and plan to customize the entities with last_reset on Home-Assistant side as it is not something to do on ESPHome side if I understood correctly.
My sensors are in WH. Should I convert values in my ESPHome config file to KwH to use them?
I don’t know ESPhome unfortunately, so can’t advice how to do it with it, but I prefer to modify it where the sensors are created, if possible. I try to avoid using customize, even if it works. In my case, I use NR to read my home energy meter, and sensors are created in a flow, so it was really easy customizing them adding the needed attributes. If you can’t modify the sensors in ESPhome, then you can use customize global entries.
They have settled on kWh, reading the discussions on discord, so the answer is yes.
I have indeed read the previous posts, but wanted to add if there would be a way to avoid these customizations. If we specify a total daily energy sensor in ESPhome, the required attributes for HA energy could be added automatically?
I’ve done all customisations with my energy sensors - i have 3 sensors for each tariff zone.
All of them (t1, t2, t3) have similar attributes and states different data in kWh
unit_of_measurement: kWh
friendly_name: T1
last_reset: '1970-01-01T00:00:00+00:00'
device_class: energy
state_class: measurement
I’ve added all of them to Energy section, but still have no data on graph.
What’s wrong ?
Upd. In few hours it started to show some data. But it’s unclear how it works, and also is there any way to calibrate this data - to put my starting values.