Set a unique device alias for an automation only

I searched around and couldn’t find my specific question so I figured I would post here.

What I am trying to achieve is to set a specific alias to a device, but only for one specific automation. Here is my use case:

I have some multipurpose sensors, where one of the functions is an entry sensor. I have set up an automation to notify me when one of these sensors is open, however, the friendly name being office_multipurpose_sensor_zha is a bit long for my liking, but I don’t want to change it in the device list because it allows me to quickly identify it if needed. Here is my current simple entry automation:

alias: Entry Door Notification
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.back_sliding_door_multipurpose_sensor_zha
      - binary_sensor.basement_multipurpose_sensor_zha
      - binary_sensor.office_multipurpose_sensor_zha_opening
    from: "off"
    to: "on"
condition: []
action:
  - service: notify.notify
    data:
      message: >-
        The {{trigger.to_state.attributes.friendly_name }} was {{trigger.to_state.state}}
mode: single

What this is getting me is the output:
“The Office Multipurpose Sensor ZHA Opening was on”

What I am trying to get it to say is
“The Office Door was opened”

Any help to achieve this or point me in the right direction would be greatly appreciated.

  - service: notify.notify
    data:
      message: >-
        The {{ trigger.to_state.name.split()[0] }} Door was {{ iif(trigger.to_state.state == 'on', 'opened', 'closed') }}

Absolutely perfect. Thank you very much!

1 Like