Hi
I have the following YAML code to try to assign a user name in an array and send the user name via notification but I can’t find a way to return the results when the Z-wave notifiction is “Keypad unlock operation”
The following code keeps giving the following error “Message malformed: template value should be a string for dictionary value @ data[‘action’][1][‘data’]” code when I try to save the automation:
states(‘input_text.{{device_attr(trigger.event.data.device_id,“name”)|regex_replace(find=’ ‘, replace=’_‘,ignorecase=False) + ‘_last_user_name’}}’) I am pretty sure that the code is OK but I can’t find the way to get it to work in the array
Can someone explain me what I am missing here
thanks
P.s., I have also tried the following variant but nothing works:
{{ states(‘input_text.{{ device_attr(trigger.event.data.device_id,“name”)|regex_replace(find=’ ‘, replace=’_‘,ignorecase=False) + ‘_last_user_name’}}’) }}
{{ states(‘input_text.{{ device_attr(trigger.event.data.device_id,‘name’)|regex_replace(find=’ ‘, replace=’_‘,ignorecase=False) + ‘_last_user_name’}}’) }}
{{ states(‘input_text.{{ device_attr(trigger.event.data.device_id,“name”) | regex_replace(find=’ ‘, replace=’_‘,ignorecase=False) + “_last_user_name”}}’) }}
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: 5
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.{{ device_attr(trigger.event.data.device_id,"name")|regex_replace(find=' ', replace='_',ignorecase=False) + '_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,'name') }}"
target:
- iphonebruno
data:
sound: spacealarm
mode: single