Execute an action when nobody is home, how?

Hi,
I have an input boleean to make a switch turn on or off. I made an automation witch acts, depending if the switch is on or off.

Unfortunately the input boleean doesn’t work correctly. I find in the log several times that "rico’ changes (see picture) while he is not ar home.

Where do I need to make an adjustment or any other way to make it work?

Thanks!

`
alias: voordeurschakelaar updaten bij afwezig
description: “”
trigger:

  • platform: state
    entity_id:
    • device_tracker.josine
    • device_tracker.luna
    • device_tracker.rico
    • device_tracker.sander
      condition: []
      action:
  • if:
    • condition: state
      entity_id: zone.spitzers
      state: “0”
      alias: Als iedereen weg is
      then:
    • service: input_boolean.turn_off
      data: {}
      target:
      entity_id: input_boolean.voordeur_op_slot_bij_afwezig
      alias: zet schakelaar uit
      else:
    • service: input_boolean.turn_on
      data: {}
      target:
      entity_id: input_boolean.voordeur_op_slot_bij_afwezig
      alias: zet schakelaar aan
      mode: single
      `

Please post your code as pre-formatted text (</> in the toolbar). It’s very hard to read otherwise.

Hi Stiltjack,

I did but it didn’t change anything.

You need to use three backticks in one line before and after the code you want to post.
It’s not, that we don’t want to help, it’s because indentation is very important in YAML, and without the formatting these indentations get lost. It could be, that your code has some indentation errors, we just couldn’t see it, but it could also be everything perfectly ok, and we as well can’t see it. :slight_smile:

Take a look at the explanation here:

But besides that, I don’t get what you mean. The automation you show, seems to do what it should. The device_tracker changes it’s state to something else than “0”, the automation starts, and the switch is turned on.

But I have a guess, what it could be. Not “0” isn’t automatically “1”. It can also be “unavailable” or “unknown” - everything but not “0”.

Hi Paddy0174,
I did use the three backticks, it didn’t do anything. I tried the button “preformatted text” as well. Same result. I don’t get this. In earlier posts it did work.

Anyway: I want an automation which locks the frontdoor when everybody is away (gps). “rico” wasn’t home and still I saw in the logfile that his state was changed. Sometimes the frontdoor locks while somebody is still at home. That’s the point I don’t understand.

Somebody told me I have to use “0” for counting how many persons are at home. Do you have a suggestion to get it working?