-
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
History of the Alarmo #642
Comments
I think this is already integrated in HA in the logbook integration. |
+1 |
This issue 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 |
Do I need to make a feature request? |
This would be great! :) |
This issue 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 |
+1 i tried to search in logbook for alarmo entity, but there is no logbook entry at all ... we absolutely need
probably one of the most important things missing in alarmo. no chance an alarm-system is missing that O_o so to answer your question @nielsfaber , no it's not sufficient for our use :/ ^^ |
+1 also from me I I'm in the same situation of @snickers2k. I have some faulty sensor triggering false alarms and I need to create a history of these false alarms to understand what I need to tune. @nielsfaber I read about your suggestion to use the logbook (https://www.home-assistant.io/integrations/logbook/). However I believe that if I setup a filter on that component to include "only" all my alarm sensors, then I won't be able to see any more events related to non-alarm stuff that happen in my house, right? I'm interested in retaining the default logbook behavior of HA (record and show all entity statuses) but it would be tremendously useful to have a logbook specific to the alarm system only. Btw if you are open to contributions I might be able to help developing such feature since I'm kind of confident with Python and asyncio (although not that much with the HA codebase)... probably I would need some guidance though. @MarcelS1988 would you mind re-opening this issue? thanks! |
@nielsfaber Please reconsider this feature. |
I hereby reconsider it 🙂 @f18m Any help is welcome! Both in cleaning up existing code or adding new features. |
I've been thinking a bit about this topic. @nielsfaber what do you think about the stack pee-wee+SQLite for the "history" feature?
That's really good. I'm mostly used to coding backends. Frontends are something I have done only sporadically and never created one from scratch... so good to know it should be easy :-) |
@f18m HA already has its own classes for handling storage. I was hoping no database libraries would have to be added for implementing this feature, just include some methods from HA. I know that HA uses a mix of SQL database and JSON text files for storage, and if I remember correctly these classes only cover the JSON storage method, Otherwise the method used in the Frigate component could be a useful alternative, but the implementation seems to contain quite some extra code related to storage handling which scares me off a bit. |
yeah right, good point.
Well I had a quick look and it seems to me that HomeAssistant is using SQLAlchemy (https://www.sqlalchemy.org/) which seems very similar (at least conceptually) to the pee-wee solution adopted by Frigate. Regarding the code at https://github.com/home-assistant/core/blob/dev/homeassistant/helpers/storage.py, it seems to be that, as you mentioned, it's mostly concerned about reading/writing Python dictionaries (in form of versioned JSON blobs). |
hi @nielsfaber , |
hi @nielsfaber , In particular I had a first look at the Alarmo source code and I wonder: would the EventHandler class be a good place to hook the storage of the event itself in some place (I would like to log to a file to get started?) |
@f18m I don't really have much pointers to help you to get started. As an alternative to storing state changes in a database, perhaps the relevant info could be retrieved from the HA logbook or history component. To me it seems this feature will/could look pretty similar to the HA logbook, but with multiple entities (all alarm + sensor entities). |
hi @nielsfaber ,
ok thanks, that's already a very good start. I'd like to start simple and then grow with features step by step. So I'll start by storing somewhere just the alarmo state changes.
Totally agree with that. I mentioned storing in a text file just as initial debug step.
That's a possibility I guess. I'm not sure however how smart can be the queries launched on the logbook database (actually it looks like the integration doing the recording is the 'recorder', see https://www.home-assistant.io/integrations/recorder ).
To address use case #1 using the standard HA recorder / logbook, we need to query the state of the sensors ONLY when the alarm was armed (the condition "alarm is armed" will create a series of time windows) and find out which sensor did trigger the alarm in those time windows. I'm not sure if the standard recorder/logbook is well-suited for such kind of queries. Addressing use case #2 is probably easier. If I go to the HA logbook today it's easy to find the time+date and see the arming/unarming state of Alarmo. The user information (who armed / disarmed) is missing though. Final point: it might be a nice feature to have a custom retention time, different from the standard HA recorder/logbook retention time (the 'purge_keep_days' setting). For all reasons above I believe that having a separate (lightweight) DB for Alarmo does make a lot of sense. Thoughts? Then I have a final question for you: I'm experimenting with the code changes in my fork. What's the best way to test the changes for the Alarmo component? Should I scp/rsync/just-copy somehow the modified Python files to the /usr/share/hassio/homeassistant/custom_components/alarmo folder ? Thanks again |
Hi, I'd quote the request and also signal what strangely happened to me: last night the Alarmo suddenly changed in "disarmed" around 3.30am and nobody of the two people having codes (me and my wife) have disarmed it (and unless we discover to be sleepwalkers we didn't...). |
Hi @nielsfaber ,
I'm back on this topic (history feature).
After these changes I was able to see my "print()" commands inside the Alarmo code.
Perhaps it could be worth adding a doc in this repo with the above procedure to explain how to test changes before submitting PRs ? |
Update: about point #1: it turns out to be much simpler than I expected. Apparently Alarmo frontend is 1 single Javascript file (cool!) so I just ran inside the devcontainer:
and now when I go to http://localhost:8123/alarmo I do see the Alarmo UI!! :) |
Update: about point #2: I actually found that I can successfully create an MQTT binary_sensor and use it in Alarmo configuration to test my changes.
where the file /tmp/my-mosquitto.conf contains:
I'm writing this down in the hope that this helps other to provide contributions to Alarmo! |
@nielsfaber , Should I be using instead hass.async_create_task() and asyncio framework? |
@nielsfaber I have created a first implementation of the History backend. In my local testing it seems to be working just fine... would you be able to help for the frontend part? |
It would be great if there is a alarm history where we can see all the action about the Alarmo.
something like this:
So here you can always see what happend, when the alarm is armed and by wo.
Which sensor are got alarm and so on....
The text was updated successfully, but these errors were encountered: