Skip to content

Commit 100dea1

Browse files
committed
Bump version 0.1.9 → 0.2.0
1 parent 9e41613 commit 100dea1

File tree

5 files changed

+377
-39
lines changed

5 files changed

+377
-39
lines changed

README.md

Lines changed: 189 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
[![Codacy grade](https://img.shields.io/codacy/grade/bff08a94e4d447b690cea49c6594826d?label=Code%20Quality&logo=codacy)](https://app.codacy.com/gh/nirsimetri/onvif-python/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
66
[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/nirsimetri/onvif-python)
7-
[![PyPI](https://img.shields.io/badge/PyPI-0.1.9-orange?logo=archive)](https://pypi.org/project/onvif-python/)
7+
[![PyPI](https://img.shields.io/badge/PyPI-0.2.0-orange?logo=archive)](https://pypi.org/project/onvif-python/)
88
[![Downloads](https://img.shields.io/pypi/dm/onvif-python?label=Downloads&color=red)](https://clickpy.clickhouse.com/dashboard/onvif-python)
99
<br>
1010
[![Build](https://github.com/nirsimetri/onvif-python/actions/workflows/python-app.yml/badge.svg?branch=main)](https://github.com/nirsimetri/onvif-python/actions/workflows/python-app.yml)
@@ -150,6 +150,109 @@ print(stream)
150150

151151
Explore more advanced usage and service-specific operations in the [`examples/`](./examples/) folder.
152152

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)).
228+
229+
**Returns:**
230+
- `doc`: Method documentation from WSDL
231+
- `required`: List of required parameter names
232+
- `optional`: List of optional parameter names
233+
- `method_name`: The method name
234+
- `service_name`: The service name
235+
236+
**Usage:**
237+
```python
238+
device = client.devicemgmt()
239+
240+
# Get detailed information about a method
241+
info = device.desc('GetDeviceInformation')
242+
print(info['doc'])
243+
print("Required params:", info['required'])
244+
print("Optional params:", info['optional'])
245+
246+
# Explore available methods first
247+
methods = device.operations()
248+
for method in methods[:5]: # Show first 5 methods
249+
info = device.desc(method)
250+
print(f"{method}: {len(info['required'])} required, {len(info['optional'])} optional")
251+
```
252+
253+
> [!TIP]
254+
> 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+
153256
> [!IMPORTANT]
154257
> 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.
155258
@@ -206,12 +309,11 @@ This library includes a powerful command-line interface (CLI) for interacting wi
206309
<summary><b>1. Direct CLI</b></summary>
207310

208311
```bash
209-
usage: onvif [-h] [--host HOST] [--port PORT] [--username USERNAME] [--password PASSWORD] [--discover] [--search SEARCH] [--timeout TIMEOUT] [--https]
210-
[--no-verify] [--no-patch] [--interactive] [--debug] [--wsdl WSDL] [--cache {all,db,mem,none}]
211-
[--health-check-interval HEALTH_CHECK_INTERVAL] [--version]
312+
usage: onvif [-h] [--host HOST] [--port PORT] [--username USERNAME] [--password PASSWORD] [--discover] [--filter FILTER] [--search SEARCH] [--page PAGE] [--per-page PER_PAGE] [--timeout TIMEOUT] [--https]
313+
[--no-verify] [--no-patch] [--interactive] [--debug] [--wsdl WSDL] [--cache {all,db,mem,none}] [--health-check-interval HEALTH_CHECK_INTERVAL] [--version]
212314
[service] [method] [params ...]
213315

214-
ONVIF Terminal Client — v0.1.9
316+
ONVIF Terminal Client — v0.2.0
215317
https://github.com/nirsimetri/onvif-python
216318

217319
positional arguments:
@@ -228,8 +330,12 @@ options:
228330
--password PASSWORD, -p PASSWORD
229331
Password for authentication
230332
--discover, -d Discover ONVIF devices on the network using WS-Discovery
231-
--search SEARCH, -s SEARCH
333+
--filter FILTER, -f FILTER
232334
Filter discovered devices by types or scopes (case-insensitive substring match)
335+
--search SEARCH, -s SEARCH
336+
Search ONVIF products database by model or company (e.g., 'c210', 'hikvision')
337+
--page PAGE Page number for search results (default: 1)
338+
--per-page PER_PAGE Number of results per page (default: 20)
233339
--timeout TIMEOUT Connection timeout in seconds (default: 10)
234340
--https Use HTTPS instead of HTTP
235341
--no-verify Disable SSL certificate verification
@@ -244,15 +350,20 @@ options:
244350
--version, -v Show ONVIF CLI version and exit
245351

246352
Examples:
353+
# Product search
354+
onvif --search c210
355+
onvif -s "axis camera"
356+
onvif --search hikvision --page 2 --per-page 5
357+
247358
# Discover ONVIF devices on network
248359
onvif --discover --username admin --password admin123 --interactive
249360
onvif media GetProfiles --discover --username admin
250361
onvif -d -i
251362

252363
# Discover with filtering
253-
onvif --discover --search ptz --interactive
254-
onvif -d -s "C210" -i
255-
onvif -d -s "audio_encoder" -u admin -p admin123 -i
364+
onvif --discover --filter ptz --interactive
365+
onvif -d -f "C210" -i
366+
onvif -d -f "audio_encoder" -u admin -p admin123 -i
256367

257368
# Direct command execution
258369
onvif devicemgmt GetCapabilities Category=All --host 192.168.1.17 --port 8000 --username admin --password admin123
@@ -275,7 +386,7 @@ Examples:
275386
<summary><b>2. Interactive Shell</b></summary>
276387

277388
```bash
278-
ONVIF Interactive Shell — v0.1.9
389+
ONVIF Interactive Shell — v0.2.0
279390
https://github.com/nirsimetri/onvif-python
280391

281392
Basic Commands:
@@ -398,7 +509,7 @@ This feature is particularly useful for:
398509

399510
**2. Device Discovery (WS-Discovery)**
400511

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)).
402513

403514
**Discover and Connect Interactively:**
404515
```bash
@@ -409,8 +520,8 @@ onvif --discover --username admin --password admin123 --interactive
409520
onvif -d -u admin -p admin123 -i
410521

411522
# Discover with search filter
412-
onvif --discover --search "C210" --interactive
413-
onvif -d -s ptz -u admin -p admin123 -i
523+
onvif --discover --filter "C210" --interactive
524+
onvif -d -f ptz -u admin -p admin123 -i
414525

415526
# Discover and interactive (will prompt for credentials)
416527
onvif -d -i
@@ -445,15 +556,15 @@ Timeout: 4s
445556
Found 2 ONVIF device(s):
446557
447558
[1] 192.168.1.14:2020
448-
[id] uuid:3fa1fe68-b915-4053-a3e1-a8294833fe3c
449-
[xaddrs] http://192.168.1.14:2020/onvif/device_service
450-
[types] tdn:NetworkVideoTransmitter
559+
[id] 3fa1fe68-b915-4053-a3e1-a8294833fe3c
560+
[xaddrs] [http://192.168.1.14:2020/onvif/device_service]
561+
[types] [tdn:NetworkVideoTransmitter]
451562
[scopes] [name/C210] [hardware/C210] [Profile/Streaming] [location/Hong Kong]
452563
453564
[2] 192.168.1.17:8000
454-
[id] urn:uuid:7d04ff31-61e6-11f0-a00c-6056eef47207
455-
[xaddrs] http://192.168.1.17:8000/onvif/device_service
456-
[types] dn:NetworkVideoTransmitter tds:Device
565+
[id] 7d04ff31-61e6-11f0-a00c-6056eef47207
566+
[xaddrs] [http://192.168.1.17:8000/onvif/device_service]
567+
[types] [dn:NetworkVideoTransmitter] [tds:Device]
457568
[scopes] [type/NetworkVideoTransmitter] [location/unknown] [name/IPC_123465959]
458569
459570
Select device number 1-2 or q to quit: 1
@@ -486,6 +597,65 @@ onvif devicemgmt GetCapabilities Category=All -H 192.168.1.17 -P 8000 -u admin -
486597
onvif ptz ContinuousMove ProfileToken=Profile_1 Velocity='{"PanTilt": {"x": 0.1}}' -H 192.168.1.17 -P 8000 -u admin -p admin123
487598
```
488599

600+
**4. ONVIF Product Search**
601+
602+
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 |
637+
| **Model** | Device model name and number |
638+
| **Firmware** | Tested firmware version |
639+
| **Profiles** | Supported ONVIF profiles (S, G, T, C, A, etc.) |
640+
| **Category** | Device type (Camera, NVR, etc.) |
641+
| **Type** | Specific device classification |
642+
| **Company** | Manufacturer name |
643+
644+
**Example Output:**
645+
```
646+
Found 15 product(s) matching: hikvision
647+
Showing 1-10 of 15 results
648+
649+
ID | Test Date | Model | Firmware | Profiles | Category | Type | Company
650+
----|---------------------|-------------------|----------|----------|----------|---------|---------
651+
342 | 2024-08-15 17:53:12 | DS-2CD2143G2-IU | V5.7.3 | S,G,T | Camera | device | Hikvision
652+
341 | 2024-08-14 14:22:05 | DS-2DE2A404IW-DE3 | V5.6.15 | S,G,T | Camera | device | Hikvision
653+
...
654+
655+
Page 1 of 2
656+
Navigation: Next: --page 2
657+
```
658+
489659
### CLI Parameters
490660

491661
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

Comments
 (0)