Using person condition to turn on light after sunset if someone is home

I had an automation that turned on a group of lights 20 minutes before sunset.
In HA 0.88.0 Persons was introduced so I got that connected and working with my Asus router (asuswrt).
I added a condition to only turn on the light if someone is home but that doesn’t seem to work. I have no syntax errors in the script:

- id: '1548625652888'
  alias: Turn lights on at sunset if anyone is home
  initial_state: true
  trigger:
    event: sunset
    offset: -00:20:00
    platform: sun
  condition:
    - condition: state
      entity_id: group.people
      state: 'home'
  action:
    service: homeassistant.turn_on
    entity_id: group.evening_lights

I also tried to make an automation that turn on the lights when someone comes home after sunset (-20 min) but that doesn’t work either:

- id: '1550768069001'
  alias: Turn lights on when someone comes home after sunset
  initial_state: true
  trigger:
    platform: state
    entity_id: group.people
    from: 'away'
    to: 'home'
  condition:
    condition: sun
    after: sunset
    after_offset: -00:20:00
  action:
    service: homeassistant.turn_on
    entity_id: group.evening_lights

There might be something with ‘away’ and ‘home’ but those seem to be the values used by the group of persons. I also tried to remove “from: ‘away’” but still not working.

This is the group:

people:
  name: Personer
  entities:
    - person.john
    - person.doe
    - person.jane

Do anyone got a clue about the problem?

1 Like

I don’t use the “person:” component but are you sure that the component creates a “group.people” entity?

You can check in the dev-states for the entity that is created and for the state of each “home” or “not_home” or whatever.

I do not think you can use away as a state. Use not_home instead.

No, it doesn’t automatically create “group.people”. I created that group.