So I’m working on updating one of my packages. Someone else here has done some good work that I’d like to incorporate. Problem (not really a problem), is that my door locks can have up to 30 codes, and I have muptiple locks Just was wondering if there was a better way to do something like this
value_template: >
{% if is_state('sensor.front_door_db_alarm_type', '112') and is_state('sensor.front_door_db_alarm_level', '0') %}
Master Code Changed
{% elif is_state('sensor.front_door_db_alarm_type', '112') and is_state('sensor.front_door_db_alarm_level', '1') %}
Person 1 Code Changed
{% elif is_state('sensor.front_door_db_alarm_type', '112') and is_state('sensor.front_door_db_alarm_level', '2') %}
Person 2 Code Changed
{% elif is_state('sensor.front_door_db_alarm_type', '112') and is_state('sensor.front_door_db_alarm_level', '3') %}
Person 3 Code Changed
{% elif is_state('sensor.front_door_db_alarm_type', '112') and is_state('sensor.front_door_db_alarm_level', '4') %}
Person 4 Code Changed
{% elif is_state('sensor.front_door_db_alarm_type', '112') and is_state('sensor.front_door_db_alarm_level', '5') %}
Person 5 Code Changed
{% elif is_state('sensor.front_door_db_alarm_type', '112') and is_state('sensor.front_door_db_alarm_level', '6') %}
Person 6 Code Changed
{% elif is_state('sensor.front_door_db_alarm_type', '112') and is_state('sensor.front_door_db_alarm_level', '7') %}
User Code Slot 7 Changed
{% elif is_state('sensor.front_door_db_alarm_type', '112') and is_state('sensor.front_door_db_alarm_level', '8') %}
User Code Slot 8 Changed
{% elif is_state('sensor.front_door_db_alarm_type', '112') and is_state('sensor.front_door_db_alarm_level', '9') %}
User Code Slot 9 Changed
{% elif is_state('sensor.front_door_db_alarm_type', '112') and is_state('sensor.front_door_db_alarm_level', '10') %}
User Code Slot 10 Changed
{% elif is_state('sensor.front_door_db_alarm_type', '112') and is_state('sensor.front_door_db_alarm_level', '11') %}
User Code Slot 11 Changed
{% elif is_state('sensor.front_door_db_alarm_type', '112') and is_state('sensor.front_door_db_alarm_level', '12') %}
User Code Slot 12 Changed
{% elif is_state('sensor.front_door_db_alarm_type', '112') and is_state('sensor.front_door_db_alarm_level', '13') %}
User Code Slot 13 Changed
{% elif is_state('sensor.front_door_db_alarm_type', '112') and is_state('sensor.front_door_db_alarm_level', '14') %}
User Code Slot 14 Changed
{% elif is_state('sensor.front_door_db_alarm_type', '112') and is_state('sensor.front_door_db_alarm_level', '15') %}
Use'r Code Slot 15 Changed
{% else %}
N/A
{% endif %}
The only thing changing is the alarm level which is the door code. If it’s a pain or makes it overly complex, then I’m good, just feel like there might be a way to say within a range, then use that number as a variable? I’ve done stuff like that in automations, but not in a sensor