Can {{ trigger.event.data.new_state.state.context.user_id }} be used as a condition or notification?

# tested both context.user_id and context['user_id'] and neither match a condition or can
be used in the notification

 - alias: 'notify - lock RF state change template'
   trigger:
     - platform: event
       event_type: state_changed
       event_data:
         entity_id: lock.zw_lock
   condition:
     condition: template
     value_template: >
       {{ trigger.event.data.new_state.state.context..user_id != 'null' }}
   action:
     - service: persistent_notification.create
       data_template:
         title: "mudroom - lock"
         message: "RF **{{ trigger.event.data.new_state.state | upper }}** \n user: {{ trigger.event.data.new_state.state.context_user_id }} \n\n {{ (now().strftime(\"%m/%d/%Y - %I:%M:%S %p\")) }}"

That double fullstop context..user_id probably isn’t making things work too well…

Addtionally I think it should be trigger.event.data.new_state.context.user_id

@mobile.andrew.jones

Indeed, you were correct on both accounts: (a) the extra “.” was my typo AND you correctly defined the trigger.event.data.new_state.context.user_id.

Thank you for your quick response and spot-on answer!

1 Like

Glad I could help. It took a LOT of reading past threads to find the right path to the user_id field. Although now that I think about it, I guess just looking at the trace of any existing automation would have also provided this information.