to my configuration but how can I extract a value from this to use in an automation or on lovelace? Something that says: tha avg humidity in the last 24h was x.
I guess if you change the max age to 24 hours you will get the average of 24 hours.
But I have never tried it to be honest.
I have only used shorter timespans so I’m not sure it works with 24 hours, but I doubt it’s limited.
Yeah it does. Have you restarted since creating it?
Also if you give it a name you will be able to find it more easily.
e.g.
sensor: # <--- this should only appear once in your configuration
- platform: statistics
name: Bathroom Humidity Stats
entity_id: sensor.multisensor_bathroom_humidity
max_age:
hours: 24
sampling_size: 2880 # depending on how often your sensor updates you may need to change this
e.g. The sampling size for a sensor that updates every 30 seconds should be 60*60*24/30 = 2880 + a bit for safety You can check this by looking at the samples attribute for your statistics sensor in developer tools / states and making sure it never counts past 2880.
Having said all of that, this is a better average sensor as it take into account the time the state stays at each value, rather than just averaging all the values:
e.g. If you used the statistics sensor and it stayed at 50% all day except the last value for the day was 0% the average would be 25%. Obviously this is not the correct average for the 24hours . The custom average sensor does not have this issue. Also you don’t need to calculate the max samples for this custom sensor.
I wanna make an avarage sensor which can examine the last 14 days temperature but in a current time.
So i do not want a simple 14d avarage but the 14d avarage at 10:00, 10:05, 10:10 …etc for all days.
With this sensor i can see not the daily avarage but the avarage for every five minutes back to 14 days.
I hope i am clear, hard to describe what i mean.
I simply do not know what kind of statistic shoud i use.
Please give me an advice.