Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to update entity filters at run time #121377

Draft
wants to merge 19 commits into
base: dev
Choose a base branch
from
Draft

Conversation

bdraco
Copy link
Member

@bdraco bdraco commented Jul 6, 2024

Proposed change

Add ability to update entity filters

arch discussion home-assistant/architecture#1106

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.

To help with the load of incoming pull requests:

@gcobb321
Copy link

gcobb321 commented Jul 8, 2024

@bdraco
As I recall, the recorder filter is set when HA starts and can not be changed or added to later. Will the new functionality have this limitation?

i ask because I have some text based info sensors for each device that are tracked (iPhone, iPad , etc) which are updated frequently. I am excluding the associated sensors (sensor.gary_iphone_info, sensor.lillian_iphone_info, etc) by entity name to avoid impacting any other component. A new device added in the iCloud3 config_flow is added to this exclusion list when it’s sensor entity is created (john_iphone_info). This sensor will then be filtered.

If the recorder filter is only updated when HA starts, this will require a restart (or iCloud3 reload) when new devices are added. Using a Glob would work and be a lot easier to implement but I don’t think that can be associated with a domain and could effect other domains.

Do you have any thoughts on the best way to handle this?

@bdraco
Copy link
Member Author

bdraco commented Jul 8, 2024

As I recall, the recorder filter is set when HA starts and can not be changed or added to later. Will the new functionality have this limitation?

It works at run time, and takes effect immediately

Example usage:

from homeassistant.components.recorder import update_entity_filter, UpdateOperation

update_entity_filter(hass, UpdateOperation.ADD, exclude_entities=["sensor.john_iphone_info"])

The filter is updated for the duration of the run. It is not persistent at this time. In the future it may become persistent, but that is outside the scope of this change and the architecture discussion.

@bdraco bdraco changed the title Add ability to update entity filters Add ability to update entity filters at run time Jul 8, 2024
@bdraco
Copy link
Member Author

bdraco commented Jul 8, 2024

Note that the arch discussion doesn't have an approval yet so its still possible this design may change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants