Intialize mqtt lock in an unknown state in pessimistic mode (#100943)
Intialize mqtt lock as unknown in pessimistic mode
This commit is contained in:
parent
734c4e8e32
commit
20a2e129fb
2 changed files with 13 additions and 10 deletions
|
@ -150,7 +150,6 @@ class MqttLock(MqttEntity, LockEntity):
|
|||
discovery_data: DiscoveryInfoType | None,
|
||||
) -> None:
|
||||
"""Initialize the lock."""
|
||||
self._attr_is_locked = False
|
||||
MqttEntity.__init__(self, hass, config, config_entry, discovery_data)
|
||||
|
||||
@staticmethod
|
||||
|
@ -160,10 +159,13 @@ class MqttLock(MqttEntity, LockEntity):
|
|||
|
||||
def _setup_from_config(self, config: ConfigType) -> None:
|
||||
"""(Re)Setup the entity."""
|
||||
self._optimistic = (
|
||||
config[CONF_OPTIMISTIC] or self._config.get(CONF_STATE_TOPIC) is None
|
||||
)
|
||||
self._attr_assumed_state = bool(self._optimistic)
|
||||
if (
|
||||
optimistic := config[CONF_OPTIMISTIC]
|
||||
or config.get(CONF_STATE_TOPIC) is None
|
||||
):
|
||||
self._attr_is_locked = False
|
||||
self._optimistic = optimistic
|
||||
self._attr_assumed_state = bool(optimistic)
|
||||
|
||||
self._compiled_pattern = config.get(CONF_CODE_FORMAT)
|
||||
self._attr_code_format = (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue