From 78e53e35c2f3e60a8d4dd068dee471570a92f5df Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" <nick@koston.org> Date: Fri, 3 Jul 2020 13:33:12 -0500 Subject: [PATCH] Prevent verisure lock from looping forever and sleeping in test (#37425) --- homeassistant/components/verisure/lock.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/verisure/lock.py b/homeassistant/components/verisure/lock.py index 96e40c5c36f..28efb64c71e 100644 --- a/homeassistant/components/verisure/lock.py +++ b/homeassistant/components/verisure/lock.py @@ -126,9 +126,14 @@ class VerisureDoorlock(LockEntity): )["doorLockStateChangeTransactionId"] _LOGGER.debug("Verisure doorlock %s", state) transaction = {} + attempts = 0 while "result" not in transaction: - sleep(0.5) transaction = hub.session.get_lock_state_transaction(transaction_id) + attempts += 1 + if attempts == 30: + break + if attempts > 1: + sleep(0.5) if transaction["result"] == "OK": self._state = state self._change_timestamp = monotonic() -- GitLab