mirror of
https://github.com/home-assistant/core.git
synced 2025-08-04 05:05:09 +02:00
Fix type of value in MQTT binary sensor (#66675)
This commit is contained in:
@@ -20,6 +20,7 @@ from homeassistant.const import (
|
|||||||
CONF_PAYLOAD_OFF,
|
CONF_PAYLOAD_OFF,
|
||||||
CONF_PAYLOAD_ON,
|
CONF_PAYLOAD_ON,
|
||||||
CONF_VALUE_TEMPLATE,
|
CONF_VALUE_TEMPLATE,
|
||||||
|
STATE_ON,
|
||||||
STATE_UNAVAILABLE,
|
STATE_UNAVAILABLE,
|
||||||
STATE_UNKNOWN,
|
STATE_UNKNOWN,
|
||||||
)
|
)
|
||||||
@@ -106,7 +107,7 @@ class MqttBinarySensor(MqttEntity, BinarySensorEntity, RestoreEntity):
|
|||||||
|
|
||||||
def __init__(self, hass, config, config_entry, discovery_data):
|
def __init__(self, hass, config, config_entry, discovery_data):
|
||||||
"""Initialize the MQTT binary sensor."""
|
"""Initialize the MQTT binary sensor."""
|
||||||
self._state = None
|
self._state: bool | None = None
|
||||||
self._expiration_trigger = None
|
self._expiration_trigger = None
|
||||||
self._delay_listener = None
|
self._delay_listener = None
|
||||||
expire_after = config.get(CONF_EXPIRE_AFTER)
|
expire_after = config.get(CONF_EXPIRE_AFTER)
|
||||||
@@ -132,7 +133,7 @@ class MqttBinarySensor(MqttEntity, BinarySensorEntity, RestoreEntity):
|
|||||||
_LOGGER.debug("Skip state recovery after reload for %s", self.entity_id)
|
_LOGGER.debug("Skip state recovery after reload for %s", self.entity_id)
|
||||||
return
|
return
|
||||||
self._expired = False
|
self._expired = False
|
||||||
self._state = last_state.state
|
self._state = last_state.state == STATE_ON
|
||||||
|
|
||||||
if self._expiration_trigger:
|
if self._expiration_trigger:
|
||||||
# We might have set up a trigger already after subscribing from
|
# We might have set up a trigger already after subscribing from
|
||||||
|
Reference in New Issue
Block a user