py-august icon indicating copy to clipboard operation
py-august copied to clipboard

get_lock_status() is stale when manually locking the lock

Open Frear opened this issue 3 years ago • 0 comments

The get_lock_status() api response is stale when manually locking the lock.

What's interesting is, the stale result can be updated by viewing the lock status with the August mobile app or asking Alexa, "Is the door locked?". Either of those actions cause those applications to return an accurate result, after which time my august-py powered application immediately reflects the correct result.

To repro:

  1. Make sure the lock is locked and door is closed
  2. Call
lockstatus, doorstatus = api.get_lock_status(authentication.access_token, lock.device_id, True)

            print("Lock", lock.device_name,
                  "state is:",
                  "(Lock =", str(lockstatus.value) + ")",
                  "(Door =", str(doorstatus.value) +")")
  1. Verify you see Lock = locked and Door = closed
  2. Manually unlock the lock. (You can also open the door; it does not affect reproducibility.)
  3. Call the code in step 2 again
  4. The expected result is for it to show Lock = unlocked and the door status should also be accurate.
  5. Manually lock the lock
  6. Run the code in step 2 once more. In my case, most of the time it continues to show the previous unlocked state despite now being locked. Some times this api result accurately shows the door is locked, but more often than not the issue is reproduced and inaccurately says Lock = unlocked, and the door status will be stale as well.
  7. If the issue has been reproduced at step 8, you can resolve it by querying the lock status using another technology such as the mobile app or asking Alexa to state the lock status, and you can resolve it by changing the lock status with py-august.
  8. This issue is fixed if we can find a way to use august-py to again show an accurate lock status without changing the state of the lock

Things I've tried:

I believe when this problem presents itself, the August service has a stale status saved at their service. Something needs to happen to cause August to update their record of the status.

Change the lock status:

I've tried calling the apis lock(), unlock(), lock_return_activities(), and unlock_return_activities() after detecting a change in lock status. These calls all cause get_lock_status() to start returning the correct status. However, they also cause the lock to become locked or unlocked. When this happens, the previous lock state can't be known for sure due to this bug so this is not a solution.

Query the lock status:

I've also tried doing various reads of the lock state, the house, etc, to see if I can get get_lock_status() to update and return a correct result. I've tried get_lock_detail(), wakeup_doorbell(), etc. I've also used sleep() to make sure I'm waiting long enough between querying using august-py, reproducing the issue, and trying to resolve the issue using august-py.

Once the problem occurs due to manually locking, I have not been able to find a call or combination of calls I can make from the py-august toolkit that allows me to query the accurate lock status.

Frear avatar Oct 15 '21 06:10 Frear