core: Logbook exclude filters produce unexpected results when combined with recorder filters
The problem
I have a few excluded entities from the logbook integration which still show up in the logbook view as it seems the exclude filters are not being applied.
Using packages to split the configuration:
homeassistant:
packages: !include_dir_named packages
And the logbook integration is configured under config/packages/system/system_logbook.yaml.
Here’s the excluded entitities showing up in logbook:
What version of Home Assistant Core has the issue?
2022.10.1
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant OS
Integration causing the issue
logbook
Link to integration documentation on our website
https://www.home-assistant.io/integrations/logbook/
Diagnostics information
No response
Example YAML snippet
logbook:
exclude:
domains:
- group
- weather
- device_tracker
entity_globs:
- sensor.accuweather_*
- sensor.openweathermap_*
- binary_sensor.rf_motion_*
- binary_sensor.paradox_<serial_omitted>_zone_*_open
- light.*_off_lights
- light.browser_*
- switch.schedule_*
entities:
- sensor.security_last_motion_index
Anything in the logs that might be useful for us?
No response
Additional information
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 5
- Comments: 28 (15 by maintainers)
I also encountered the problem today. No matter what I try, my sensors cannot be excluded from the logbook integration, even though I am not interested in them being displayed.
Still an issue
The conversations were on discord, and sadly I’ve lost track of them at this point.
I think the next step would be to start an architecture discussion here so everyone can get aligned on a solution: https://github.com/home-assistant/architecture/discussions
Not sure if it is a conflict from user perspective although it might be a “conflict” in the overlayed filters from technical perspective.
It seems to be impossible to exclude something in logbook which has been included in recorder. I created 2 simple input_booleans to test the behaviour with this config which you might describe as “conflict”:
I would expect that a simple change to input_boolean.test_include is included in the recorder, but not in the logbook. As far as I remember this was possible before PR https://github.com/home-assistant/core/pull/72728 was introduced.
Logbook filters are overlayed on top of recorder filters. If you have a conflict in the two filters they won’t work as expected
Referring to PR #72728 it seems to be impossible to define an exclude for an entity for the logbook if this entity has been included via recorder, no matter by which filter type (domain, entity_glob, entity).
Feels like a Bug to me…
@bdraco I tried to dig a bit into the logbook source code and in detail into the PR #72728 because I wanted to understand what this change exactly does. Here are my findings and I would love to hear especially your feedback:
Conclusion: Merging the filter rules was a bad idea. Imo the recorder rules should only be applied for storing the logbook entries into db and the logbook rules should only be applied for returning them to UI, … That way no merge is needed.
This is a real nightmare, I wasted a lot of time trying to get the logbook to work properly before I read this.
It’s counter intuitive, I think there should at least be a note in the documentation.
That’s correct, includes always win in this case.
There’s been some talk about redoing the whole filtering system, but the conversations have died off a few months ago.
Just to set expectations, unless a champion appears to work on this, I expect the current state of things is how it’s likely to be for the foreseeable future.
After updating to 2022.11 it’s getting even worse for me, the excluded entity in logbook is not just wrongly logged in the logbook, the logbook also seems to log triggers from other entities which does not make sense at all.
Both entities are independent template sensors, why the heck does the logbook think one triggered the other 😆
EDIT: solved, this happens if multiple template sensors are generated from attributes of the same entity, they share the trigger context although no explicit trigger is defined. Got rid of this issue by defining a trigger on the attribute I want to template on.
This is the template binary sensor, just for completeness: