Use shorthand attr for mqtt assumed_state (#100241)

This commit is contained in:
Jan Bouwhuis 2023-09-12 22:21:13 +02:00 committed by GitHub
parent eb0ab3de93
commit e3837cd1e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 26 additions and 78 deletions

View file

@ -159,6 +159,7 @@ class MqttLock(MqttEntity, LockEntity):
self._optimistic = (
config[CONF_OPTIMISTIC] or self._config.get(CONF_STATE_TOPIC) is None
)
self._attr_assumed_state = bool(self._optimistic)
self._compiled_pattern = config.get(CONF_CODE_FORMAT)
self._attr_code_format = (
@ -221,11 +222,6 @@ class MqttLock(MqttEntity, LockEntity):
"""(Re)Subscribe to topics."""
await subscription.async_subscribe_topics(self.hass, self._sub_state)
@property
def assumed_state(self) -> bool:
"""Return true if we do optimistic updates."""
return self._optimistic
async def async_lock(self, **kwargs: Any) -> None:
"""Lock the device.