diff --git a/events.py b/events.py index 603c031..1179b53 100755 --- a/events.py +++ b/events.py @@ -49,19 +49,22 @@ eventStrings = { # -XML = ET.Element("VertXMessage") -ET.SubElement(XML, "hid:EventMessages", attrib={"action": "LR"}) -xml = doXMLRequest(TARGET_IP, ET.tostring(XML)) -print(xml[0].attrib) +# get parameters for messages to get? +# honestly not really sure why this is required, their API is confusing +parXMLIn = ET.Element("VertXMessage") +ET.SubElement(parXMLIn, "hid:EventMessages", attrib={"action": "LR"}) +parXMLOut = doXMLRequest(TARGET_IP, ET.tostring(parXMLIn)) -XML = ET.Element("VertXMessage") -ET.SubElement(XML, "hid:EventMessages", +# get the actual messages +eventsXMLIn = ET.Element("VertXMessage") +ET.SubElement(eventsXMLIn, "hid:EventMessages", attrib={"action": "LR", "recordCount": "1000", - "historyRecordMarker": xml[0].attrib["historyRecordMarker"], - "historyTimestamp": xml[0].attrib["historyTimestamp"]}) -xml = doXMLRequest(TARGET_IP, ET.tostring(XML)) -for event in xml[0]: + "historyRecordMarker": parXMLOut[0].attrib["historyRecordMarker"], + "historyTimestamp": parXMLOut[0].attrib["historyTimestamp"]}) +eventsXMLOut = doXMLRequest(TARGET_IP, ET.tostring(eventsXMLIn)) + +for event in eventsXMLOut[0]: ET.dump(event) att = event.attrib eventType = int(att["eventType"])