Hello all,
Below is my current code.
The issue I see with it currently is that if someone were to come through the back door at night and trigger the alarm, they would immediately get picked up with the “gym motion sensor” and it would kick into “dog mode” and the alarm would get disarmed for 20 minutes.
Is there anyway to get the order of events to matter inside of a home assistant automation. If so, or if another idea presents itself to someone, can someone show me how to modify my instance to make it happen. Essentially if the “gym motion sensor” were to go to state on and then any of the doors were to open that would be fine and I would want the dog mode section to run (disabling alarm, 20 min delay and then enabling back) but if the door were to go to “on” first, I wouldn’t want it go into the dog mode sequence and I would want it to trigger the alarm.
My hopes would be to modify the below in some way and keep all of the other logic intact.
Thank you all for any help/ guidance you can provide!!
- id: dog_mode_activated
alias: Dog Mode Activated
mode: single
trigger:
- platform: state
entity_id: binary_sensor.gym_motion_sensor
to: 'on'
- platform: state
entity_id: input_boolean.dog_mode
to: 'on'
action:
- choose:
- conditions:
- condition: template
value_template: '{{ trigger.to_state.attributes.friendly_name == "Dog Mode" }}'
sequence:
- service: script.text_notify
data:
who: parents
message: Dog Mode has been enabled manually
- service: script.dog_mode_lighting_on
- delay:
minutes: 20
- service: input_boolean.turn_off
entity_id: input_boolean.dog_mode
- conditions:
- condition: state
entity_id: input_boolean.sentry_mode
state: 'on'
- condition: state
entity_id: group.family
state: home
- condition: state
entity_id: group.external_doors
state: 'off'
sequence:
- service: input_boolean.turn_on
entity_id: input_boolean.dog_mode
- service: script.jarvis_alert
data_template:
message: Turning on Dog Mode.
- service: script.dog_mode_lighting_on
- service: alarm_control_panel.alarm_disarm
data:
code: '1131'
target:
entity_id: alarm_control_panel.alarmo
- delay:
minutes: 20
- service: input_boolean.turn_off
entity_id: input_boolean.dog_mode
- service: alarmo.arm
data:
entity_id: alarm_control_panel.alarmo
code: '1131'
mode: armed_night