Recorder - exclude selection

Here is, Withings integration which provides 34 sensors.
Let’s say I want to exclude most of them, leaving only sleep related ones and of course all others untouched.

Any ideas how to do it nicely?

My first attempt looke like this:

recorder:
  exclude:
    entity_globs:
      - sensor.withings_*
  include:
    entity_globs:
      - binary_sensor.withings_in_bed*

And you know what? Only this only one sensor “withings_in_bed” was recorded. Where are all other entities which I did not excluded?

I read documentation and found that once I want to include single entity, I must include all others domains… who came to the thought it’s intuitive? Especially because list of domains is not fixed, every one has different list and those might change in time.

OK, I’ve changed it this way:

recorder:
  exclude:
    entity_globs:
      - sensor.withings_*
  include:
    domains: 
      - sensor
      - binary_sensor
      - switch
      - light
      - sun
    entity_globs:
      - binary_sensor.withings_in_bed*
      - sensor.withings_*sleep*

The result is that sensors listed in include/entity_globs are not inlcuded.

Maybe I’m missing something.

The easiest way I have found is to just include the entities you want by specifying them as domains, entity_globs, or entities. Everything else will be excluded by default.

Problem is I want to exlude some sensors using a pattern.
Doing your way I would need to include manually tens of sensors and every new in future. It doesn’t make sense

Ok. Well your exclude entity_glob sensors completely overlaps your include entity_glob sensors so I wouldn’t expect any of those sensors to show up as per the rules of the recorder.

All ACL systems I know allows exclude wider group and then include selected entities. Some of them give precedence to exclude or include depending on order of appearance. Recorder rules are so chaotic and inconsistent. But mainly I cannot see description for behaviour of overlapping blobs set to exclude and include at the same time

If I have to add manually 25 entities to exclude while being able to describe it by simple pattern
just to allow default behaviour for the rest of entities… then something is wrong with this feature.

OK, since I’m forced to go harder way, there is my current config:

recorder:
  exclude:
    entities:
      - binary_sensor.snapshot_stale
      - binary_sensor.updater
    entity_globs:
      - sensor.*waste*
      - sensor.*version*
      - sensor.*state*
      - sensor.*uptime*
      - sensor.*connection_type*
      - sensor.*battery_state*

Why entities defined by globs are not excluded?

example
obrazek

If I had to guess it would be it doesn’t handle more than one ‘*’ per glob. The few examples only show a single match anything point. Have you tried using only one?

No because I need to match both sides.
Pattern matching is around us for tents of years. I would be really surprised by this limitation 'cause there is no reason to limit it this way. And there is no word about that in the documentation.

There is no documentation that indicates how robust the pattern matching is. Since I don’t see any example besides a single star, I would lean towards not very robust. Maybe you should start with something that should work (a single *) and then successively add more complexity until it breaks.

But are you aware that pattern matching is not invented by HA devs? That we were using it even on 8bit computers in '80? I cannot believe it.
Anyway thanks for idea of trying what is beyond my imagination. I will do that once I find a time for another several HA restarts: another proof of great system design

I get you’re frustrated. I don’t keep a ton of metrics and I find creative entity naming along with using simple includes to work much better than a complex exclusion scheme. Just my two cents.

https://docs.python.org/3/library/fnmatch.html#module-fnmatch

2 Likes