|
11 | 11 | import datetime |
12 | 12 | import xml.etree.ElementTree as ET |
13 | 13 | from zeep.plugins import HistoryPlugin |
14 | | -from onvif import ONVIFClient |
| 14 | +from onvif import ONVIFClient, CacheMode |
15 | 15 |
|
16 | | -HOST = "192.168.1.6" |
17 | | -PORT = 8000 |
| 16 | +HOST = "192.168.1.3" |
| 17 | +PORT = 80 |
18 | 18 | USERNAME = "admin" |
19 | 19 | PASSWORD = "admin123" |
20 | 20 |
|
21 | | -client = ONVIFClient(HOST, PORT, USERNAME, PASSWORD) |
| 21 | +client = ONVIFClient(HOST, PORT, USERNAME, PASSWORD, cache=CacheMode.NONE) |
22 | 22 |
|
23 | 23 | # 1. Create PullPoint Subscription from Events service |
24 | 24 | subscription = client.events().CreatePullPointSubscription() |
|
80 | 80 | print("⚠️ HistoryPlugin topic parse error:", e) |
81 | 81 |
|
82 | 82 | # Extract Message (XML element) |
| 83 | + # After the patch, _value_1 is directly a list of Elements (not a dict) |
83 | 84 | msg_elem = None |
84 | | - if isinstance(n.Message, dict) and "_value_1" in n.Message: |
85 | | - msg_elem = n.Message["_value_1"] |
86 | | - elif hasattr(n.Message, "_value_1"): |
87 | | - msg_elem = n.Message._value_1 |
| 85 | + if hasattr(n.Message, "_value_1") and n.Message._value_1: |
| 86 | + # _value_1 is now a list of Elements, take the first one |
| 87 | + if isinstance(n.Message._value_1, list) and len(n.Message._value_1) > 0: |
| 88 | + msg_elem = n.Message._value_1[0] |
| 89 | + else: |
| 90 | + msg_elem = n.Message._value_1 |
88 | 91 |
|
89 | 92 | if msg_elem is not None: |
90 | 93 | # Extract timestamp from UtcTime attribute |
|
0 commit comments