Automation when every person leaves - not triggering

Evening everyone,

I had simple automation turning air purifier off when all.devices state changed to “not home”. Because I’ve added some new devices to my network which were constantly registered as “home” I’ve tried to modify the automation by using the new person component.

I’ve set the group.allpersons:

allpersons:
  name: All Persons
  entities:
    - person.mark
    - person.gos

Then tried below automation:

- alias: Turn off air purifier when everyone leaves
  trigger: 
    platform: state
    entity_id: group.allpersons
    to: 'not_home'
  action:
    entity_id: fan.air_purifier
    service: fan.turn_off

Unfortunately despite the changes in the state of the group the automation doesn’t trigger. What can be the reason? Does person component should be used differently then devices?

Look in the states page and make sure your automation is turned on.

I feel so stupid. Dont know why but in fact this one was turned off…
Switching it on solved the problem apparently - thanks :slight_smile:

1 Like

Add “initial_state: ‘true’” to your automation configuration to ensure the automation turns on every time you restart HA. It is supposed to be the default, but people have had issues in the past with automations turning off and turning back on after a reboot. See the bottom of this page.

1 Like

On a side-note, you might also want to consider changing to: 'not_home' to from: 'home'. In future versions/revisions of HA not_home might be renamed (eg: away) whereas home is less likely to be renamed. Also, not_home excludes any other zones you may have configured (now or in the future).

I am running latest version (0.115.4) with the same kind of trigger.
The automation is ‘on’ at all times but the group trigger does not work.
Checking the behavior of the group entity shows a perfectly working group entity.

I have changed the trigger condition to switch.one_of_the_sensors (just a stupid name for the post) in the group which was the test case and this works.
I fear there is a bug in the group triggering. I have the same issue with show boiler automation. I ended up using the following an if statement inside the trigger entity which caused the trigger to work.