Getting the friendly name of the sensor triggered automation

Hi guys,

Been following some advice here on the forum regarding automation generalization, should this work ? please note that I use numeric_state as the trigger rather than state platform as the automation trigger which is the reason why I have doubt should it work or not :

- alias: Plants Watering
  trigger:
    - platform: numeric_state
      entity_id: 
      - sensor.guest_bathroom_plant_moisture
      - sensor.entrance_plant_moisture
      below: 20
  action:
  - service: notify.ios_ohad_iphone
    data:
      message: '{{ trigger.to_state.attributes.friendly_name }} need watering'
      data:        
        push:
          badge: 0
          category: 'plantnotification'

Thanks in advance

I think it should work as I do a similar thing :slight_smile:

 - alias: 'Plant Battery Check' 
   initial_state: off
   trigger:
     - platform: numeric_state
       entity_id: sensor.miflora_bird_of_paradise_battery, sensor.miflora_trailing_plant_bathroom_battery, sensor.miflora_volcano_fern_battery, sensor.miflora_flowering_fern_battery
       below: 5
       above: 1
   action:
      # Actions are scripts so can also be a list of actions
     - condition: time
       after: '17:30:00'
       before: '18:00:00'
     - service: notify.mypushbullet
       data_template:
         message: >
           '{{ trigger.from_state.attributes.friendly_name }} NEEDS a new Battery!'
2 Likes

Thank you very much, that did the trick :slight_smile: