Trigger Automation if if first Person comes home

Hello Everyone,

I try to trigger an automation only if the first person comes home. My yaml code looks like this:


trigger:
  - platform: state
    entity_id:
      - person.p1
    to: home
    for:
      hours: 0
      minutes: 0
      seconds: 0
  - platform: state
    entity_id:
      - person.p2
    to: home
    for:
      hours: 0
      minutes: 0
      seconds: 0
  - platform: state
    entity_id:
      - person.p3
    to: home
condition:
  - condition: and
    conditions:
      - condition: state
        entity_id: person.p1
        state: not_home
      - condition: state
        entity_id: person.p2
        state: not_home
      - condition: state
        entity_id: person.p3
        state: not_home

The automation doesn’t trigger because when the trigger fires the conditions can’t be met anymore. Of course I could create a separate automation per person and then only check the other two in the conditions.

Does anyone see a smarter way? How can I solve this in one automation?

Thank you very much!

You can trigger off the zone.home entity. It has the count of the number of people at home, so when somebody gets home it will go from 0 to >0 (2 people might arrive together).

2 Likes

Zone state trigger:

trigger:
  - platform: state
    entity_id:
      - zone.home
    from: "0"
2 Likes

Wow thank you very much!! This worked like a charm!!