Zone not working in a template as is_state test

Tags: #<Tag:0x00007f32664a85b8>

I have the following in a binary sensor, but testing the template, it’s always showing false, even when I am in the zone defined.

  - platform: template
    sensors:
      justin_ingym:
        value_template: "{{ is_state('person.Justin', 'zone.The_Gym') }}"

The zone is defined and shows in the system view for me as ‘The Gym’ when I’m there. In the map it’s showing as The Gym with the co-ordinates etc.

I’m going to assume that all of the states are as you have them in your template. But just as an FYI “The_Gym”, “The Gym” and “the_gym” aren’t the same. So you need to make sure that the state of your person is entered exactly as shown in your states page.

But here s the correct template:

- platform: template
    sensors:
      justin_ingym:
        value_template: "{{ is_state('person.Justin', 'The_Gym') }}"

Thanks, I think I will make the zones specifically with a _ and no spaces to be sure I’m talking apples and apples then.

So, zone.zonename is not correct, just zonename?

you can write them however you want as long as you make sure you put them in the template the same way.

and yes, leave the “zone.” part out.

Thanks again, I added an underscore to them all in the map and then kept that in the template and removed zone. and it’s all working perfectly!

1 Like