Long Term Statistics not showing for utility_meter

Hi,

I have a “utility_meter” setup from my configuration.yaml.
I want to be able to look back a few months at historical values.
The utility_meter has a monthly cycle… so although it’s constatly increasing, it’s mainly the value just before it cycles I’m looking for.

The sensor look like this in my configuration.yaml:

utility_meter:
  house_solar_saving_montly:
    source: sensor.house_solar_saving_last_hour
    cycle: monthly
    delta_values: true
    offset: '00:00:20'
    unique_id: "house_solar_saving_monthly"
    name: House Solar Saving Monthly
    #unit_of_measurement: SEK

And the sensor looks like this:

From a bit of reading I now undestand that it’s normal that I can’t see historical values long ago in the history viewer:

Trying to look at last month, I have nothing in my history.

But, I also read that there is something called LTS (Long Term Statistics) and that I should be able to see this data for my sensor as it has a native “state_class: total_increasing”.
The data should become visible when adding it to a statistics card.
But when I do so… I still only see the sensor data that gets purged.

Please help, what am I doing wrong here?

  1. You’d have to wait for it to populate that data. The system does not create things in the past. When you add an entity to the system, your LTS and Regular history start the moment you add the entity.

  2. You’ll need a unit of measurement for it to be numerical.

  3. You may need device_class: monetary for it to work.

Sorry I forgot to mention that I created the sensor roughly a year ago, so there should be plenty of LTS data.

Ok, I’ll look to implement your other two advice.
Any risk I mess up any potential LTS data I have by making changes like this to the sensor?

Thank you for taking your time to look at this! :heart:

For your statement 2, do I solve this by removing the # in front of my “unit of measure” in the configuration.yaml file?
Seems I was playing around with this at the time I created this sensor, but I’ve not sure why I left it out by adding the #

That would be a start

So… I’ve now looked into all the bullets above.

1) I created the sensor ~a year ago, so this should not be the issue

2) I tried adding a unit if measurement to my utility_meter as we (although it already has a unit_of_measurement based on the source sensor it’s tracking (sensor.house_solar_saving_last_hour):

utility_meter:
  house_solar_saving_montly:
    source: sensor.house_solar_saving_last_hour
    cycle: monthly
    delta_values: true
    offset: '00:00:20'
    unique_id: "house_solar_saving_monthly"
    name: House Solar Saving Monthly
    unit_of_measurement: "SEK"

HA doesn’t like this added “unit_of_measurement”:

Perhaps it’s because it would be a double statement from the sensor values fed to it?

3) I tried adding “device_class”…

utility_meter:
  house_solar_saving_montly:
    source: sensor.house_solar_saving_last_hour
    cycle: monthly
    delta_values: true
    offset: '00:00:20'
    unique_id: "house_solar_saving_monthly"
    name: House Solar Saving Monthly
    device_class: monetary

But HA doesn’t seem to like this either:

I have exactly the same problem. My utility meter sensors are not show in the long term statistic. Adding unit_of_measurement or device_class are leading to errors in the config as shown above.

I also cannot add an utility meter sensor to a “Statistics graph Card”.

Does anyone have a solution how to bring utility meter sensors to the long term statistic? @Piffis maybe?

They need to be added via

homeassistant:
  customize:
    <entity_id>:
      device_class: ...
      state_class: ...
      unit_of_measurement: ...
1 Like

To add to this. A good place to start is in Developer Tools and States. This will show you how the sensor/entity is defined in HA. If it does not have state_class it will not save to LTS.

1 Like