Dealing with include/exclude in Logbook, History, HomeKit, other

Hi all,

I’m using HA since some times now and there is something that I may not understand well: include/exclude in components like History, Logbook, Homekit, etc.

For example my current configuration for the History component:

history:
  exclude:
    domains:
      - sensor
      - sun
      - automation
      - group

As you can see, I have excluded a lot of things because everything was in and I don’t want everything.
Now, I would like to add some sensors (but not all) to History. Do I really need to include them one by one? For example if I want all sensors except all that start by “sensor.dark_sky”?
I’ve tried this:

history:
  exclude:
    domains:
      - sun
      - automation
      - group
    entities:
      - sensor.dark_sky*

but it does not work. And as I have currently 161 sensors for Dark Sky, I don’t really want to exclude them one by one. And include all others sensors will not help as I have a lot of them too…

Any idea?
Thank you

As far as I know, there’s no templating or wildcards available for this. But I might be wrong.

I’d try using the Template Editor page and using the following to get the list, and then copy and paste it into your config file in the include option.

{% for e in states.sensor if not e.entity_id.startswith('sensor.dark_sky') %}
      - {{ e.entity_id }}
{%- endfor %}

Caveat: I can’t get the first line to include leading whitespace, so you’d have to edit that line to add it.

3 Likes

Thank you for your answer, that’s a good workaround to get the list :slight_smile:

It would have been nice if it had work like customize_glob.

1 Like