Просмотр исходного кода

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 лет назад
Родитель
Сommit
0e4f208633
1 измененных файлов с 5 добавлено и 0 удалено
  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():
             by = self.unlocker_id(dp, desc)
             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
 
     async def async_lock(self, **kwargs):