Skip to main content

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


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.3.0.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hikconnect-1.3.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file hikconnect-1.3.0.tar.gz.

File metadata

  • Download URL: hikconnect-1.3.0.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.14.6 Darwin/25.5.0

File hashes

Hashes for hikconnect-1.3.0.tar.gz
Algorithm Hash digest
SHA256 69a04ebd33a7f3b99af481cc0e1136d76b8c880955580b8c4051956dee232a8f
MD5 97c5b45c99b95f6d2e712d39ce2c2d96
BLAKE2b-256 114eec9113b726fe1e79ac532bf21a00cdb4e56bfe3ce9a94f36954bd7771cf7

See more details on using hashes here.

File details

Details for the file hikconnect-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: hikconnect-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.14.6 Darwin/25.5.0

File hashes

Hashes for hikconnect-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bdf070fdef0d1b083fdeea3c8f6182feb881f226bde9a45f07e4b2d7d7102e94
MD5 8c19ccd5ad4a32197ca6b80f4f8c6b29
BLAKE2b-256 1647decee7a0fc04ab5cd33f2107731012a8dd955d1bec31f7e6ad8a7a8fc945

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page