diff --git a/packages/security/security.yaml b/packages/security/security.yaml index 2486cc9..6d30aa6 100644 --- a/packages/security/security.yaml +++ b/packages/security/security.yaml @@ -625,3 +625,49 @@ automation: data: title: "Doorbell" message: "Home Doorbell Rang but could not create event: {{ event_data['content']['message'] }}" + + - alias: Notify that Garage Door is Open + trigger: + - platform: state + entity_id: alarm_control_panel.ha_alarm + state: + - 'armed_away' + - 'armed_home' + - 'armed_night' + - 'armed_vacation' + condition: "{{ is_state('binary_sensor.garage_door', 'on') }}" + mode: restart + action: + - alias: Set up variables for the actionable notification + variables: + action_close: "{{ 'CLOSE_' ~ context.id }}" + action_ignore: "{{ 'IGNORE_' ~ context.id }}" + + - alias: Ask to close the Garage Door + action: notify.iphone_jp + data: + title: Garage Door Open + message: The garage door is open - close it now? + data: + actions: + - action: "{{ action_close }}" + title: Close + - action: "{{ action_ignore }}" + title: Ignore + + - alias: Wait for a response + wait_for_trigger: + - platform: event + event_type: mobile_app_notification_action + event_data: + # waiting for the specific action avoids accidentally continuing + # for another script/automation's notification action + action: "{{ action_close }}" + + - alias: Handle the action + choose: + - conditions: "{{ wait.trigger.event.data.action == action_close }}" + sequence: + - action: switch.turn_on + target: + entity_id: switch.garage_door_relay_1