-
-
Notifications
You must be signed in to change notification settings - Fork 28.4k
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 websocket API to get list of recorded entities #92640
Conversation
Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
Very interesting ! Going to try this out asap. |
Finished my testing of this patch on Core 2023.5. This works really well and behaves exactly as expected. I really hope this will be merged into Core. Not only will it restore functionality lost with #90992 in a much more flexible way, it also provides a very low latency and resource friendly way to retrieve the recorded entity list. This feature is very useful for frontend cards that provide some kind of UI to let users select entities based on recorder inclusion, like for example alternative history panels. Another use case is the automated creation of history graphs based on user supplied patterns. As an example, it will make alexarch21/history-explorer-card#162 possible in a way that was not possible before (due to the latency of the required database fetch). |
I hope this patch will be part of Core. As @alexarch21 wrote, this is really helpful! |
This is probably useful for populating the history panel and editor with the list of entities that are actually available in history instead of showing everything. We should work that into the frontend to see if the api as I threw it together makes sense for that use case before moving this forward |
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. |
Since the plan is to use this on the frontend now this should be ready to go. cc @karwosts |
Can you elaborate a bit how this selects entities? It's not quite working how I expected, though I might be missing something. When trying to test no matter what I add to recorder excludes, it doesn't seem to change the value returned. If I add an entity to recorder exclude (and restart), it is still returned in this list. If I additionally purge that entity, it is still returned in this list. If I add a domain to excludes, entities from that domain are still returned in this list. Do I need to flush some metadata, or repack the database, or anything like that to make an entity fully "nonrecorded"? |
You need to remove all history for the entity from the database and restart to make it go away after excluding it |
Ok. I guess that's a good argument for keeping the interface this way. |
What's somewhat interesting about this is it's finding a lot of junk that I had no idea was still there, it's returning me entities with no history records that I deleted months ago that are mentioned nowhere else. Not sure if that's addressed fixed by your earlier bugfix, but it's interesting. Was sort of prototyping a devtools panel that could show this information, not sure if that's too useful or not yet though. |
I think thats super useful. Users ask how to see that data all the time |
Frontend change approved to consume the API, now waiting for backend. |
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. |
unstale |
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @bdraco 👍
Thanks |
related thread https://community.home-assistant.io/t/2023-5-lets-talk/567331/273?u=bdraco
Proposed change
frontend PR home-assistant/frontend#19621
In #90992 we now require a list of entity ids to be passed to history to avoid the cases were systems were getting overloaded because the default was to return everything and that behavior was no longer viable (see the issue queue) now that most systems have hundreds of entities.
Some users have expressed a desire to know which entities are being recorded so they can feed the list back into the history APIs to achieve what they were doing before.
This change adds a websocket API to get list of recorded entities. It may be better to implement this as a REST api since we do not generally document websocket APIs, but I did it as a websocket API since we have generally stopped adding new REST apis except for large binary data.
Type of change
Additional information
Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.To help with the load of incoming pull requests: