Skip to content

Commit fc7b92b

Browse files
authored
Ignore unavailable and unknown states (pnbruckner#31)
Some device trackers (especially the newer entity-based variety, like Life360 just became in 2022.7) and binary sensors can temporarily have unavailable or unknown states. If this is true on two consecutive updates for an entity the composite tracker will stop listening to it. This change causes the composite tracker to ignore unavailable and unknown states of the input entities, similar to what the Person integration does.
1 parent 3e9cc0d commit fc7b92b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

custom_components/composite/device_tracker.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
STATE_HOME,
3131
STATE_NOT_HOME,
3232
STATE_ON,
33+
STATE_UNAVAILABLE,
3334
STATE_UNKNOWN,
3435
)
3536
import homeassistant.helpers.config_validation as cv
@@ -172,7 +173,7 @@ def _dt_attr_from_utc(self, utc, tzone):
172173
return utc
173174

174175
def _update_info(self, entity_id, old_state, new_state):
175-
if new_state is None:
176+
if new_state is None or new_state.state in (STATE_UNKNOWN, STATE_UNAVAILABLE):
176177
return
177178

178179
with self._lock:

0 commit comments

Comments
 (0)