Hello… I’m a new user here and just getting my feet wet with Home Assistant. I love the platform so far, and am still coming up to speed.
I’m experimenting with different automations, and would like to create one to arm my Simplisafe Alarm when I lock my Yale Lock from the outside. I’ve created the following automation, but it only works when I lock the Yale Lock via my Home Assistant Dashboard. When I lock it using the keypad, manual deadbolt or Yale App, nothing happens. (I actually don’t want it to arm when locking the deadbolt manually from the inside). Once I have this working, I would like to do the same thing to disarm the alarm when I unlock the door.
Here is my current automation:
alias: Yale Lock Arm Alarm
description: ""
trigger:
- platform: state
entity_id:
- lock.front_door_lock
from: null
to: locking
condition:
- condition: state
entity_id: alarm_control_panel.alarm_control_panel
state: disarmed
action:
- service: alarm_control_panel.alarm_arm_away
target:
device_id: 4555c9x8478fx4b6665562x3232x4b3a
data: {}
mode: single
You are on to something here. Looking at the entity history it just goes to locked. However, the automation does trigger when I use the HA dashboard. I wonder if HA is smart enough to know it’s locking and triggers it.
I can change the automation to use locked, but then I have another issue. The alarm will arm anytime the state changes to locked, which could be triggered by me locking the deadbolt manually from the inside. Obviously, I don’t want to arm the alarm with me in the house. I wonder if there is a way to avoid that?
OK, I think I have it figured out. There is another entity called front_door_lock.operator That tracks the difference between a manual lock/unlock and one completed using the keypad. I need to figure out how to code it now. Will report back.
When I lock with the keypad the Operator is “One Touch Lock” so ideally, I want to say:
[When state changes from Unlocked to Locked AND Operator is One Touch Lock, arm the alarm.]
However, I’m not great with code, so still figuring out that part.
Conversely, I need to do the same to disarm the alarm, so something like…
[When state changes from Locked to Unlocked AND Operator is NOT Manual Unlock, arm the alarm]
I just need to figure out how to write that in YAML and I should be good to go.
OK, I’ve updated the code… Now for the one to disarm the alarm. This is a bit more tricky. The easy option is to just have the alarm disarm when the state changes from Locked to Unlocked and not worry about the Operator. However, that could cause an issue if someone were to break in via a window, and just unlock the deadbolt manually, it would disarm the alarm…
Ideally, I’d like to have multiple options for the condition, something like…
If sensor.front_door_lock_operator is “Matt” disarm alarm with code 1234
If sensor.front_door_lock_operator is “Erica” disarm alarm with code 5678
If sensor.front_door_lock_operator is “Billy” disarm alarm with code 9101
But how do I write the code to link each condition with a different action? Should they be separate automations for each one, but each with the same trigger?
I really appreciate all your help. I still don’t quite have the “lock” scenario working yet. Not sure why but the arming of the alarm isn’t being triggered.
I’m wondering if the “One-Touch Lock” should be in quotes or not, or if that is actually what the state is called. I know that’s what it shows in the History page, but wonder if it’s flagged as something else behind the scenes. Any ideas?
I took the state from your screenshot of the history graph. To see the actual state go to Developer Tools → States and look for your sensor.front_door_lock_operator entity.
You can filter on strings at the top of the columns to make it easier to find.
I figured it out… So, I now have the lock part working. I actually changed the YAML to trigger the arming of the alarm based on the sensor.front_door_lock_operator like this:
alias: Lock Arm Alarm
trigger:
- platform: state
entity_id:
- sensor.front_door_lock_operator
from: null
to: One-Touch Lock
condition:
- condition: state
entity_id: alarm_control_panel.alarm_control_panel
state: disarmed
action:
- service: alarm_control_panel.alarm_arm_away
target:
device_id: 4555c9e8478fx4x6665562x3232x4b3a
data: {}
mode: single
So, the lock/arm automation works. Now I need the unlock/disarm automation to work. This is what I have so far, but it isn’t working. I must be missing something.
alias: Lock Disarm Alarm
trigger:
- platform: state
entity_id:
- sensor.front_door_lock_operator
from: null
to: Matt
- platform: state
entity_id:
- sensor.front_door_lock_operator
from: null
to: Billy
condition:
- condition: state
entity_id: alarm_control_panel.alarm_control_panel
state: armed_away
action:
- service: alarm_control_panel.alarm_disarm
target:
device_id: 4555c9e8478fx4x7765562b3232x4b3a
data:
code: "0000"
mode: single
I checked out the link and it was helpful. Used the trace, and it appears my automation was triggered and did actually run, it just also appears that the alarm didn’t disarm. Maybe I need to wait a few seconds longer to give it time to react. I’ll try again tomorrow and circle back with an update.