Python SDK for Niko Home Control 2
Project description
pynhc2
version = 0.1.3
Lightweight Python wrapper library to interact with Niko Home Control 2 systems built on top of paho-mqtt. Includes functionality to read NHC2 config files for better device readability. The library is primary built for home use.
Installation
pip install pynhc2
Quick Start
from pynhc2 import MQTTConnector, Lamp
# Connect to Niko Home Control
conn = MQTTConnector(
broker="192.168.1.10",
jwt="your-jwt-token",
ca_cert="path/to/ca.pem"
)
conn.connect()
# Control a lamp
lamp = Lamp(mqttconnector=conn, device_uuid="lamp-uuid")
lamp.switch_on()
lamp.set_brightness("75")
Documentation
The Device and Lamp classes are used to easily control individual devices. Using the NHC2FileReader, it is possible to loop through all devices in your home installation and create Device or Lamp objects that are easily human readable.
The MessageHandler and MultiMessageHandler make it possible to use incoming messages for specific devices to trigger certain output actions; this can be methods for existing Device or Lamp objects, but also actions that have nothing to do with NHC, allowing devices like Shelly to be controlled through NHC.
Under the hobby/control/devices/evt topic, the NHC Connected Controller - which also acts as MQTT message broker - does not publish events for button-type devices (e.g. 'button pressed') but it does this for the devices these buttons command (e.g. "Properties":[{"Status":"Off"}, {"Brightness": "50"}] when a button connected to a lamp is pressed).
The MessageHandler and MultiMessageHandler circumvent this setup by using the devices whose properties have changed to trigger the actions.
Full documentation is available at ReadTheDocs.
Changelog
See CHANGELOG.md for version history.
License
MIT License - see LICENSE file for details.
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
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 pynhc2-0.1.3.tar.gz.
File metadata
- Download URL: pynhc2-0.1.3.tar.gz
- Upload date:
- Size: 19.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0810e11fe8bcc29629b4f846caa701e19c17abfd203dcdab7fff2da8ff8ad7ac
|
|
| MD5 |
b12fdcdda364483b1e1eba8d869ee179
|
|
| BLAKE2b-256 |
0fb9ab94e46d82912c3f83457cbe5f06e565916054774732fabb9378c9ded57b
|
File details
Details for the file pynhc2-0.1.3-py3-none-any.whl.
File metadata
- Download URL: pynhc2-0.1.3-py3-none-any.whl
- Upload date:
- Size: 12.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e3c7f916c57447ed186e0c816878f16f4e296467e78bdbf2a1174031d7496f37
|
|
| MD5 |
ebd87fd1f09e2ece4bcdf2919d278fde
|
|
| BLAKE2b-256 |
3802eeb856f1b07e868657bab9ab22cb54cc58c2b364933052b8139add4b64a6
|