Set MQTT sensor to state unavailable when value expires (#36609)
This commit is contained in:
1 parent
fb420d5952
commit
fb3049d6a2
3 files changed
+63
-8
No files matched your search
@@ -181,7 +181,7 @@ class MqttBinarySensor(
|
||||
expiration_at = dt_util.utcnow() + timedelta(seconds=expire_after)
|
||||
|
||||
self._expiration_trigger = async_track_point_in_utc_time(
|
||||
self.hass, self.value_is_expired, expiration_at
|
||||
self.hass, self._value_is_expired, expiration_at
|
||||
)
|
||||
|
||||
value_template = self._config.get(CONF_VALUE_TEMPLATE)
|
||||
@@ -250,7 +250,7 @@ class MqttBinarySensor(
|
||||
await MqttDiscoveryUpdate.async_will_remove_from_hass(self)
|
||||
|
||||
@callback
|
||||
def value_is_expired(self, *_):
|
||||
def _value_is_expired(self, *_):
|
||||
"""Triggered when value is expired."""
|
||||
|
||||
self._expiration_trigger = None
|
||||
|
||||
Reference in new issue
Block a user