Huge history sensors?

I would like to get statistics about some sensors more even over years… I.e. I would like to see how many time the heater has been working (last month, last year, this year, etc…)…
I know you have https://www.home-assistant.io/components/sensor.history_stats/
to do this, but I dont know if this sensor can work with database recorder set to standard 10 days.

Obviously, I dont want to have a database with 5 years for all sensors, because of space disk ,startup time, etc. (i am runnig in a rpi3). Today I have purge_keep_days=10 days and a 300MB of database size.

I have about 200 entities from wich I would like to have record for a few (less than 10) for more than 1 year, a few 30-40 to have tipical record 10-30 days, and the rest of devices not recorded at all. This seems that cant be configured in “recoder” because you have whitelist and blacklist, but only a “purge_keep_days” global for all entities…

I have seen that HA design has poorly support for save permanent (or long live) state of things… I have seen restore_state @ https://www.home-assistant.io/components/recorder/ but it is suported by only a few components…

I would like to know If anyone has though something similar. At least for get a cummulative sensor that get the time activated from where you want, independent of your “purge_keep_days” database.

Thanks.

Does this help? (I am not sure if it dies, but worth a look)

1 Like

as @nickrout said, Influx is probably what you are after, as you can pipe into it whatever sensor’s you want, just one, or 10, and then just keep a record/database of them, then let Home Assistant do it’s home assistant’y things :slight_smile:

I use it to keep a track of my temp and humidity sensors.

I have implemented something similar to this for one of my entities. It might not be the right solution for you since you’re wanting to track several entities but I’ll share anyways. May help you or someone else.

I wanted to track how many hours my heater/air conditioning have ran for the entire winter/summer season. I have a history_stats sensor that calculates how long it has been running today. I created an input_number sensor that I update the value of each night using an automation just before midnight before the daily history_stats sensor resets.

- alias: Seasonal HVAC total update
  trigger:
    platform: time
    at: '23:59:55'
  action:
    service: input_number.set_value
    data_template:
      entity_id: input_number.seasonalhvactotal
      value: "{{(states.input_number.seasonalhvactotal.state | float) + (states.sensor.hvac_running_time__today.state | float)}}"

An optional step is to create a sensor that gives the state of the input_number so you have a read-only value in your front end instead of and editable input_number.

Just make sure that the input_number is set to restore_state so it won’t get reset when you restart Home Assistant.

1 Like

Thanks a lot nickrout. I would investigate…
First impressions, a new database seem as " a sledgehammer to crack a nut"…

I have been that there are more components like influxDB but most of then dont have “filter devices” options.

Thanks Cee…
I think that has long term statistics of a house are things that a home assistant could do. You have history graphs that are so related with " home assistant’y things" as this long-term statistics.

For me, for example, can be very useful to know how it impacts an automate open-close blinds intelligently in the gas bill (or get info on how to equalize it).

Thanks

bradyn12
Its really witty.
I think that I was searching for something as you propose, but coded in HA (as a component).

Hi, how did you set the history_stats for your heater? Hi have no idea on how i have to write in ‘state’ row in order to track the hvac_action.