From 91fd59aa578177529f4bf11d6a78f36169306b79 Mon Sep 17 00:00:00 2001 From: Aaron Bach Date: Sun, 18 Oct 2020 12:21:48 -0600 Subject: [PATCH] Fix incorrect initial state with SimpliSafe locks (#42039) * Fix incorrect initial state with SimpliSafe locks * Cleanup --- homeassistant/components/simplisafe/lock.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/simplisafe/lock.py b/homeassistant/components/simplisafe/lock.py index 82177fb4387..000b1cd9abb 100644 --- a/homeassistant/components/simplisafe/lock.py +++ b/homeassistant/components/simplisafe/lock.py @@ -32,8 +32,8 @@ class SimpliSafeLock(SimpliSafeEntity, LockEntity): def __init__(self, simplisafe, system, lock): """Initialize.""" super().__init__(simplisafe, system, lock.name, serial=lock.serial) - self._is_locked = False self._lock = lock + self._is_locked = None for event_type in (EVENT_LOCK_LOCKED, EVENT_LOCK_UNLOCKED): self.websocket_events_to_listen_for.append(event_type) @@ -51,8 +51,6 @@ class SimpliSafeLock(SimpliSafeEntity, LockEntity): LOGGER.error('Error while locking "%s": %s', self._lock.name, err) return - self._is_locked = True - async def async_unlock(self, **kwargs): """Unlock the lock.""" try: @@ -61,8 +59,6 @@ class SimpliSafeLock(SimpliSafeEntity, LockEntity): LOGGER.error('Error while unlocking "%s": %s', self._lock.name, err) return - self._is_locked = False - @callback def async_update_from_rest_api(self): """Update the entity with the provided REST API data.""" @@ -74,6 +70,8 @@ class SimpliSafeLock(SimpliSafeEntity, LockEntity): } ) + self._is_locked = self._lock.state == LockStates.locked + @callback def async_update_from_websocket_event(self, event): """Update the entity with the provided websocket event data."""