-
Notifications
You must be signed in to change notification settings - Fork 120
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 History backend (#642) #960
Conversation
sounds nice @f18m , but why is this not integrated with the database of choice (the recorder) as configured by the user. |
hi @rolfvreijdenberger thanks.
|
I'll read #642 for context first. Without knowing what's in there fully right now, can't you solve some issues using the actions section with a custom logging rule? in other words, solve it in the alarmo application as an end user implementation instead? logging these events with more contextual data in it seems possible so you add least solve some of the problems stated in #642 |
hi @rolfvreijdenberger , This is hard to do using the Recorder alone: I have more than 20 sensors: I should open their recorded statuses together with the Alarmo control panel status to check which sensor had a state transition (closed->open or no-motion->motion) WHILE the alarm was active. Doable but very unconfortable. And yes I might be building using Alarmo notifications/actions my own "logging system". Indeed for the past few months I've been running my own "logging" system: every time the alarm is triggered I send myself an email with the indication of which sensor triggered it.
Indeed I think that, if one day HomeAssistant Recorder gains such feature (ability to search on 'related' historical events and conditions), then this History feature of Alarmo might be discarded. |
Hi @f18m
I will keep the PR open for a while until it is feature-complete, when I find the time for it I may add some commits (mostly the frontend part). Thanks again for your efforts so far! |
We are indeed trying to make something similar to the logbook, but specific to the alarm. |
thanks!
ok right -- I guess it makes sense to store the sensor status only when the alarm is active though?
yes I have included a basic schema upgrade procedure but of course, the better we start from minute zero, the better is.
Should the configuration for such feature end up inside the existing AlarmoStorage class (and ultimately come from the Alarmo card UI)?
Inside const.py I added a DATABASE_MAX_EVENTS constant for that. it needs to be exposed as configurable parameter somewhere.
Good point. I guess we should be using this: https://developers.home-assistant.io/docs/config_entries_index/#removal-of-entries
Yeah I have no much experience with websockets. I do have some time to work on that... perhaps if you can hint the general way to follow I can try.
Thanks! |
hi @nielsfaber , |
@f18m
This link brings me to a logbook page showing a log for both the alarm entity and my security sensors, for the last 3 hours. Given that this is already possible through HA, I wonder what is the added value of adding a database and storing all such events, it seems a duplicate implementation. What are your thoughts about this? What use-cases do you have in mind for the feature? |
hi @nielsfaber ,
Actually to be honest I had already noticed that all entities that you choose in the logbook appear concatenated in the URL. However I'm not sure that the view obtained in such a way is really a "clear overview".
Well even if the logbook page was enough for a user, there is the problem of data persistence. For an alarm system you might want to back to alarms triggered even months ago right? Imagine leaving the house for an extended period of time (perhaps it's an house you use only in some months of the year).
My use case as described in #960 (comment) is that I have some "flaky" alarm sensors (after all HomeAssistant is mostly for DIY users right? so I installed most of the sensors myself...) and I get false alarms. So I want to have an history of all alarms triggered and check which sensor has triggered the alarm each time. This way I can focus my attention on the most problematic sensors.
I think this is also what other users were highlighting: So to conclude: I don't think it makes any sense to create a UI similar to the logbook UI. Hopefully I was able to explain my ideas... |
This pull request is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days |
Any updates on this? |
This PR is adding a basic implementation of an HistoryHandler inside Alarmo that is capable of storing all events inside a dedicated sqlite3 database.
The implementation is designed to be future-proof: a schema version is added in the database to handle future changes to the database format in a backward-compat manner.
The implementation includes a 'purge logic' to make sure a bounded number of events is stored in the database so it does not explode in size.
A function to query the database for all events within a time window is provided (this should be used by a frontend ideally).
The entire implementation is 212 lines in total (I tried to stay simple&lean).
I tested this PR using the devcontainer methodology and a fake sensor as described in #642 .
Example data produced and stored inside my sqlite3 database:
NOTE: the commits of this PR should be squashed before merging.