Sending notification which sensor triggered the alarm

Hi,
I would like to send a notification when the alarm is triggered and in that knowing which sensor triggered the alarm so i have following :

#################################################
#          Trigger alarm while armed....        #
#################################################
- alias: 'Trigger alarm while armed away'
  initial_state: true
  trigger:
    - platform: mqtt
      topic: "home/433toMQTT"
      payload: 12345
    - platform: mqtt
      topic: "home/433toMQTT"
      payload: 123456
  condition:
    - condition: state
      entity_id: alarm_control_panel.alarm
      state: armed_away
  action:
    - service: alarm_control_panel.alarm_trigger
      entity_id: alarm_control_panel.alarm
    - service: notify.pushbullet
      data_template:
        message: >
          {% if trigger.payload | string == '12345'%}
            "main door"
          {% elif trigger.payload | string == '123456%}
            "kitchen door"
          {% endif %}

The problem is that the notification is sent right away when the alarm is triggered but i have 45sec to turn it off before it’s really triggered when i enter the house so essentially only in the case the alarm is really triggered it should send a notification. How can i accomplish that ?

I could make a automation that looks at the alarm_control_panel for it’s status triggered but i don’t know if i can get the triggered sensor to know.

any ideas would be appreciated.

Can’t you put a mins delay in the start of the action and have another automation that cancels the alarm one if the alarm is successfully deactivated?

1 Like

I am not sure exactly how to do that, do you have an example ?

#################################################
#          Trigger alarm while armed....        #
#################################################
- alias: 'Trigger alarm while armed away'
  initial_state: true
  trigger:
    - platform: mqtt
      topic: "home/433toMQTT"
      payload: 12345
    - platform: mqtt
      topic: "home/433toMQTT"
      payload: 123456
  condition:
    - condition: state
      entity_id: alarm_control_panel.alarm
      state: armed_away
  action:
    - delay: '00:00:45' # Add a delay for the time you are disarming
    - service: alarm_control_panel.alarm_trigger
      entity_id: alarm_control_panel.alarm
    - service: notify.pushbullet
      data_template:
        message: >
          {% if trigger.payload | string == '12345'%}
            "main door"
          {% elif trigger.payload | string == '123456%}
            "kitchen door"
          {% endif %}

#################################################
#          Trigger when alarm disarmed...                                  #
#################################################
- alias: 'Trigger when alarm disarmed'
  initial_state: true
  trigger:
     <on disarmed>
 action:
   - service: automation.turn_off           
     entity_id: automation.trigger_alarm_while_armed_away
  - delay: '00:00:45' # assuming it can take 45s to disarm
   - service: automation.turn_on          
     entity_id: automation.trigger_alarm_while_armed_away

Something like that should do it I think :slight_smile: You’ll have to figure out how to get the disarmed trigger working.

I do not use this component, but something like this may work as a trigger for the disarming

trigger:
  - platform: state
    entity_id: alarm_control_panel.ha_alarm
    from: armed_away
    to: disarmed

I shared my solution here, where I can pass the trigger to the actual automation that fires when the alarm is triggered, honouring timeouts: