Ver código fonte

Lock: clear non-persistent unlock credential dps on reporting.

When the last credential is kept until the next full poll, if the user
unlocks twice in quick succession, the second attempt is not reported.
This can also happen with a different credential if a lower priority
unlock method is used

Clearing immediately after reporting may mean it disappears from the
attributes too quickly to notice in the UI, but the logbook will be more
accurate.

Issue #796
Jason Rumney 2 anos atrás
pai
commit
0e4f208633
1 arquivos alterados com 5 adições e 0 exclusões
  1. 5 0
      custom_components/tuya_local/lock.py

+ 5 - 0
custom_components/tuya_local/lock.py

@@ -106,6 +106,11 @@ class TuyaLocalLock(TuyaLocalEntity, LockEntity):
         }.items():
         }.items():
             by = self.unlocker_id(dp, desc)
             by = self.unlocker_id(dp, desc)
             if by:
             if by:
+                # clear non-persistent dps immediately on reporting, instead
+                # of waiting for the next poll, to make the lock more responsive
+                # to multiple attempts
+                if not dp.persist:
+                    self._device._cached_state.pop(dp.id, None)
                 return by
                 return by
 
 
     async def async_lock(self, **kwargs):
     async def async_lock(self, **kwargs):