Need help to understand the logic of how to use Automation Conditions

Hi All i need a little help please.

I’m struggling to understand the logic of how to use Conditions in my Automations. Specifically if a condition is true will the action run or not run? I’m not grasping the basic logic of how conditions are designed to work.

This is my first example.
I am building an automation to power on some smart plugs (attached to ip cameras) when certain device_tracker items (mobile phones) change from home to not_home state. This signifies that all family members have left the house. The important thing is that the defined actions only run if “all” the device_tracker items are in the not_home state and probably for 30 more minutes.
In this example should i use conditions to test the current state as home or not_home? So if any family member is still home then don’t run the action.

My second example is almost the reverse of the first one. That is to power off some smart plugs when any one of the family members returns home.

I’m reading as many example automations as i can & reading the docs available but i’m just not getting it.

Cheers
Nick

A condition has to evaluate to true for the automation to run.
Conditions are AND logic by default (i.e. all conditions have to be true for the automation to run). However you can override this with condition: or in this case any of the conditions evaluating to true will cause the automation to run. You can also combine AND and OR conditions.

Thing are as @tom_l said.
I just want to add some more details.

According to what you want to do, I am already doing this with music from my tv, switching on or off the computers etc.

So:
Every automation needs a trigger, a condition and an action. (A condition is not always necessary. You can have no conditions if you want)
With that in mind:
Group your devices into one entity. If any of these devices are home, the entity will go from “not_home” to “home”. <<< use this as a trigger
Now go for this:

 condition:
  - condition: state
    entity_id: group.device_tracker.all
    state: not_home

and use that trigger:

  trigger:
    platform: state
    entity_id: group.device_tracker.all
    to: not_home
    for:
      minutes: 30

And then make your action turning on your smart plugs. Hope it made sense.

In that case I don’t think you need the condition at all!

Fantastic. Thanks for the help. I’m more clear on this topic now.