I’ve had this value template for quite awhile and noticed lately that it hasn’t been working. It’s purpose is to read the value/name returned from a fingerprint scanner and set that value/name to an input text. I’ve read that data_template is no longer working so I suspect it has something to do with this but I have very limited knowledge on scripting.
Below is my original (non-working) template:
- alias: Fingerprint Scanner - User Identity
description: ''
trigger:
- platform: mqtt
topic: "/fingerprint/mode/status"
value_template: "{{ value_json.state }}"
payload: Matched
condition: []
action:
- service: input_text.set_value
data_template:
entity_id: input_text.last_garage_user
value: >
{% if is_state('sensor.fingerprint_person', 'Mark') %}
Mark
{% elif is_state('sensor.fingerprint_person', 'Jean') %}
Jean
{% elif is_state('sensor.fingerprint_person', 'Alexis') %}
Alexis
{% elif is_state('sensor.fingerprint_person', 'Ashley') %}
Ashley
{% else %}
Error
{% endif %}
mode: single
I decided I would give ChatGPT a chance to fix and it returned this, but it doesn’t work either. Anyone template experts here smarter than ChatGPT? lol
- alias: Fingerprint Scanner - User Identity
description: ''
trigger:
- platform: mqtt
topic: "/fingerprint/mode/status"
value_template: "{{ value_json.state }}"
payload: "Matched"
condition: []
action:
- service: input_text.set_value
target:
entity_id: input_text.last_garage_user
data:
value: >-
{% set p = states('sensor.fingerprint_person') %}
{{ p if p in ['Mark','Jean','Alexis','Ashley'] else 'Error' }}
mode: single