You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Explore more advanced usage and service-specific operations in the [`examples/`](./examples/) folder.
152
152
153
+
## Helper Methods
154
+
155
+
Every ONVIF service provides three essential helper methods to improve the development experience and make working with ONVIF operations more intuitive:
156
+
157
+
**1. `type(type_name)`**
158
+
159
+
Creates and returns an instance of the specified ONVIF type for building complex request parameters (applied at [`>=v0.1.9`](https://github.com/nirsimetri/onvif-python/releases/tag/v0.1.9)).
160
+
161
+
**Usage:**
162
+
```python
163
+
device = client.devicemgmt()
164
+
165
+
# Create a new user object
166
+
new_user = device.type('CreateUsers')
167
+
new_user.User.append({
168
+
"Username": 'new_user',
169
+
"Password": 'new_password',
170
+
"UserLevel": 'User'
171
+
})
172
+
device.CreateUsers(new_user)
173
+
174
+
# Set hostname
175
+
hostname = device.type('SetHostname')
176
+
hostname.Name ='NewHostname'
177
+
device.SetHostname(hostname)
178
+
179
+
# Configure system time
180
+
time_params = device.type('SetSystemDateAndTime')
181
+
time_params.DateTimeType ='NTP'
182
+
time_params.DaylightSavings =True
183
+
time_params.TimeZone.TZ='UTC+02:00'
184
+
now = datetime.now()
185
+
time_params.UTCDateTime.Date.Year = now.year
186
+
time_params.UTCDateTime.Date.Month = now.month
187
+
time_params.UTCDateTime.Date.Day = now.day
188
+
time_params.UTCDateTime.Time.Hour = now.hour
189
+
time_params.UTCDateTime.Time.Minute = now.minute
190
+
time_params.UTCDateTime.Time.Second = now.second
191
+
device.SetSystemDateAndTime(time_params)
192
+
```
193
+
194
+
**2. `operations()`**
195
+
196
+
Lists all available operations for the current service (applied at [`>=v0.2.0`](https://github.com/nirsimetri/onvif-python/releases/tag/v0.2.0)).
197
+
198
+
**Returns:**
199
+
- List of operation names that can be called on the service
200
+
201
+
**Usage:**
202
+
```python
203
+
device = client.devicemgmt()
204
+
media = client.media()
205
+
ptz = client.ptz()
206
+
207
+
# List all available operations for each service
208
+
print("Device Management Operations:")
209
+
for op in device.operations():
210
+
print(f" - {op}")
211
+
212
+
print("\nMedia Operations:")
213
+
for op in media.operations():
214
+
print(f" - {op}")
215
+
216
+
print("\nPTZ Operations:")
217
+
for op in ptz.operations():
218
+
print(f" - {op}")
219
+
220
+
# Check if specific operation is supported
221
+
if'ContinuousMove'in ptz.operations():
222
+
print("PTZ continuous movement is supported")
223
+
```
224
+
225
+
**3. `desc(method_name)`**
226
+
227
+
Provides comprehensive documentation and parameter information for any ONVIF operation (applied at [`>=v0.2.0`](https://github.com/nirsimetri/onvif-python/releases/tag/v0.2.0)).
> These helper methods are available on **all** ONVIF services (`devicemgmt()`, `media()`, `ptz()`, `events()`, `imaging()`, `analytics()`, etc.) and provide a consistent API for exploring and using ONVIF capabilities across different device types and manufacturers.
255
+
153
256
> [!IMPORTANT]
154
257
> If you're new to ONVIF and want to learn more, we highly recommend taking the official free online course provided by ONVIF at [Introduction to ONVIF Course](https://www.onvif.org/about/introduction-to-onvif-course). Please note that we are not endorsed or sponsored by ONVIF, see [Legal Notice](#legal-notice) for details.
155
258
@@ -206,12 +309,11 @@ This library includes a powerful command-line interface (CLI) for interacting wi
@@ -398,7 +509,7 @@ This feature is particularly useful for:
398
509
399
510
**2. Device Discovery (WS-Discovery)**
400
511
401
-
The CLI includes automatic ONVIF device discovery using the WS-Discovery protocol. This feature allows you to find all ONVIF-compliant devices on your local network without knowing their IP addresses beforehand.
512
+
The CLI includes automatic ONVIF device discovery using the WS-Discovery protocol. This feature allows you to find all ONVIF-compliant devices on your local network without knowing their IP addresses beforehand (applied at [`>=v0.1.2`](https://github.com/nirsimetri/onvif-python/releases/tag/v0.1.2)).
The CLI includes a built-in database of ONVIF-compatible products that can be searched to help identify and research devices before connecting (applied at [`>=v0.2.0`](https://github.com/nirsimetri/onvif-python/releases/tag/v0.2.0)).
603
+
604
+
**Basic Search:**
605
+
```bash
606
+
# Search by model name
607
+
onvif --search "C210"
608
+
onvif -s "axis camera"
609
+
610
+
# Search by manufacturer
611
+
onvif --search "hikvision"
612
+
onvif -s "dahua"
613
+
614
+
# Search by any keyword
615
+
onvif --search "ptz"
616
+
onvif -s "thermal"
617
+
```
618
+
619
+
**Paginated Results:**
620
+
```bash
621
+
# Navigate through multiple pages of results
622
+
onvif --search "hikvision" --page 2 --per-page 5
623
+
onvif -s "axis" --page 1 --per-page 10
624
+
625
+
# Adjust results per page (1-100)
626
+
onvif --search "camera" --per-page 20
627
+
```
628
+
629
+
**Search Database Information:**
630
+
631
+
The product database contains comprehensive information about tested ONVIF devices:
632
+
633
+
| Field | Description |
634
+
|-------|-------------|
635
+
|**ID**| Unique product identifier |
636
+
|**Test Date**| When the device was last tested/verified |
All `ONVIFClient` parameters (like `--timeout`, `--https`, `--cache`, etc.) are available as command-line arguments. Use `onvif --help` to see all available options.
0 commit comments