Please help device tracker & notice iphone who is going out or back home.config

if not sending msg to track device is working, ( just open door & someone going out or back send msg) , once i added the tracker device , it did’t notice the iphone. please help the config.

My automation :

  • alias: mama go out & send msg
    trigger:

    • platform: state
      entity_id: binary_sensor.door_window_sensor_158d000278b5f0 ( outside steel door)
      from: ‘off’
      to: ‘on’
  • condition:

    • condition: and
      conditions:
      • condition: state
        entity_id: ‘binary_sensor.door_window_sensor_159d8603e9dac9’ (inside wood door)
        state: ‘on’
        for:
        seconds: 3
      • condition: state
        entity_id: device_tracker.iphone_max
        state: ‘home’
    • action:
      • wait_template: “{{is_state(‘device_tracker.iphone_max’, ‘not_home’)}}”
      • service: notify.ios_iphone
        data:
        • title: “notice”
          message: “mama is going out.”
  • alias: Carrin back & send msg
    trigger:

    • platform: state
      entity_id: binary_sensor.window_sensor_159d8603e9dac9’ (inside wood door)
      from: ‘off’
      to: ‘on’

    condition:

    • condition: and
      • conditions:
        • condition: state
          entity_id: ‘binary_sensor.door_window_sensor_158d000278b5f0’ ( outside steel door)
          state: ‘on’
          for:
          seconds: 3
        • condition: state
          entity_id: device_tracker.iphone_max
          state: ‘not_home’

    action:

    • wait_template: “{{is_state(‘device_tracker.iphone_max’, ‘home’)}}”
    • service: notify.ios_iphone
      data:
      • title: “notice”
        message: “mama back home.”