Use attribute 'device_status' in presence tracking template?

HI,
no matter what i try, the iCloud presence tracking keeps switching on and off, triggering the automation for the same location over and over.

the location is being served as a trigger.to_state at each power safe cycle. It then is not_home, while in fact it should be unavailable, since the not_home state triggers the automation falsely.

I noticed just now, that an attribute device_status is available and it is set to ‘offline’, when offline :wink:
15

could I use that in a value_template like this, to prevent it from triggering the automation?

condition:
  - condition: template
    value_template: >
      {{ trigger.to_state.state is not none and
         trigger.from_state.state is not none and
         trigger.to_state.state != trigger.from_state.state and
         trigger.to_state.attributes.device_status != 'offline' }}
        }}
  - condition: template
    value_template: >
      {% set zones = states.zone | map(attribute='entity_id')|list %}
      {{trigger.to_state.state in ['home','not_home'] or
        trigger.zone in zones}}
  - condition: template
    value_template: >
      {{ (now() - trigger.from_state.last_changed).total_seconds() > 360 }}
  - condition: template
    value_template: >
      {{ is_state('input_boolean.notify_presence', 'on')}}
action:
  service: notify.m
  data_template:
    title: 'Presence Tracking:'
    message: >
      {% set name = trigger.to_state.attributes.friendly_name %}
      {% set to_state = trigger.to_state.state %}
      {% set from_state = trigger.from_state.state %}

      {% if to_state == 'not_home' %}
        {{ name }} left {{from_state}}
      {% elif from_state == 'not_home' %}
        {{ name }} arrived at {{to_state}}
      {% else %}
        {{ name }} left {{from_state}} and arrived at {{to_state}}
      {% endif %}

answering myself here, for reference:

The answer is yes you can, but it is useless. The attributes are completely inaccurate, and offline was there all evening even when being online all the time…Why these attributes are there in the first place…