Input_number helper and statistics

Hi,

I have a helper input_number.imported_energy_quarter_hour_current_price
I added the following in my configuration.yaml

  - platform: statistics
    entity_id: input_number.imported_energy_quarter_hour_current_price
    state_characteristic: mean
    max_age:
      days: 3650

But when adding a bar chart for this entity, there is a “no statistics found” ?!
Could please anyone help me? I really have no glue why this happens?
Best regards and thanks in advance,
Otto

Thanks. And now? What can I do to get a chart from this helper?

Create a template sensor from your input_number helper, and use that as the source for your statistics.

Thanks for the hint, but somehow still no statistics created.
I now have the following template:

  - name: epex_stromkosten_real
    state: >-
      {{ states('input_number.imported_energy_quarter_hour_current_price') | float }}
      unit_of_measurement: "¢"

and this is the statistics entry in my configuration.yaml:

- platform: statistics
    entity_id: template.epex_stromkosten_real
    state_characteristic: value_max
    max_age:
      days: 3650

In statistics there is no value created. I have absolutely no glue why?

sensor.epex_stromkosten_real

Thanks. But also does not create a statistics entity for the device :frowning:

Are the indents correct in your actual config…? Both the samples above are incorrectly indented.

ahm? what exactly is incorrect?
(I hate this indentendig grr…)

Make sure this is under the top-level key template not sensor and unit_of_measurement should be aligned like:

  - name: epex_stromkosten_real
    state: >-
      {{ states('input_number.imported_energy_quarter_hour_current_price') | float }}
    unit_of_measurement: "¢"

This one should be under the top-level key sensor and the indentation should be:

  - platform: statistics
    entity_id: template.epex_stromkosten_real
    state_characteristic: value_max
    max_age:
      days: 3650

Then there are other errors in the sensor’s configuration. For example, is the first line actually offset like this in your configuration or is it just a copy-paste error in the forum post?

If it’s actually offset like that then it’s incorrect.

Thanks for all your help.
Hm. The sensor from the template is created, but no statistics yet.
All I could find wrong was the indenting of the unit of measurement in the template, what I corrected.
I will wait until tomorrow, as the sensor is only updated each 15 minutes. Maybe there will be values until then. I hope at least.
But a question for being able to help myself better in the future:
Is there any log where possible errors can be seen? I am pretty familiar with linux (actually I have been working on linux only for more than 20 years) and reviewing logs, but still a little bit lost with HA…

This was just a copy/paste error.
It is like this:

  - platform: statistics
    entity_id: sensor.epex_stromkosten_real
    state_characteristic: mean
    max_age:
      days: 3650

and the template:

  - name: epex_stromkosten_real
    state: >-
      {{ states('input_number.imported_energy_quarter_hour_current_price') | float }}
    unit_of_measurement: "¢"

The sensor itself is here and has the correct value. Only no statistics for it… hm…

What is the reported value of the statistics sensor? Is it unknown?

No. There is simply no entry for it in Developer tools - statistics

Then its configuration is invalid. Check Settings → System → Log for errors.

That’s normal.

  1. You have created a Statistics Sensor.
  2. Developer Tools → Statistics lists sensors that are designed to record long-term statistics.

The two things aren’t the same.

ahm. but I also can not add it to a statictics card? and this would be what I want to do?
if I add a card like this

chart_type: bar
period: day
type: statistics-graph
entities:
  - sensor.epex_stromkosten_real
title: Strom Einkauf Kosten

The card tells me: No statistics found?!

And thanks for the clarification about these statistics. I thought that a sensor with a statistic would automatically show up there.

The Statistics Graph card is designed to display the data of sensors that record long-term statistics.

Did you read this part in the documentation for the Statistics Sensor integration?


The statistics integration is different to Long-term Statistics. More details on the differences can be found in the 2021.8.0 release notes.


You may need to create a Template Sensor from your Statistics Sensor. A Template Sensor provides a state_class option that allows you to specify how you want its long-term statistics to be recorded.

There’s more information about State Classes here.

1 Like

Thanks a lot!
the state_class in the template seemed to be the missing part :slight_smile:
There is still no statistic data for the card, but now I could choose the entity in the config :slight_smile:

Btw. Now the statistics also show up in developer tools → statistics. I learned, that is a different thing, but obviously there are connections…

edit: now the data show up in the card :slight_smile: THANKS man!

1 Like