Notification to State Which Sensor Triggered Manual Alarm

Thanks for taking the time to explain the details; I understand the challenge now.

The solution is to store the friendly_name of whatever triggers the first automation, then retrieve it in the second automation.

You can do that using chris_avfc’s zoogara’s suggestion using MQTT and a device_tracker. Alternately, you can store the friendly_name in an input_text.

Define the input-text entity:

input_text:
  trigger_source:
    name: Trigger Source

In the first automation, save the friendly_name of whatever triggered the automation to input_text.trigger_source:

  action:
    - service: input_text.set_value
      data_template:
        entity_id: input_text.trigger_source
        value: "{{ trigger.to_state.attributes.friendly_name }}"
    - service: alarm_control_panel.alarm_trigger
      entity_id: alarm_control_panel.home_alarm

In the second automation, simply retrieve the value of input_text.trigger_source:

  action:
    - service: notify.notify
      data_template:
        title: "ALARM!"
        message: "The alarm has been triggered by the {{ states('input_text.trigger_source') }} at {{now().strftime('%H:%M %d-%m-%Y')}}." 

4 Likes