Attributes of an unavailable sensor

I have a TP-Link mesh network at home. It allows me to see who is in which room. Apparently, devices regularly disconnect, making the devices in that room unavailable.
See images.

Unavailable

If the device_tracker is unavailable, certain attributes disappear! This causes the attribute for my other sensor to become null.
See image.
Sensor Home

Sensor unav

Is it possible that if the device_tracker becomes unavailable, the attribute for my sensor won’t change?
See image.

Can anyone help me? Thanks for all the replies!

You can try something like this:

- name: Your sensor with copied stuff
  attributes:
    location: >-
      {% set the_source_location = state_attr('device_tracker.the_source_tracker', 'location') %}
      {{ this.attributes.get('location','unknown') if the_source_location is none else the_source_location }}
  • this.attributes.get('location','unknown') reads the current value of the ‘location’ attribute being evaluated, defaulting to ‘unknown’ in case the value is null/none.
  • is none tests the source attribute for null

Thanks for your reply!! Works perfectly.