-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
feat: Add support for Sector Alarm event entities and log ingestion #218
base: master
Are you sure you want to change the base?
Conversation
- Implemented SectorAlarmEvent entity to track log events per device - Established association between logs and pre-existing lock devices - Resolved name and model overriding issues when adding event entities - Parsed timestamps to compatible ISO format for Home Assistant display - Enabled log entries to be visible in the Home Assistant logbook - Added fallback setup and debug logging for reliable event ingestion This update introduces event tracking for Sector Alarm, enhancing log visibility and historical tracking directly in Home Assistant.
Should the |
One event which isn't picked up by the lock entity is "lock_failed" which is quite crucial if someone has left the door in a semi-closed state and the lock can't engage. For events such as arming/disarming the logs include data about what user and how the alarm was engaged which isn't otherwise accessible. Alternatively we could just filter out the things which we can only get from the log. |
I think we should update
That makes sense 👍
I think with the |
- Corrected the matching logic in `process_events` within `coordinator.py`: - Previously, logs' `LockName` values were not matching any devices because `self.data["devices"]` used serial numbers as keys. - Updated the code to iterate over `self.data["devices"]` and match `lock_name` against each device's `name` field. - This ensures that events are correctly associated with their respective devices based on `LockName`. - Resolved `RuntimeWarning` about `async_update` not being awaited in `event.py`: - Adjusted the listener setup in `async_added_to_hass` to properly schedule `async_update` as a task. - Used `lambda: self.hass.async_create_task(self.async_update())` to ensure `async_update` is awaited. - Modified the `state` property in `SectorAlarmEvent` to return the latest `EventType` instead of the timestamp: - This aligns the entity state with the expected event type (e.g., "lock", "unlock"). - Cleaned up redundant code and unused attributes in `event.py`: - Removed `_queued_events` and related logic since events are processed immediately. - Simplified the class by keeping only the necessary attributes. - Added additional debug logging throughout `coordinator.py` and `event.py`: - Included logs for device initialization, event processing, and entity creation. - These logs aid in tracing the flow of data and diagnosing issues in event handling. These changes address the issue where lock events were not being matched to devices due to incorrect key usage in device mapping. They also fix asynchronous handling in the event listener to prevent runtime warnings. --- **Files Changed:** - `coordinator.py`: - Updated `process_events` to match `LockName` with devices by `name` field. - Added debug statements to trace event processing. - Removed unused methods and cleaned up the code. - `event.py`: - Fixed asynchronous call to `async_update` by scheduling it properly. - Changed `state` property to return the latest event type. - Removed redundant attributes and methods. - Enhanced debug logging for entity creation and event triggering.
…ual event history instead, cache the result to avoid multiple lookups towards the API
So rather than registering failed_lock as an event should it update the state of the lock entity? |
Ready for review again, everything is working as expected now. |
This update introduces event tracking for Sector Alarm, enhancing log visibility and historical tracking directly in Home Assistant.