Skip to main content

A Python client for HKC SecureComm API

Project description

HKC Alarm API Python Wrapper

Python module for interacting with HKC's Alarm API, allowing for easy interactions with the alarm system.

Note: This uses a private API, which means it is subject to change without notice and can break at any time. Always be cautious and respectful when using private APIs. To mimic the behavior of the app and reduce the chance of being rate-limited or blocked, it is recommended to limit requests to the API to one every 5-10 seconds, especially when fetching logs or inputs, similar to HKC's new v2 App.

Features

  • Retrieve system status.
  • Fetch all inputs.
  • Inspect read-only panel details, outputs, and temporary-user status.
  • View recent logs.
  • Arm and disarm the alarm in various modes.
  • Configure multiple user codes for the same panel and inspect per-user access.

Installation

  1. Clone this repository:
git clone https://github.com/jasonmadigan/pyhkc
  1. Navigate to the repository's directory:
cd pyhkc
  1. Install the required packages:
pip install -r requirements.txt

Dependencies

  • requests==2.31.0
  • tabulate==0.9.0

Example Usage

from pyhkc import HKCAlarm

# Initialize the system with your credentials.
panel_id = [your-panel-id]  # replace with your panel ID
panel_password = "[your-panel-password]"  # replace with your panel password
user_code = [your-user-code]  # replace with your user code

alarm_system = HKCAlarm(panel_id, panel_password, user_code)

# Retrieve system status.
status = alarm_system.get_system_status()
print("System Status:", status)

# Fetch all inputs.
inputs = alarm_system.get_all_inputs()
print("All Inputs:", inputs)

# View recent logs.
logs = alarm_system.fetch_logs()
print("Recent Logs:", logs)

# Arm the system.
# alarm_system.arm_fullset()

# Disarm the system.
# alarm_system.disarm()

Single-user initialization remains unchanged. If you have multiple panel users with different permissions, add their codes with user_codes and query their effective access separately:

from pyhkc import HKCAlarm

alarm_system = HKCAlarm(
    panel_id,
    panel_password,
    1111,  # default / active user code
    user_codes=[2222],
)

# Use the original methods with the active user code.
status = alarm_system.get_system_status()

# Or inspect every configured user and their access levels.
access_summary = alarm_system.get_user_access_summary()
print(access_summary[1111]["allowedBlocks"])
print(access_summary[2222]["allowedBlocks"])

# Read-only v3 helpers confirmed against the current app/API.
details = alarm_system.get_device_details()
outputs = alarm_system.get_outputs()
temporary_user = alarm_system.get_temporary_user()

# Build a Home Assistant-oriented block/entity mapping.
entity_map = alarm_system.get_home_assistant_entity_map()
for block in entity_map["blocks"]:
    print(block["description"], block["accessUserCodes"], len(block["inputs"]))

# Temporarily act as another configured user.
alarm_system.set_active_user(2222)
guest_status = alarm_system.get_system_status()

# You can also override the user per call without switching the active user.
admin_status = alarm_system.get_system_status(user_code=1111)

get_home_assistant_entity_map() is conservative:

  • it assigns an input to a block only when the set of users who can see that input matches exactly one block's accessUserCodes
  • it leaves inputs in sharedInputs when every configured user can see them
  • it leaves inputs in ambiguousInputs when the upstream API does not provide enough information to place them safely on one block

The additional read-only helpers are intended for diagnostics and integrations:

  • get_device_details() returns panel metadata such as variant, platform, installation name, and site name when the upstream API exposes them
  • get_outputs() returns the current device outputs payload, which may be empty on some panels
  • get_temporary_user() returns the current temporary-user status for the authenticated panel user

Publishing

python3 setup.py sdist bdist_wheel
twine upload dist/*

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

pyhkc-0.6.0.tar.gz (15.1 kB view details)

Uploaded Source

Built Distribution

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

pyhkc-0.6.0-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file pyhkc-0.6.0.tar.gz.

File metadata

  • Download URL: pyhkc-0.6.0.tar.gz
  • Upload date:
  • Size: 15.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyhkc-0.6.0.tar.gz
Algorithm Hash digest
SHA256 b0c009ed70d0bd24b0e0f4972eccb613dd2071e86a6134a5f81c589529a46419
MD5 f8fc511851931e1f9b63ee91d801deae
BLAKE2b-256 9459530ee11765c89d697f83ce32e7a5d171ed8564eb24bb1742b63a36c61bad

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyhkc-0.6.0.tar.gz:

Publisher: publish-to-pypi.yml on jasonmadigan/pyhkc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyhkc-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: pyhkc-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 12.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyhkc-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 39f2519b968d724fb54562ca16d1e536c30b8dbf5be0ef4fa9d92007b5724db2
MD5 7ee9ad7cac2d0488e58a28685be7bfb2
BLAKE2b-256 2dea0376a444e5c01f447c4e4e10a99c53be19c1b0686a2e5bebb2cb9ad4217f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyhkc-0.6.0-py3-none-any.whl:

Publisher: publish-to-pypi.yml on jasonmadigan/pyhkc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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