简体   繁体   中英

Set date and time in Hikvision camera from bash or REST?

How can I set date and time in a hikvision camera from linux command line? Or from some language, like Python, PHP, etc... I have a computer connected to cameras, and I want to change date and time in cameras without access to browser, only from terminal. Thanks

You might use the document HIKVISION ISAPI . as you know, interface depends on camera firmware version. For setting date and time for camera. you needs HTTP PUT method with URL

http:// hikvision_camera_ipaddress [: http_port ] /ISAPI/System/time .

On general, An IP camera has 3 types of time mode; NTP, manual, sync(timecorrect for HIKVISION).

It would be better for getting date and time of the camera through GET method first with the same above url. After that you will get a hint for HTTP body for setting date and time via PUT method.

For more detail you could refer the document 8.1.9

If your camera supports onvif you can use python library called python-onvif (for 2.x):

pip install onvif

or python-zeep-onvif(for 3+):

pip3 install --upgrade onvif_zeep

Python code:

from onvif import ONVIFCamera
camera_ip = "your camera ip"
camera_port = "your camera port, default is 80"
wsdl_path = "path to wsdl folder"
cam = ONVIFCamera(args.ip, 80, login, password, wsdl_path)
time_request = cam.devicemgmt.create_type('SetSystemDateAndTime')
time_request.DateTimeType = "Manual"
time_request.DaylightSavings = True
time_request.UTCDateTime.Time.Hour = 4 
time_request.UTCDateTime.Time.Minutes = 20
time_request.UTCDateTime.Time.Seconds = 0
cam.devicemgmt.SetSystemDateAndTime(time_request)

Please, check python-onvif package page and onvif operation page for more detailed info

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM