Hoping someone can help figure out why my two outputs in this test appear to be the same but my “if” statement says otherwise. I am pretty sure it has something to do with how my variables present but I am too much of a noob to figure it out. Thanks.
- alias: Samuel's Ceiling Fan States Check
{% set entity = expand('binary_sensor.samuel_s_ceiling_fan_wattage') | selectattr('state', 'eq', 'on') |map(attribute='entity_id')|join(', ') %}
{% set fan_current_state = states('switch.fan_light_samuel_s_room'),states('counter.samuel_fan_light'),state_attr('fan.samuel_fan','preset_mode'),states('counter.samuel_fan_speed') %}
{% set d = { 'binary_sensor.samuel_fan_low_speed':('off','0','low','1'),
'binary_sensor.samuel_fan_light':('on','1','off','0'),
'binary_sensor.samuel_fan_medium_speed':('off','0','medium','2'),
'binary_sensor.samuel_fan_low_speed_light':('on','1','low','1'),
'binary_sensor.samuel_fan_medium_speed_light':('on','1','medium','2'),
'binary_sensor.samuel_fan_high_speed':('off','0','high','3'),
'binary_sensor.samuel_fan_high_speed_light':('on','1','high','3'),
'binary_sensor.samuel_fan_off': ('off','0','off','0')
}
%}
{% set fan_true_state = d.items() | selectattr('0','in',[entity]) | map(attribute='1') | join(',') %}
{{entity}}
{{fan_current_state}}
{{fan_true_state}}
{% if fan_current_state == fan_true_state %}
true
{% else %}
false
{% endif %}