Basic absence automation

I can’t get following automation running.
My goal is to switch the light(s) off, when the last person is leaving home.
Where is my mistake?
I’m obviously new to home assistant.
Thanks for your help

alias: A home
description: ""
  - platform: state
      - zone.home
    attribute: persons
    to: "0"
condition: []
  - type: turn_off
    device_id: c42cb2d01fc76b5a75004bb76d8581bf
    entity_id: 9d6e28842c4e8b80882b334b60d54fe8
    domain: light
mode: single

Remove the attibute: persons line. That contans names. You need to test (the state of) zone.home itself. That holds is a person count.
Another tip: stay away from device actions. They tend to break causing much work. Use service light.turn_on instead.

1 Like

How should one know something like that… thank you for your help. It worked.

The way to find out these things is to go to the developer tools, states tab and look up the entity. There you can see the state and all the attributes with their values. Seems like I’m not there :slight_smile:

Also, Home Assistant has quite extensive documentation:

And if that does not help, ask here, like you did! Glad to help.