Need Statistics Help for Freezer Running Average & Notification

Need Statistics Help for Freezer Running Average & Notification.

I’m attempting to log the hourly running average of temperatures then trigger actions if the running average goes outside of limits.

I have attempted creating the yaml code below, however it does not populate the virtual sensor (sensor.freezer_temperature_rolling_average) with data. There is historical data for the actual sensor (sensor.kit_freezer_temperature) and the docs say it will use historical data if it is there. I have also let it run for over a day and still no data.

I apologize, I’m new at this and I don’t have a clear understanding of the purpose of the Statistics Platform and Template Platform.

Clearly, I am not doing something correctly.

Any help is appreciated. Thanks

sensor:
  - platform: statistics
    entity_id: sensor.kit_freezer_th_temperature
    name: Freezer Temperature Statistics
    max_age:
      hours: 1
    sampling_size: 10
    precision: 2
    state_characteristic: average_linear
    unique_id: "kit_freezer_temperature_1h_Rolling_Avg_stats"

  - platform: template
    sensors:
      freezer_temperature_1h_rolling_average:
        friendly_name: "Kit Freezer Temperature 1h Rolling Average"
        unit_of_measurement: "°F"
        value_template: "{{ state_attr('sensor.freezer_temperature_statistics', 'average_linear') }}"
        unique_id: "kit_freezer_temperature_1h_Rolling_Avg"

PS: i assume your indents are correct, spite the fact you haven’t quoted your code

Also , i believe below is the new way of defining template-sensors

# Template-Sensors
template:
  - sensor:
      - name: "Total Price"
        unit_of_measurement: "Sek/kWh"
        state: >

Thank you very much for your replies.

I believe the code formatting is correct. I am using Studio Code Server. I’m not sure what is the best way to cut and paste code from that tool into the Forum and preserve the formatting. HA does not indicate any yaml errors when I run the check.

Ai added a Unique ID to the template (see the edited code above) and that now lets me click in the gear and manage some setting for the sensor.freezer_temperature_1h_rolling_average entity but still no data.

Here are the entities created…

This site WIKI that you read when you signed up has some suggestions in that direction. Here’s a jump link to that section.
How to help us help you - or How to ask a good question.

Otherwise YAML is all about the indents and we cannot see them in your code, so helping you is pretty hard if you can’t fix that here.

Thanks for the tip about pasting the code.

I edited the original post, so I think the formatting in the post is correct now.

1 Like

A sensor which shows as unavailable, cant / wont provide anything
So where is the sensors:

sensor.kit_freezer_temperature

and

?

Ahh, now you’ve change your file-names in your orig post … maybe AI played you with old info :wink:

Thanks for the challenge. I had a typeo in the entity_id: sensor.kit_freezer_th_temperature name. Code is update in the post.

I now have data for the sensor.freezer_temperature_statistics but it does not look like an hourly running average.

The entity sensor.kit_freezer_th_temperature always had data.

No data for the sensor.freezer_temperature_1h_rolling_average entity.

Here are my relevant entities:

Here is the data: (I think the data before 7:15 for the statistics might be messed up due to code changes)

is average-linear an attribute to sensor.freezer-temperature-statistics ?
check in developer-tools

And while you at the keyboard, you might as well follow the new way , for template-sensors … and check documentations before you ask AI for help :slightly_smiling_face:

and this might explain your ( falling graph )

"/integrations/statistics/#an-important-note-on-max_age-and-sampling_size".

Thanks for the additional direction. The important-note-on-max age-and-sampling size helped a lot.

The following seems to work as expected.

sensor:
  - platform: statistics
    entity_id: sensor.kit_freezer_th_temperature
    name: "Freezer Temperature 1h Rolling Avg"
    max_age:
      hours: 1
    # sampling_size: 10
    precision: 2
    state_characteristic: average_linear
    unique_id: "kit_freezer_temperature_1h_Rolling_Avg_stats"

My template sensor is not working and does not have any entity attributes. I’m digging further into the docs to try and understand the role of templates and if one is needed for my application. At this point I don’t think so, but I would like to learn.

Note: I was not able to include the underscores in the entity names in the post below because the forum tool kept barking about unformatted code. Clicking on Post Anyway or Fix Code did nothing and it would not post.

I was able to set up a Threshold Sensor Helper and it will tell me if the Rolling Avg of the
“sensor.freezer temperature statistics” entity goes out of bounds.

I dont understand why it is name this way since the name is not in my code. I could understand if it were named “sensor.freezer temperature 1h rolling avg statistics”.

  • How is the “sensor.freezer temperature statistics” entity name derived?
  • Do I need to implement a template?

The “sensor.freezer temperature statistics” now looks like it is working after the 930P change.

1 Like

Thanx for this info, glad to hear im not the only one :slightly_smiling_face: , it’s been driving me nuts for past month :confounded:

Edit:

Get use to read the documentation, so you get a little idea how a certain integration / function work , if you then still find it useful to use AI, feel free , just remember AI don’t always (hardly) provide updated info, and most of all NO ( source ) meaning you are just eating it raw, and have to revise your ( learning ) when you eventually Have To read the source ( HA Docs ) :wink:

PS: A weather forecast is still more reliable than AI :laughing:

Doubtful , depends upon what you want/need it for … but as you figured out average-linear is not an attribute , as you ( requested ) in your template-sensor , it’s used in your statistics-sensor to define the outcome ( state ) of that sensor

PS: Sorry for my harsh way of Assisting :wink: , but people who believe AI will make their life easier , needs to understand the primary prerequisite , i.e Read the manual to get a basic understanding first

Im glad to hear that i was able to provide a little information that you found helpful. I wasted a lot of time trying to figure out why i couldn’t submit my post. Being new I was convinced i was doing something incorrectly. I ended up posting a sentence at a time until it would not post then changing a character at a time until the breaking sentence would post.

As far as AI goes. Im not using it for this. I had a typo in my 2nd post 3rd paragraph. “Ai” should be “I”.

I appreciate your guidance about AI. I do understand you’re concerns and recommendations about it. The models are built from old information and considering how often HA is updated, recommendation are likely outdated. I do understand that basically the algorithms are based on which word is most likely to be the next word based on crawling the web a year or so ago. The response may not be correct.

Im trying to get my head around the docs. It’s not always intuitive or clear what the optimal approach is. As with most things, it depends.

Thanks for all your help and guidance. Can I buy you a coffee somehow?

1 Like

Being old i been wondering wth i had done to my browser (FF), so yes i have been going through almost every post, every time, until i figured, it seems mostly the underscore.

Aiii :smile: shit happens

And yes The Docs, it’s sometime hard to find, eventually one gets use to poke around, but …
The Docs are written by various people, and as we all are different we’ll interpret it with our current knowledge … like the " State Characteristic" in Statistics-docs ( This could be more clear, one have to read some of this 3-4 times, and still feel " im in the dark here " :crazy_face:

Nope , but hand me a beer , when we meet :grin:

I will be happy to do that. Thank you again.