Communicate with Hikvision smart doorbells via Hik-Connect cloud.
Project description
Usage
from hikconnect.api import HikConnect
async with HikConnect() as api:
await api.login("foo", "bar")
devices = [device async for device in api.get_devices()]
print(devices)
# [{
# 'id': 'DS-XXXXXX-YYYYYYYYYYYYYYYYYYYYYYYYY',
# 'name': 'DS-XXXXXX-Y(ZZZZZZZZZ)',
# 'serial': 'ZZZZZZZZZ',
# 'type': 'DS-XXXXXX-Y',
# 'version': 'V1.2.3 build 123456',
# 'locks': {1: 2, 2: 0, 3: 1}
# }]
# locks data means (guessing): <channel number>: <number of locks connected>
my_device_serial = devices[0]["serial"]
cameras = [camera async for camera in api.get_cameras(my_device_serial)]
print(cameras)
# [
# {'id': '4203fd7c5f89ce96f8ff0adfdbe8b731', 'name': 'foo', 'channel_number': 1, 'signal_status': 1, 'is_shown': 0},
# {'id': 'cd72bc923956952194468738123b7a5e', 'name': 'bar', 'channel_number': 2, 'signal_status': 1, 'is_shown': 1},
# {'id': 'd2a2057d853438d9a5b4954baec136e3', 'name': 'baz', 'channel_number': 3, 'signal_status': 0, 'is_shown': 0}
# ]
call_status = await api.get_call_status(my_device_serial)
print(call_status)
# {
# 'status': 'idle',
# 'info': {
# 'building_number': 0,
# 'floor_number': 0,
# 'zone_number': 0,
# 'unit_number': 0,
# 'device_number': 0,
# 'device_type': 0,
# 'lock_number': 0
# }
# }
# can be "idle" / "ringing" / "call in progress" - see hikconnect/api.py:45
# Unlock device
await api.unlock(my_device_serial, 1)
# Cancel call for device
await api.cancel_call(my_device_serial)
# call this periodically at least once per 30 mins!
if api.is_refresh_login_needed():
await api.refresh_login()
If you are new to async
Python, you simply need to wrap your code in a construction like this:
import asyncio
async def main():
# put the original code containing `async` keywords here
asyncio.run(main())
More info in the async
docs.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
hikconnect-1.2.1.tar.gz
(5.7 kB
view details)
Built Distribution
File details
Details for the file hikconnect-1.2.1.tar.gz
.
File metadata
- Download URL: hikconnect-1.2.1.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.12.3 Darwin/23.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2a962f69c82fdde9576e40ae3befe650feb841fc226ae668db2ab2c0bab2a683 |
|
MD5 | dddc97aab83982df7405fc8beda1b370 |
|
BLAKE2b-256 | bf8e27c23a72999ac62248e1f8f5281191081fa3e5538747e682819aff342e92 |
File details
Details for the file hikconnect-1.2.1-py3-none-any.whl
.
File metadata
- Download URL: hikconnect-1.2.1-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.12.3 Darwin/23.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 844004c6134982c78717e28264700cc17ca42534adfab6799947c2e214ea291c |
|
MD5 | 1fe52f09598986224ca7974ad23a5b38 |
|
BLAKE2b-256 | b0e51a84d0831307bf203a317faea8ebda35b058c7e2914d4910a9d21cd8e748 |