History statistics component


You’re welcome :slight_smile:


Aware of revamping this topic, however it seems a good ‘overview’ topic.
I am trying to create a history_stats sensor that is using a group as input. In my case this is a group of presence_detectors, so I can see how much time the house was ‘empty’.
The sensor results in Unknown in the front-end. Is it even possible to use a group for history_stats? Documentation on history_stats nor history mentions this.

- platform: history_stats
  name: Empty house today
  entity_id: group.household
  state: 'off'
  type: time
  start: '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'
  end: '{{ now() }}'


The history_stats component will work as long as there are states saved in the history.

Are you sure this is the case ? Can you attempt this database query and check the values ?

SELECT state from states WHERE entity_id = 'group.household'


Thanks @bokub. Running the query on my separate InfluxDB (via Docker on Synology) didn’t give any results. I did make sure to have the group include in the history config:

      - group.household

I am now thinking to set up a template sensor that mimick the group’s state…