How to extract attr_name from trigger.event.data.device_id?

Hi, I am trying to extract the ‘name’ of a device id in a notification but can’t find a way to do it.

Below is the yaml code for a basic automation where if there is a ‘trigger.event.data.command_class == 113’ happening, I would like to receive a Pushover notification with the name of the device_id on wich there was a 113 event. Unfortunatlty, I can’t seem to find any way to get the ‘name_attr’ to be sent

Anybody can help with this ?

Here is my latest try where I have the following error message ‘Error: Error rendering data template: TypeError: attribute name must be string, not ‘LoggingUndefined’’

alias: Serrures Notification Pushover
description: ""
trigger:
  - platform: event
    event_type: zwave_js_notification
    event_data: {}
condition:
  - condition: template
    value_template: "{{trigger.event.data.command_class == 113}}"
action:
  - delay:
      hours: 0
      minutes: 0
      seconds: 2
      milliseconds: 0
  - service: notify.pushover_serrures
    data:
      message: |-
        {% set Lock_State_Array = {
           "Lock state: Lock jammed": 'Moteur bloqué',
           "Keypad lock operation": 'Barrée par le claiver',
           "Keypad unlock operation": states('input_text.serrure_cabanon_last_user_name') ,
           "Manual lock operation": 'Barrée manuellement' ,
           "Manual unlock operation": ' Débarrée manuellement',
           "RF lock operation": 'Barrée par RF',
           "RF unlock operation": 'Débarrée par RF',
           "Auto lock locked operation": 'Barrée automatiquement',
           "Battery level status: Charge battery soon": 'Changer les piles bientôt',
           "Battery level status: Charge battery now": 'Changer les piles immédiatement'
        } %}   
        {{ Lock_State_Array[ trigger.event.data.event_label ]}}
      title: "{{ device_attr(trigger.event.data.device_id,attr_name) }}"
      target:
        - iphonebruno
      data:
        sound: spacealarm
mode: single

Should attr_name be "name_by_user"?

Your template for title is trying to use a variable named attr_name, but you’ve never defined this as a variable anywhere. If you want the name, trying asking for the attribute called "name".

title: "{{ device_attr(trigger.event.data.device_id, "name") }}"

But the name is probably already in the trigger. You can check the traces and click on “changed variables” to see what all data comes in the trigger. Something like this should work:

title: "{{ trigger.event.data.device_name }}"

@atlflyer you put me on a good path, here is how I finaly got it to work:

title: "{{ device_attr(trigger.event.data.device_id,'name') }}"

unfortunatly, the

title: "{{ trigger.event.data.device_name }}"

did not work, it was not in the ‘‘changed variables’’, thanks a lot for your help