Smart way to use zones in your conditions

Hi guys, I was wondering if anyone has some tips for me. Here’s the thing:

I have quite some automations that include a condition wether I am home or not. At first that was quite easy, just use ‘home’ or ‘not_home’ as a condition. But now I’ve set up a few other zones like work. What I didn’t realise is that when I’m in the ‘work’ zone, that doesn’t count as ‘not_home’.

Off course I could add al the other zones to my conditions, but that requires some administration when I add new zones. What do you guys think is the most smart way to deal with this?

Try a template condition where you are <> home?

1 Like

Thanks. That looks like something I can use but I have a little trouble getting it right. How would my condition look? I tried this:

- id: '0000000000012'
  alias: Test Template Condition
  trigger:
  condition:
    condition: template
    value_template: "{{ is_state('device_tracker.iphone') <> home }}"

also tried this:

  condition:
    condition: template
    value_template: "{{ state_attr('device_tracker.iphone', 'state') <> home }}"

‘home’ needs to be quoted, for starters. But you’ve got a few other issues.

try this syntax:

value_template: “{{ not is_state(‘device_tracker.iphone’,‘home’) }}”

2 Likes

Thanks, works flawless!

1 Like