#Reference sensor name from autiomation conditions in notifications

1 messages · Page 1 of 1 (latest)

fading terrace
#

Trying to wrap my brain around how to reference data from the conditions section of an automation. It seems to reference the trigger you can do {{ state_attr(trigger.entity_id, 'friendly_name') }} but I want to reference whichever binary sensor in the coniditional section returned true.

Current yaml:

alias: Bin notification
description: ""
triggers:
  - trigger: time
    at: "18:30:00"
conditions:
  - condition: or
    conditions:
      - condition: state
        entity_id: binary_sensor.refuse_bin_reminder
        state: "on"
      - condition: state
        entity_id: binary_sensor.recycling_bin_reminder
        state: "on"
      - condition: state
        entity_id: binary_sensor.garden_bin_reminder
        state: "on"
      - condition: state
        entity_id: binary_sensor.food_bin_reminder
        state: "on"
actions:
  - metadata: {}
    data:
      title: 🗑️ BINS
      data:
        channel: Bins
        notification_icon: mdi:delete-empty
      message: "{{ state_attr(trigger.entity_id, 'friendly_name') }}"
    action: notify.all_devices
mode: parallel
max: 4
frozen dove
#

that information doesn't exist

fading terrace
#

ah right, so it doesn't get the variable passed out?

frozen dove
#

maybe you can make a variable in the header with a list of all the reminder sensors, and then you can make a template condition that loops over them, and in your message you can loop over the same list as well

#

if you don't want to repeat the list

fading terrace
#

hmm ok, will have a look at attacking it that way

dry yoke
#

OR...
Hi @fading terrace, BTW,
You can use a choose statement instead of a condition. This puts the condition(s) you want to do something with immediately on top of an action statement and you can always have a default that does nothing, so it could work the same, except you know which one(s) passed.