Add support for limiting which entities are recorded#4733
Conversation
kellerza
left a comment
There was a problem hiding this comment.
Not sure if this is the correct approach, since the entity lists might become quite long. Also for some components it might be critical not to log it and the reason why I proposed to make this a property of the Entity rather (or even attribute of Entity so that it can be customized) in #4576
There was a problem hiding this comment.
You should probably complete your queue task before continuing
|
@kellerza Making it a property of the entity involves quite a lot of additional configuration with auto-discovery setups. In that scenario the easiest option might be to add an exclude option at the entity level but leave include at the recorder object? |
|
Actually the oppsite, if an Entity contains its sane defaults, it will ok on discovery. Customizing can then force/change the behaviour. |
|
@kellerza I don't think I'm quite clear on this. If I want to limit recording to a single entity, I probably don't want to have to add explicit configuration for everything that's currently autodiscovered in order to exclude those and leave behind the one I want - similarly, it would feel odd if adding configuration for a single entity were to change the behaviour of every other entity. Having that configuration at the recorder level feels more obvious in that respect. Am I misunderstanding your proposal? |
|
The idea was that an entity indicates its recorder level and then you can, in rare cases, overwrite it with Say you have three states for the Entity's In the Most entities will default to All. It will cover your |
|
Ah, ok, only saw @balloob 's reply now |
|
@balloob I see this as a similar property to Examples:
In summary, I have no objections adding it here, it answers a immediate question after all. Just feel that we could go down a path that can answer at least two of the questions raised in #4576 more elegantly. |
|
I think that recording is not a concern that the core should even be aware of that it exists. Entities should not have to care about anything outside of themselves, their state and their attributes. An entity has a few properties that go beyond this, but they are exceptions to give hints to our UI how they should be rendered: Recording can have so many use cases, allowing that to sip into the core will open the door for more attributes and properties to add. Sure, the idea that a sensor can tell that it will update frequently and a switch that it won't is already engrained in their domain. If the domain is not clearly representing the entity that it holds, the entity should be part of another component (or maybe it's own). When it comes to a distributed setup of HASS: let's figure that out when we get there. But adding an origin like we already do for event (remote/local) would be an easy fix there. Entity properties would not be the answer there, because how would a local recorder know to record it if it is saved in the entity? |
|
Maybe making it a property or attribute is the wrong approach, but if we make it an attribute only we can get the same behaviour In a way we will already go the attribute route. In #4614 we will add an attribute called 'restored' to indicate to the frontend this state was restored from the DB. Part of this will be adding logic not to record entities with the 'restored' attribute or at least on the first shot. In this way the core does not have to be concerned about it at all, but it is still an interaction between the Entity and the (The recorder is actually also the perfect place to clear the 'restored' attribute, but that is a side topic) |
|
The difference with the restored property is that the entity is not in control of it. It's not part of the Entity class or any component base classes. It is something that gets added by the new A property will also introduce problems if you would want to use the recorder component and the InfluxDB component and record different things for each. |
|
If we think about it as two different recorder components with different scope of entities to record, having local config makes sense. Still would have liked a way to indicate that an entity is a spammer (like the sun's elevation attribute), but will ponder it a bit more... |
752cdeb to
4dbc34a
Compare
There was a problem hiding this comment.
line too long (88 > 79 characters)
|
Done - domain support seemed easy enough so I added that as well. |
4dbc34a to
aa784f7
Compare
kellerza
left a comment
There was a problem hiding this comment.
Thanks, do you mind adding a test for this logic, especially the include part?
I think the way the recorder unit tests are structured it might be easier to set recorded.INSTANCE.include_* and test the event in your test case and not try the full init cycle.
Not squashing commits from here on will help subsequent reviews
There was a problem hiding this comment.
Can you import these from history? Or better yet if only in history move it to consts and import from there?
There was a problem hiding this comment.
No need to save both entities dict and the expanded lists
There was a problem hiding this comment.
Only need to test if not in list
There was a problem hiding this comment.
Self.include should always be true here, because of voluptuous passing in a dict of empty lists
|
@mjg59 shout if you get stuck with the unit tests |
For privacy reasons, it may be desirable to either exclude some entities or domains from being recorded or limit the recorded devices to a specific list. This patch adds support. The exclude list allows for domains and entities to be blacklisted such that they will never be recorded. The include list, if present, will avoid recording all entities and domains unless they appear in the list.
aa784f7 to
1e671e0
Compare
|
@kellerza Thanks for fixing that up - I'm still out of town, but will fix up docs this week! |
|
@mjg59 I updated the docs to your code, and added some extra stuff from history docs in a new PR. Hope my wording is correct ;) |
|
@mjg59 I updated hass to the dev version, but it seems domain filtering doesn't work.. entities get filtered properly though. Configuration: recorder:
db_url: !secret db_url
purge_days: 3
exclude:
domains:
- group
- scene
- updater
- weblink
- zone
entities:
- sensor.time
- sensor.since_last_boot
- sensor.disk_free_ |
|
Sorry for the late feedback, I updated the code this morning, but also horribly broke my MySQL server while trying to reset the DB, so I need to fix that before I can report back. |

Description:
Allow filtering of entities in the recorder component where there may be privacy concerns.
Pull request in home-assistant.github.io with documentation: home-assistant/home-assistant.io#1539
Example entry for
configuration.yaml(if applicable):Checklist:
If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
toxrun successfully. Your PR cannot be merged unless tests passREQUIREMENTSvariable (example).requirements_all.txtby runningscript/gen_requirements_all.py..coveragerc.If the code does not interact with devices:
toxrun successfully. Your PR cannot be merged unless tests passFor privacy reasons, it may be desirable to either exclude some entities
from being recorded or limit the recorded devices to a specific list. This
patch adds support. The exclude_entities list in the recorder configuration
provides a set of entities that will be excluded. The include_entities list,
if present, will avoid recording all entities except for those explicitly
included in the list.