Closed xaviml closed 1 year ago
I have been able to reproduce your issue.
It happens when the safe_mode
is activated and you activate a door sensor, next you deactivate the safe_mode
and activate it back within the activation_delay
timer.
This PR solves the issue. Thanks @xaviml for your contribution
Bug description
The alarm triggers when it is disarmed and armed again within the
activation_delay
window. How to reproduce:safe_mode_delay
time.activation_delay
window, disarm the alarm and arm it back again.Actual: After doing that, the alarm will be triggered. Expected: The alarm should not be triggered since it was disarmed and armed again.
Fix
The problem is that the countdown for the
activation_delay
timer does not have a cancelation policy. This timer should be always canceled when the alarm is disarmed.Notes
I have also refactored some code to always use
self.safe_mode_active
rather than the checkawait self.get_state(self.safe_mode) == Generic.ON
. It is better to be consistent and use theself.safe_mode_active
since it is controlled based onsafe_mode_delay
value. This was not causing directly the issue, but it could potentially affect other corner cases. For this reason, it is better to be consistent and use alwaysself.safe_mode_active
.