Giter VIP home page Giter VIP logo

hikconnect's Introduction

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()

hikconnect's People

Contributors

tomasbedrich avatar dependabot[bot] avatar mayankraichura avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.