Consider this binary_sensor:
- name: alert_iphone
device_class: problem
state: >-
{% set DEVICE_TRACKER = "device_tracker.iphone" -%}
{%- if state_attr(DEVICE_TRACKER,"status") is none -%}
on
{%- elif not state_attr(DEVICE_TRACKER,"status") is match("online",ignorecase=true) -%}
on
{%- else -%}
off
{%- endif %}
availability: >-
{% set DEVICE_TRACKER = "device_tracker.iphone" -%}
{{ not states(DEVICE_TRACKER) in ["unavailable","unknown"] }}
The sensor is supposed to set dependently on some “status” attribute of some “device_tracker”.
This attribute could be:
– “online” - means OK,
– smth else - means BAD;
– or it may not exist.
Here are graphs for these 2 entities:
The current state of the “device_tracker” is
i.e. it is faulty, no “latitude/longitude” & “status” is not present.
The question is not about why the tracker became faulty.
It is about - how a binary_sensor may become “unknown”?