Template not working correctly

I have an template in an automation that looks to see how many persons are home. Here it is:

{% if ( state_attr('zone.home','state') | int(72)) == 1 %} true {% else %} false {% endif %}

The test does not pass:

here is the state of the zone:

image

why would this not be true? really, I want it to be >= 2 but right now but that shows as condition passes. did I write something incorrectly?

The template is working correctly based on what you wrote:

There is no attribute called ‘state’… so ‘state_attr(‘zone.home’, ‘state’)’ returns a null value…

Then you convert null into an integer, which it can’t do… so it returns your default value of 72.

72 is not equal to 1… so false is the correct output.

Also, if you just need your template to return true or false, you do not need to use if/then/else statements for a basic comparison…

{{ states('zone.home') | int(0) >= 2 }}

oh ok. someone else wrote it for me in another post for another automation I was doing so I coverted it for this use. I’m not fluent at all for this. I thought because in my second screenshot that the state for zone.home was one that I could use that in the template like i did in the code I posted.

Just tested it. that obviously worked. Thanks for your help