Home and Away states to use in automations etc

Hello,

I was a user of Samsung Smartthings for many years, and one feature I made a massive use of was the “home mode” where you could have it also set to home or away based on tracking of home members phones. I used it for security purposes and other automations.

I’ve been searching a while now and I am struggling to implement the legacy group based method I am finding in the latest version of Home Assistant.

It is indeed super easy to have zone based automations set for one device tracker leaving or returning but difficult to set for multiple.

I’ve tried to set an Input Boolean to a state depending on device zone locations in conditions but you can only appear to have one trigger for that automation so you appear to need to create another automation for each device tracker?

To be clear I do have the Home assistant client app setup and location based tracking and zones working.

Any suggestions on the best way to go about this? I’d love to follow the latest best practices and recommendations.

Thank you.

Don’t you want to share your code (or part of your code) so we can under tand better where are you struggling?

By the way, have you tried to play with groups, persons, etc?

Hi, I think groups and helper input select is your answer to this.

#groups.yaml
  adults:
    name: Adults
    entities:
      - person.anssi
      - person.mea
  kids:
    name: Kids
    entities:
      - person.aki
      - person.mimi
  all:
    name: Family
    entities:
      - person.anssi
      - person.mea
      - person.aki
      - person.mimi

Automations:
When someone comes home (group Family) - Set Home mode to Home
When no one is home (group Family) - Set Home mode to Away

Let me know if you need more details

3 Likes

Thank you both.

So part one of my problem was I was adding the groups incorrectly to the configuration.yaml (I hadn’t tried the groups.yaml). Turns out with the configuration.yaml you need to add “group:” first which makes sense now.

After setting this group correctly and reloading I was then able to toggle an input boolean in automations based on this new family group state (home or not_home).

I was also trying to use device_tracker before but the one you posted is far more elegant and works.

Seems to be working great, a start to many more automations! Big thanks.

2 Likes

Good to hear that!