Leaving Home, SHOULD trigger all the lights to go out

Hi,
Currently I’m trying out to get a working automation, where if I leave the home. The lights should go out.

Right now in the logs, it notices me leaving the home, but then again. It’s not triggering the automation. Am I doing something wrong?
Right now I’m working from the UI and not really in the “code” side of things. I don’t know if people could help me or point me in the right direction?

Thanks!

See image below how I set it up right now.

The trigger looks OK. What action follows it?

Edit: If you’re editing in the UI you can still post code in the forum - it’s easier for us to follow.

Go to the three dots top right and select Edit in YAML:

You can then copy and paste the code;

description: ""
mode: single
triggers:
  - trigger: numeric_state
    entity_id:
      - zone.home
    below: 1
conditions: []
actions: []

When you paste into your post, use the preformatted text option (in the cogwheel menu top right of the post). That will keep the YAML layout.

@kazure What is “Thuis”? A zone? If so, you need to look at its state not one of its attributes. The persons attribute of a zone is a list of persons, not a number — delete the “Persons” from the Attribute field and leave that blank.

I’d say the trigger is not correct.
Post the correctly formatted yaml instead of images.

Oops, sorry. Missed that… :flushed:

Hi, I don’t have the older format anymore. But as @Troon said, it was the issue that I used an attribute, and should’ve left that field blank.

For good measure, see the current YAML

alias: lights_home-empty
description: ""
triggers:
  - trigger: numeric_state
    entity_id:
      - zone.home
    below: 1
conditions: []
actions:
  - action: light.turn_off
    metadata: {}
    data: {}
    target:
      label_id: aanwezigheid_verlichting
  - delay:
      hours: 0
      minutes: 0
      seconds: 5
      milliseconds: 0
  - action: light.turn_on
    metadata: {}
    data:
      brightness_pct: 40
      kelvin: 2000
    target:
      label_id: thuis_verlichting
mode: single

That automation turns your light on 5s after you leave the house. Are you sure that’s what you want?

Yeah…
It’s gonna shut down the lighting and start up the absence lighting.

Still need to do a lot of optimalizations, but it get’s the job done.

1 Like