diff --git a/lib/hid/DoorController.py b/lib/hid/DoorController.py index f62395e..88a9260 100644 --- a/lib/hid/DoorController.py +++ b/lib/hid/DoorController.py @@ -135,17 +135,24 @@ class DoorController(): recordCount = 0 moreRecords = True + # note: all the "+/-1" bits are to work around a bug where the + # last returned entry is incomplete. There is probably a + # better way to do this, but for now I just get the last entry + # again in the next request. I suspect this probably ends + # poorly if the numbers line up poorly (ie an exact multiple + # of the returned record limit) while moreRecords: res = self.doXMLRequest(ROOT( req({ "action": "LR", - "recordCount": str(count - recordCount), - "recordOffset": str(recordCount), + "recordCount": str(count - recordCount + 1), + "recordOffset": str(recordCount - 1 + if recordCount > 0 else 0), **params }))) - result += list(res[0]) + result = result[:-1] + list(res[0]) - recordCount += int(res[0].get('recordCount')) + recordCount += int(res[0].get('recordCount')) - 1 moreRecords = res[0].get('moreRecords') == 'true' return result