#How do I reference a the trigger state in a CHOOSE block?

1 messages · Page 1 of 1 (latest)

sacred sequoia
#

I currently have a Door lock where I have several codes configured. I want to receive a notification with the name of the user whose code was entered. Working today, I have a notification automation created for each user.

Single User Notification Automation

triggers:
  - trigger: event
    event_type: zwave_js_notification
    event_data:
      domain: zwave_js
      node_id: 0
      event_label: Keypad unlock operation
      parameters:
        userId: 1
conditions: []
actions:
  - variables:
      notification_message: User 1 unlocked the Front Door using a PIN
  - action: notify.mobile_app_adminuser
    data:
      message: "{{  notification_message }}"

However, I can see this can become inefficient the more codes I use. I want to create one notification automation that uses the userId value to determine the message. I was thinking the Choose construct would work for what I am trying to do, however I cannot seem to properly reference the userId value from the trigger block.

Does the userId value have be referenced in the trigger block, or is it available to be referenced because it is in the notification event block.

Unified Notification Automation
https://dpaste.org/4o0Oy

Thanks in advance for any help or direction that you can offer. After reading through the documentation and the community posts, I seem to come to the end of me.

delicate grail
#

the trigger variable is available in both the condition and action blocks

#

one thing I notice is that you're comparing against a string, when that field could be an integer

#

and second, your trigger in the example above implies that it's under paramaters:, but you haven't referenced that in your templates

sacred sequoia
#

@delicate grail Thanks for your help. I that the the string/interger might be an issue. I only assumed that it was a string as it was not used as as scalar value.

The trigger data is

event_type: zwave_js_notification
data:
  domain: zwave_js
  node_id: 9
  home_id: 9999999999
  endpoint: 0
  device_id: 37ad1070e88b30c484e2dcd229e42368
  command_class: 113
  command_class_name: Notification
  label: Access Control
  type: 6
  event: 6
  event_label: Keypad unlock operation
  parameters:
    userId: 1
origin: LOCAL
time_fired: "2025-10-06T18:25:51.250381+00:00"
context:
  id: XXXXXXXXXXXXXXXXXXXXXXXXXX
  parent_id: null
  user_id: null

To reference the userId , would this be the appropriate format?

 conditions:
          - alias: UserID =1
            condition: template
            value_template: |
              {{ trigger.event.data.parameters.userId == 1 }}

Feel free to point me in the right direction to RTFM or good examples.