ESPhome BLE tracking - Help needed

I am currently using BLE tracking via ESPhome to run some automations. However, my iPhone goes regularly to sleep mode and Tracker Status moves to ‘Away’. I have a condition set using NMAP in the automation for validation (My current YAML code for automation copied below

Is there anyway I could change this YAML code to operate in a way, wherein IF my BLE device is last dected in LIVINGROOM before gong to sleep/idle, my device tracker would continue to record my device tracker as LIVINGROOM until the device is detected in a different location like BEDROOM.

In short, I want my BLE tracker to continuously record me to be in Last Known Location, until I am detected in a different location; instead of changing status to Away when my iphone BLE signal goes to sleep/idle

alias: Update BLE Tracker
description: “”
triggers:

  • entity_id:
    • sensor.iphone
      trigger: state
      conditions:
  • condition: template
    value_template: “{{ trigger.from_state.state != trigger.to_state.state }}”
    enabled: true
  • condition: and
    conditions:
    • condition: state
      entity_id: person.me
      state: home
      actions:
  • data:
    dev_id: iphone
    location_name: |
    {% if trigger.to_state.state in [‘livingroom’] %}
    Living Room
    {% elif trigger.to_state.state in [‘bedroom’] %}
    Bedroom
    {% endif %}
    action: device_tracker.see
    mode: single

any ideas anyone? :frowning: