doorUpdater: Use ROOT for VertXMessage tag for clarity
This commit is contained in:
parent
9d376a87b1
commit
a84ef646f1
@ -6,6 +6,8 @@ import requests
|
|||||||
E_plain = ElementMaker(nsmap={"hid": "http://www.hidglobal.com/VertX"})
|
E_plain = ElementMaker(nsmap={"hid": "http://www.hidglobal.com/VertX"})
|
||||||
E = ElementMaker(namespace="http://www.hidglobal.com/VertX",
|
E = ElementMaker(namespace="http://www.hidglobal.com/VertX",
|
||||||
nsmap={"hid": "http://www.hidglobal.com/VertX"})
|
nsmap={"hid": "http://www.hidglobal.com/VertX"})
|
||||||
|
ROOT = E_plain.VertXMessage
|
||||||
|
|
||||||
|
|
||||||
class DoorController():
|
class DoorController():
|
||||||
def __init__(self, ip, username, password, name="", access=""):
|
def __init__(self, ip, username, password, name="", access=""):
|
||||||
@ -64,7 +66,7 @@ class DoorController():
|
|||||||
self.doCSVImport(outString)
|
self.doCSVImport(outString)
|
||||||
|
|
||||||
# clear all schedules
|
# clear all schedules
|
||||||
delXML = E_plain.VertXMessage(
|
delXML = ROOT(
|
||||||
*[E.Schedules({"action": "DD", "scheduleID": str(ii)})
|
*[E.Schedules({"action": "DD", "scheduleID": str(ii)})
|
||||||
for ii in range(1, 8)])
|
for ii in range(1, 8)])
|
||||||
self.doXMLRequest(delXML)
|
self.doXMLRequest(delXML)
|
||||||
@ -77,7 +79,7 @@ class DoorController():
|
|||||||
# TODO: add delete formats
|
# TODO: add delete formats
|
||||||
# delete example: <hid:CardFormats action="DD" formatID="7-1-244"/>
|
# delete example: <hid:CardFormats action="DD" formatID="7-1-244"/>
|
||||||
|
|
||||||
el = E_plain.VertXMessage(
|
el = ROOT(
|
||||||
E.CardFormats({"action": "AD"},
|
E.CardFormats({"action": "AD"},
|
||||||
E.CardFormat({"formatName": formatName,
|
E.CardFormat({"formatName": formatName,
|
||||||
"templateID": str(templateID)},
|
"templateID": str(templateID)},
|
||||||
@ -85,13 +87,13 @@ class DoorController():
|
|||||||
return self.doXMLRequest(el)
|
return self.doXMLRequest(el)
|
||||||
|
|
||||||
def lockOrUnlockDoor(self, lock=True):
|
def lockOrUnlockDoor(self, lock=True):
|
||||||
el = E_plain.VertXMessage(
|
el = ROOT(
|
||||||
E.Doors({"action": "CM",
|
E.Doors({"action": "CM",
|
||||||
"command": "lockDoor" if lock else "unlockDoor"}))
|
"command": "lockDoor" if lock else "unlockDoor"}))
|
||||||
return self.doXMLRequest(el)
|
return self.doXMLRequest(el)
|
||||||
|
|
||||||
def getStatus(self):
|
def getStatus(self):
|
||||||
el = E_plain.VertXMessage(
|
el = ROOT(
|
||||||
E.Doors({"action": "LR", "responseFormat": "status"}))
|
E.Doors({"action": "LR", "responseFormat": "status"}))
|
||||||
xml = self.doXMLRequest(el)
|
xml = self.doXMLRequest(el)
|
||||||
relayState = xml.find('./{*}Doors/{*}Door').attrib['relayState']
|
relayState = xml.find('./{*}Doors/{*}Door').attrib['relayState']
|
||||||
|
Reference in New Issue
Block a user