Set mqtt binary_sensor unavailable if expire_after specified (#34259)
* Set self._expired=True if expire_after specified * Added test_expiration_on_discovery_and_discovery_update_of_binary_sensor to mqtt/test_binary_sensor.py * Fixed flake8 error * Fixed isort error
This commit is contained in:
parent
a8cd7203df
commit
d6ab36bf8e
3 changed files with 98 additions and 6 deletions
|
@ -119,7 +119,11 @@ class MqttBinarySensor(
|
|||
self._sub_state = None
|
||||
self._expiration_trigger = None
|
||||
self._delay_listener = None
|
||||
self._expired = None
|
||||
expire_after = config.get(CONF_EXPIRE_AFTER)
|
||||
if expire_after is not None and expire_after > 0:
|
||||
self._expired = True
|
||||
else:
|
||||
self._expired = None
|
||||
device_config = config.get(CONF_DEVICE)
|
||||
|
||||
MqttAttributes.__init__(self, config)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue