Logbook and history exclude

As I have quite a few entities from e.g. NodOn smart plugs that report a lot of data I am not interested in, I want to exclude these from the logbook and history. To tidy things up, I tried to do an !include of these entities in my config as follows:

logbook:
  exclude:
    entities:
      - !include /config/exclude_entities/logbook_exclude.yaml

The logbook_exclude.yaml looks like this:

- sensor.nodon_msp_3_1_xx_micro_smart_plug_alarm_level
- sensor.nodon_msp_3_1_xx_micro_smart_plug_alarm_level_2
- sensor.nodon_msp_3_1_xx_micro_smart_plug_alarm_level_3
- sensor.nodon_msp_3_1_xx_micro_smart_plug_alarm_level_4
- sensor.nodon_msp_3_1_xx_micro_smart_plug_alarm_type
...

However, I get the following error in the home-assistant.log:

2019-03-06 11:23:59 ERROR (MainThread) [homeassistant.config] Invalid config for [logbook]: value should be a string for dictionary value @ data['logbook']['exclude']['entities']. Got [['sensor.nodon_msp_3_1_xx_micro_smart_plug_alarm_level', 'sensor.nodon_msp_3_1_xx_micro_smart_plug_alarm_level_2', 'sensor.nodon_msp_3_1_xx_micro_smart_plug_alarm_level_3', 'sensor.nodon_msp_3_1_xx_micro_smart_plug_alarm_level_4', 'sensor.nodon_msp_3_1_xx_micro_smart_plug_alarm_type', 'sensor.nodon_msp_3_1_xx_micro_smart_plug_alarm_type_2', 'sensor.nodon_msp_3_1_xx_micro_smart_plug_alarm_type_3', 'sensor.nodon_msp_3_1_xx_micro_smart_plug_alarm_type_4', 'sensor.nodon_msp_3_1_xx_micro_smart_pl.... (See ?, line ?). Please check the docs at https://home-assistant.io/components/logbook/
2019-03-06 11:23:59 ERROR (MainThread) [homeassistant.setup] Setup failed for logbook: Invalid config.

Is it just an indentation issue, or is this type of !include not possible in HA?

1 Like

Guessing you don’t need the - before the include.

You probably need to indent the items in the included file so they are where they would be if you kept them in the main file.

This seems to work :+1:

logbook:
  exclude:
    domains:
      - sun
    entities: !include /config/exclude_entities/logbook_exclude.yaml

Why not put your entire logbook configuration in the include file and keep it all in one place?

Here is the configuration.yaml entry and the beginning of my recorder.yaml include file (works the same way).

recorder: !include recorder.yaml

##################################################################################################
# recorder.yaml
# https://www.home-assistant.io/components/recorder/
##################################################################################################

db_url: !secret MARIADB_URL
purge_keep_days: 7
purge_interval: 1

exclude:
  domains:
#  - alert
#  - automation
#  - binary_sensor
  - calendar
  - camera
  - delay
  - group
  - history_graph
  - light_store
2 Likes

Oh, but I did. This is an !include in another !include. I figure that most of the entities I don’t want in my logbook, I don’t want in the database or recorder either. With one !include for the entities, I don’t need to repeat a huge number of code lines.

Gotcha. Just an FYI - If you excluded them in your recorder they automatically won’t show up in your history or logbook because they aren’t in the database at all. Info near the bottom of this page.

5 Likes

Ah, I see! Great tip, thanks.

Thank you for this. I’ve been using HA for years and initially set up the logbook to have excluded domains and entities, and left it like that with the (incorrect) idea that it drops events from the DB.

Now I know it just hides it instead of dropping and I moved my configuration to recorder: to actually get the drop.

Sorry for the necromancy (the topic is 5 years old) but I wanted to highlight my gratefulness for the information.

1 Like

I’m a bit confused. I did exactly as you have done in your example, yet I am still getting flooded with camera log entries in logger. I have restarted.

Has this option been deprecated?

There is an issue with the logbook now, doesn’t look like a solution is forthcoming.

2 Likes