[Solved] Struggling with a template using a dictionary of strings

So I am monitoring my ZWave lock with a zwave_js_notification as the trigger that’ll send a notification when a specific key code slot was used. Basically I templated out the message porting of a notify service call to map the received slot ID from the zwave_js_notification trigger to a desired display string. However it seems to be failing all the time and not picking a string even though the trigger’s event data shown from the trace has the correct value I’m looking for. Since I’m a templating newbie, can someone take a look at my template and tell me what I am doing wrong?

service: notify.mobile_app
data:
  message: >
          {% set names = {
            '251':'Slot 251',
            '1':'Slot 1',
            '2':'Slot 2',
            '3':'Slot 3'
            } %}
          {{ names[trigger.event.data.parameters.userId] }} opened the front door with the keypad.

And here is the trigger’s data from the last automation execution trace.

this:
  entity_id: automation.front_door_unlocked_notification
  state: 'on'
  attributes:
    id: '<Some Value>'
    last_triggered: '<Some Value>'
    mode: single
    current: 0
    friendly_name: Front Door Unlocked Notification
  last_changed: '<Some Value>'
  last_updated: '<Some Value>'
  context:
    id: <Some Value>
    parent_id: <Some Value>
    user_id: null
trigger:
  id: '0'
  idx: '0'
  alias: null
  platform: event
  event:
    event_type: zwave_js_notification
    data:
      domain: zwave_js
      node_id: 158
      home_id: 4162111339
      device_id: <Some Value>
      command_class: 113
      command_class_name: Notification
      label: Access Control
      type: 6
      event: 6
      event_label: Keypad unlock operation
      parameters:
        userId: 251
    origin: LOCAL
    time_fired: '<Some Value>'
    context:
      id: <Some Value>
      parent_id: null
      user_id: null
  description: event 'zwave_js_notification'

that’s an int, not a string

          {% set names = {
            251:'Slot 251',
            1:'Slot 1',
            2:'Slot 2',
            3:'Slot 3'
            } %}
          {{ names.get(trigger.event.data.parameters.userId, 'Error') }} opened the front door with the keypad.
1 Like

Ahhh, Thanks I’ll give that a shot.

Just tested this out when I got home and it worked great. Thanks for the help