swiim
October 7, 2024, 7:22pm
1
Hi
I’m trying to have a custom mushroom template card to show information about my dishwasher. I have the following code in Primary Information:
but no matter if the following is true or not it will act like its true and display that information. Are you not allowed to have multiple “elif” here or what am i doing wrong?
{% elif states(‘sensor.gaggenau_df270160f_68a40e0c737b_bsh_common_status_operationstate’,‘BSH.Common.EnumType.OperationState.DelayedStart’) %}
Added the code as plain text.
{% if is_state('sensor.gaggenau_df270160f_68a40e0c737b_bsh_common_status_operationstate','BSH.Common.EnumType.OperationState.Run') %}
Vasker: {% set rest = states('sensor.gaggenau_df270160f_68a40e0c737b_bsh_common_option_remainingprogramtime')%} {{rest}}
{% elif states('sensor.gaggenau_df270160f_68a40e0c737b_bsh_common_status_operationstate','BSH.Common.EnumType.OperationState.DelayedStart') %}
Starter {% set start = states('sensor.gaggenau_df270160f_68a40e0c737b_bsh_common_option_startinrelative')%} {{start}}
{% elif states('sensor.gaggenau_df270160f_68a40e0c737b_bsh_common_status_operationstate','BSH.Common.EnumType.OperationState.Ready') %}
Tændt
{% elif states('sensor.gaggenau_df270160f_68a40e0c737b_bsh_common_status_operationstate','BSH.Common.EnumType.OperationState.Inactive') %}
Dvale
{% else %}
Slukket
{% endif %}
petro
(Petro)
October 7, 2024, 7:28pm
2
please don’t post photos of code. Always post the actual code.
The reason your if statements aren’t working is because you’re using states
incorrectly. It seems like you should be using is_state
in some of those instead of states
.
swiim
October 7, 2024, 8:44pm
3
Thanks i added the code as plain text and will have a look at States
swiim
October 7, 2024, 8:51pm
4
Thanks - working now.
{% if is_state('sensor.gaggenau_df270160f_68a40e0c737b_bsh_common_status_operationstate','BSH.Common.EnumType.OperationState.Run') %}
Vasker: {% set rest = states('sensor.gaggenau_df270160f_68a40e0c737b_bsh_common_option_remainingprogramtime')%} {{rest}}
{% elif is_state('sensor.gaggenau_df270160f_68a40e0c737b_bsh_common_status_operationstate','BSH.Common.EnumType.OperationState.DelayedStart') %}
Starter {% set start = states('sensor.gaggenau_df270160f_68a40e0c737b_bsh_common_option_startinrelative')%} {{start}}
{% elif is_state('sensor.gaggenau_df270160f_68a40e0c737b_bsh_common_status_operationstate','BSH.Common.EnumType.OperationState.Ready') %}
Tændt
{% elif is_state('sensor.gaggenau_df270160f_68a40e0c737b_bsh_common_status_operationstate','BSH.Common.EnumType.OperationState.Inactive') %}
Dvale
{% else %}
Slukket
{% endif %}
petro
(Petro)
October 7, 2024, 8:52pm
5
this should work
{% if is_state('sensor.gaggenau_df270160f_68a40e0c737b_bsh_common_status_operationstate','BSH.Common.EnumType.OperationState.Run') %}
Vasker: {{ states('sensor.gaggenau_df270160f_68a40e0c737b_bsh_common_option_remainingprogramtime') }}
{% elif is_state('sensor.gaggenau_df270160f_68a40e0c737b_bsh_common_status_operationstate','BSH.Common.EnumType.OperationState.DelayedStart') %}
Starter {{ states('sensor.gaggenau_df270160f_68a40e0c737b_bsh_common_option_startinrelative') }}
{% elif is_state('sensor.gaggenau_df270160f_68a40e0c737b_bsh_common_status_operationstate','BSH.Common.EnumType.OperationState.Ready') %}
Tændt
{% elif is_state('sensor.gaggenau_df270160f_68a40e0c737b_bsh_common_status_operationstate','BSH.Common.EnumType.OperationState.Inactive') %}
Dvale
{% else %}
Slukket
{% endif %}