Light automation with motion sensor and room presence help

Hi everyone,

I’ve been banging my head how to make this work.
I have in my kitchen a motion sensor, works great it’s dark, lights turn on.
I have a simple automation that if no movement, turn off the light after 30 seconds.
Obviously this doesn’t have much practical usage if you do the dishes for example and you don’t move like crazy, the light will turn off.
So I used an ESP I had for room presence, I use my phone as beacon, also works as indented.

Now my automation is the following: Turn off the light when no movement, but keep the lights on as long as I have my phone in the room.

I did create the following automation, but doesn’t work. The light will turn off no matter what after no movement is detected.
Can someone please help me out? Thank you!

alias: New Automation
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.hue_motion_sensor_1_motion
    to: "off"
    for:
      hours: 0
      minutes: 0
      seconds: 0
    from: "on"
condition:
  - condition: and
    conditions:
      - condition: state
        entity_id: device_tracker.74c052fe_8425_4fa2_95e9_926b857b02f3_tracker
        state: not_home
      - condition: state
        entity_id: binary_sensor.hue_motion_sensor_1_motion
        state: "off"
action:
  - service: light.turn_off
    data: {}
    target:
      area_id: kitchen
  - delay:
      hours: 0
      minutes: 0
      seconds: 30
      milliseconds: 0
mode: single