Fix incorrect initial state with SimpliSafe locks (#42039)
* Fix incorrect initial state with SimpliSafe locks * Cleanup
This commit is contained in:
parent
941453dca9
commit
91fd59aa57
1 changed files with 3 additions and 5 deletions
|
@ -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."""
|
||||
|
|
Loading…
Add table
Reference in a new issue