WTH isn't 'entity_globs' allowed in History

it would make it so very easy to simple use 1 !include file for logbook, history and recorder, including and excluding the same entities all over.

The history filtering is done at the database level instead of in Home Assistant’s python code for performance reasons. Since not all the databases we support can accept a glob, history does not either.

1 Like

Anything excluded from recorder is also excluded from history and logbook is it not? I don’t exclude anything from history personally, I exclude from recorder and use the history tab as my way of seeing what all is being recorded that I need to exclude next.

:+1: Excluding from recorder is the most efficient method and usually preferred as it means we don’t waste space in the database as well.

I see. Not even the most frequently used (or the default ones?) like the default sql and MariaDB?

If not, wouldn’t it be an option to have it as, well, an option maybe? it would literally save (me) at least 80% of the lines…

I realize tuning the recorder is most efficient, and nothing beyond that will pass through to either history or logbook. The latter 2 should really only be fine-tuned if one would like to filter down even more than the recorder settings shouldn’t it?

using this right now:

history: !include logging/logbook.yaml
logbook: !include logging/logbook.yaml
recorder: !include logging/recorder.yaml

with logbook.yaml being:

# https://home-assistant.io/components/logbook/

include:
  !include logged_entities.yaml

and setting recorder to use those same logged_entities:

db_url: !secret db_url
purge_keep_days: 5

include:
  !include logged_entities.yaml

exclude:
  event_types:
    - service_removed
    - service_executed
    - platform_discovered
    - homeassistant_start
    - homeassistant_stop
    - feedreader
    - service_registered
    - call_service
    - component_loaded
    - logbook_entry
    - system_log_event
    - automation_triggered
    - script_started
    - timer_out_of_sync

  domains:
    - alarm_control_panel
    - alert
    - automation
    - binary_sensor
    - camera
    - climate
    - counter
    - cover
    - device_tracker
    - geo_location
    - group
    - input_boolean
    - input_datetime
    - input_number
    - input_select
    - input_text
    - light
    - media_player
    - proximity
    - remote
    - scene
    - script
    - sensor
    - sun
    - switch
    - timer
    - updater
    - variable
    - weather
    - zone

all my included items are in logged entities. Which of course would benefit from the entity_globs…

so now they are: https://www.home-assistant.io/integrations/history/#entity_globs ?

1 Like

Same here. Reported an issue on github:

support for that was implemented in 0.116
from changes for 0.116
Add entity glob matching support to history (@bdraco - #40387) (history docs)

1 Like

what made it work for me was, after having excluded all domains in recorder, and including only the explicit sensors I need, this works fine when listing these sensors individually.

If you want to use the entity_glob, you need to take-out the exclude of that domain.
This isn’t really documented very well, but it did the trick in my setup.

Added to that, the golden rule is: exclude/include as much as possible in recorder, and then only fine-tune what you want to see in history and logbook.

compared to the above post:

db_url: !secret db_url
purge_keep_days: 5

include:
  !include logged_entities.yaml

exclude:
  event_types:
    - service_removed
    - service_executed
    - platform_discovered
    - homeassistant_start
    - homeassistant_stop
    - feedreader
    - service_registered
    - call_service
    - component_loaded
    - logbook_entry
    - system_log_event
    - automation_triggered
    - script_started
    - timer_out_of_sync

  domains:
    - alarm_control_panel
    - alert
    - automation
#    - binary_sensor
    - camera
    - climate
    - counter
    - cover
    - device_tracker
    - geo_location
#    - group
    - input_boolean
    - input_datetime
    - input_number
    - input_select
    - input_text
    - light
    - media_player
    - proximity
    - remote
    - scene
    - script
#    - sensor
    - sun
    - switch
    - timer
    - updater
    - variable
    - weather
    - zone

and logged entities:

entity_globs:
  - sensor.*_power_daystart
  - sensor.*_usage_daystart
  - sensor.*_calibrated_temperature
  - sensor.*_actueel
  - sensor.*_state
  - sensor.*_totaal
  - sensor.calculated*
  - sensor.l1*
  - sensor.l2*
  - sensor.l3*
  - sensor.teller*

  - sensor.zp*
  - sensor.solaredge_*
  - sensor.speedtest*

entities:
  - sensor.driveway_buiten_sensor_light_level_raw
  - binary_sensor.family_home
  - binary_sensor.daughters_home

  - sensor.family_home
  - sensor.daughters_home

etcetc

Thanks again :smiley: