History statistics component


#21

You’re welcome :slight_smile:


#22

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() }}'

#23

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'


#24

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:

history:
  include:
    entities:
      - group.household

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