-
Notifications
You must be signed in to change notification settings - Fork 2
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
Remove set-stolen on alarm trigger #52
Conversation
@vlebourl I checked that I can recreate this feature using automations. Still need to test the alarm implementation in aiobiketrax though ;-) |
@@ -72,7 +72,7 @@ def state(self): | |||
"""Return the state of the device.""" | |||
return ( | |||
STATE_ALARM_TRIGGERED | |||
if self.device.is_alarm_triggered or self.device.is_stolen | |||
if self.device.is_guarded and self.device.is_alarm_triggered |
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.
can is_alarm_triggered
be true if is_guarded
is false? If not this is redundant.
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.
I think it does not hurt. I could also invert all the if-statements to achieve the same. Just want to prevent any side-effects: I would not expect the alarm to be triggered if it isn't armed.
await self.device.set_stolen(True) | ||
# There is not really a possibility to trigger an alarm, so at | ||
# least enable it. | ||
await self.device.set_guarded(True) |
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.
maybe set_guarded
could be a switch or a button attached to the device rather than the trigger command, as you rightfully commented, this doesn't trigger the alarm...
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.
The async_alarm_trigger
is only executed when you want to trigger the alarm on command. The closest you can do is to enable the alarm then.
What do you mean with a switch or button?
Did a test tonight, and it seems to work great with an automation. Once the alarm sounds, the state automatically changes to 'stolen', as configured in the automation. |
fde43ab
to
b4cc306
Compare
I just checked out your branch in my prod HA, I'll let you know how it runs here after a few days! |
Did you encounter some issues after testing? |
Working great! |
b4cc306
to
c548b8b
Compare
Thanks for testing! |
Marking the device as stolen when the alarm is enabled would mark it as triggered, which might not be the case.
The same 'functionality' can be recreated using automations, so it is up to the end-user to enable this or not.