I’m trying to create a conditional card that is present when a weather warning sensor (Environment Canada) is populated. I can’t make the state: or state_not: test to see if the sensor is populated. I recognize that I could make a template binary sensor, but that seems inefficient so I was trying to use a template in the conditional card conditions section.
This led me to another discovery - it seems like the value of the sensor when there is no warning is nothing. If I test for ‘is defined’ it is defined. If I test for ‘null’, it is not null. If I test for ‘none’, it is not none. “” and ‘’ give the same results. If I try ‘x{{ states(“sensor.warnings”) }}x’ in the template editor, I get ‘xx’, so it is not a single space or some other special character. The state is not ‘unknown’ either.
So, question 1 is can I use a template in the conditional card conditions, and question 2 is what state is this sensor in when it is not populated with data - even if I were to make a template binary sensor, I wouldn’t know how to test it.
Be aware that using jinja2 templates causes a we socket connection to be opened for the backend to parse and evaluate it. If you use a lot of them, it can become a burden on your server and your frontend