Automation doesn't seem to work

What will go wrong in the next automation?

I want the children to stay out of my office when I am not present. With the Google-say service I want to tell them that too and that works. Only when I am at home but that I don’t need.I use the automation tool to create the automation.
The motion sensor is the trigger (from off to on).
The condition is the condition of the phone. It may not be ‘home’.
However, the state of the phone is ‘home’ and yet the automation works.

- id: '1591716447335'
  alias: Niet in het kantoor
  - platform: state
    entity_id: binary_sensor.kantoor
    to: 'on'
    from: 'off'
  - condition: not
    - condition: state
      entity_id: device_tracker.iphone
      state: home
  - data:
      entity_id: media_player.slaapkamer
      message: Wat moet je hier in het kantoor?
    service: tts.google_translate_say
  mode: single

Are you firing this using the execute button? If so you are only executing the action, the conditions are only evaluated when the actual trigger defined in your automation triggers it.

No, I’m not. It really is the automation itself. Every time I enter the office with my phone.

If you have the log level set to “info”, then you should see something like this:

2020-10-09 10:55:32 INFO (MainThread) [homeassistant.components.script.fix_fr_scene] fix_fr_scene: Running script sequence
2020-10-09 10:55:32 INFO (MainThread) [homeassistant.components.script.fix_fr_scene] fix_fr_scene: Test condition and: False
2020-10-09 10:55:32 INFO (MainThread) [homeassistant.components.script.fix_kit_scene] fix_kit_scene: Running script sequence
2020-10-09 10:55:32 INFO (MainThread) [homeassistant.components.script.fix_kit_scene] fix_kit_scene: Test condition and: False
2020-10-09 10:55:32 INFO (MainThread) [homeassistant.components.script.fix_mbr_scene] fix_mbr_scene: Running script sequence
2020-10-09 10:55:32 INFO (MainThread) [homeassistant.components.script.fix_mbr_scene] fix_mbr_scene: Test condition and: False

See what that tells you about whether it sees and evaluates the condition. I also find it helpful to use persistent_notification.create as the first action to show what a condition or trigger state really is when an automation is triggered. In this case, you could display device_tracker.iphone in the message:

    - data:
        message: "{{ states('device_tracker.iphone') }}"
      service: persistent_notification.create

I also see that the example in the docs has “home” quoted, but I don’t think that would matter:

The thing is: Everything looks okay. Because I thought it might be the issue I even added the quotes myself in the automation.yaml but even that did not help. By the way: The fact that there are no quotes around “home” when you enter it using the automation template might be a bug.
But still my automation doesn’t work the way I want it to work. I still hope it’s something minor I oversee. Otherwise I might have to take this automation to Node-red. There I have something similar working.

try to make it a regular condition and not the “not” kind just to make sure there’s nothing buggy going on:

  - condition: state
    entity_id: device_tracker.iphone
    state: not_home

You haven’t mentioned specifically whether you see log messages related to it evaluating the condition. Weird stuff like this happens when you reload automations and it fails because there’s an error somewhere, so that can act as a sanity check. Or adding a message to show the state, as I mentioned above.

What I have done?
I threw away the automation. Then I restarted Hassio and rebuilt the automation in exactly the same way. Now it works. Apparently during the building process sometimes a bit keeps pointing in the wrong direction.
Thanks for the suggestions and help.