Skip to main content

Python SDK for Niko Home Control 2

Project description

pynhc2

version = 0.1.4

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.

PyPI version Python 3.12+ Documentation Status License: MIT

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

pynhc2-0.1.4.tar.gz (19.7 kB view details)

Uploaded Source

Built Distribution

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

pynhc2-0.1.4-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file pynhc2-0.1.4.tar.gz.

File metadata

  • Download URL: pynhc2-0.1.4.tar.gz
  • Upload date:
  • Size: 19.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for pynhc2-0.1.4.tar.gz
Algorithm Hash digest
SHA256 b89d386b4b4f30ff13762eff081f3f0a0d256c350bce9f009d8a9d043e419f95
MD5 7282a2d549c9b8c26c45139d1a5d2bb4
BLAKE2b-256 8a387a0cef6c11f75848aff3afb41f16b44361518536207876fa1be9841ac324

See more details on using hashes here.

File details

Details for the file pynhc2-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: pynhc2-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 13.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for pynhc2-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 b82c7a28dbec2e9a2247cbd33fefb5a67e4c549441592dcd79ee51258f6a5ebe
MD5 6116bbd3938d6c8c558f7e662859edda
BLAKE2b-256 deb7372528fdd6ff0b726338fdaab0c5408dd890bd35ae97f6307be11e0b2c03

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