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
- Clone this repository:
git clone https://github.com/jasonmadigan/pyhkc
- Navigate to the repository's directory:
cd pyhkc
- Install the required packages:
pip install -r requirements.txt
Dependencies
requests==2.31.0tabulate==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
sharedInputswhen every configured user can see them - it leaves inputs in
ambiguousInputswhen 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 themget_outputs()returns the current device outputs payload, which may be empty on some panelsget_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
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b0c009ed70d0bd24b0e0f4972eccb613dd2071e86a6134a5f81c589529a46419
|
|
| MD5 |
f8fc511851931e1f9b63ee91d801deae
|
|
| BLAKE2b-256 |
9459530ee11765c89d697f83ce32e7a5d171ed8564eb24bb1742b63a36c61bad
|
Provenance
The following attestation bundles were made for pyhkc-0.6.0.tar.gz:
Publisher:
publish-to-pypi.yml on jasonmadigan/pyhkc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyhkc-0.6.0.tar.gz -
Subject digest:
b0c009ed70d0bd24b0e0f4972eccb613dd2071e86a6134a5f81c589529a46419 - Sigstore transparency entry: 1236240737
- Sigstore integration time:
-
Permalink:
jasonmadigan/pyhkc@b96b17fd5a031cad77f9f1047858fc6d48ceb646 -
Branch / Tag:
refs/tags/0.6.0 - Owner: https://github.com/jasonmadigan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@b96b17fd5a031cad77f9f1047858fc6d48ceb646 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39f2519b968d724fb54562ca16d1e536c30b8dbf5be0ef4fa9d92007b5724db2
|
|
| MD5 |
7ee9ad7cac2d0488e58a28685be7bfb2
|
|
| BLAKE2b-256 |
2dea0376a444e5c01f447c4e4e10a99c53be19c1b0686a2e5bebb2cb9ad4217f
|
Provenance
The following attestation bundles were made for pyhkc-0.6.0-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on jasonmadigan/pyhkc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyhkc-0.6.0-py3-none-any.whl -
Subject digest:
39f2519b968d724fb54562ca16d1e536c30b8dbf5be0ef4fa9d92007b5724db2 - Sigstore transparency entry: 1236240819
- Sigstore integration time:
-
Permalink:
jasonmadigan/pyhkc@b96b17fd5a031cad77f9f1047858fc6d48ceb646 -
Branch / Tag:
refs/tags/0.6.0 - Owner: https://github.com/jasonmadigan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@b96b17fd5a031cad77f9f1047858fc6d48ceb646 -
Trigger Event:
push
-
Statement type: