Optimize a value template with that has a lot of repeats?

Thanks for this… I have a question… these two lines… I think are incorrect as we end up with User containing the passcode?

{% set entity_id = 'input_text.door_keypad_' + number + '_name' %}
{% set user = 'Master' if number == '0' else states(entity_id) %}

In my setup, input_text.door_keypad_’ + number + '_name

is a persons name.

Yah, I was under the impression that input_text.door_keypad_x_name was a user_id or name.

This line just adds a bunch of strings together to end up with an input_text entity id.

{% set entity_id = 'input_text.door_keypad_' + number + '_name' %}

This line checks the number. If the number equals zero, it sets the user equal to “Master”. If the number is any other number, it gets the state from the entity_id variable and sets user equal to that.

{% set user = 'Master' if number == '0' else states(entity_id) %}