diff --git a/hid/DoorController.py b/hid/DoorController.py index cae8962..95c5839 100644 --- a/hid/DoorController.py +++ b/hid/DoorController.py @@ -6,6 +6,8 @@ import requests E_plain = ElementMaker(nsmap={"hid": "http://www.hidglobal.com/VertX"}) E = ElementMaker(namespace="http://www.hidglobal.com/VertX", nsmap={"hid": "http://www.hidglobal.com/VertX"}) +ROOT = E_plain.VertXMessage + class DoorController(): def __init__(self, ip, username, password, name="", access=""): @@ -64,7 +66,7 @@ class DoorController(): self.doCSVImport(outString) # clear all schedules - delXML = E_plain.VertXMessage( + delXML = ROOT( *[E.Schedules({"action": "DD", "scheduleID": str(ii)}) for ii in range(1, 8)]) self.doXMLRequest(delXML) @@ -77,7 +79,7 @@ class DoorController(): # TODO: add delete formats # delete example: - el = E_plain.VertXMessage( + el = ROOT( E.CardFormats({"action": "AD"}, E.CardFormat({"formatName": formatName, "templateID": str(templateID)}, @@ -85,13 +87,13 @@ class DoorController(): return self.doXMLRequest(el) def lockOrUnlockDoor(self, lock=True): - el = E_plain.VertXMessage( + el = ROOT( E.Doors({"action": "CM", "command": "lockDoor" if lock else "unlockDoor"})) return self.doXMLRequest(el) def getStatus(self): - el = E_plain.VertXMessage( + el = ROOT( E.Doors({"action": "LR", "responseFormat": "status"})) xml = self.doXMLRequest(el) relayState = xml.find('./{*}Doors/{*}Door').attrib['relayState']