Skip to main content

Python SDK for Niko Home Control 2

Project description

pynhc2

version = 0.1.2

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.2.tar.gz (18.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.2-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pynhc2-0.1.2.tar.gz
  • Upload date:
  • Size: 18.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.2.tar.gz
Algorithm Hash digest
SHA256 15d739877ca5c945639ddedd1ebd01e58b1a0d441e35af0caf0043ef98b14a59
MD5 412d2e1960bdfcb7449d61d4f29c1606
BLAKE2b-256 18052e0fa8c1501fdd118cbb65a7476528fdd6966469dcdef41aa04cd9672fc7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pynhc2-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 12.7 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0f28d3a86749588a7104a2e7bb9d6155fdfdd8082ec5c6d8756f2943cbf3d3de
MD5 f0cd3f7c0b6651e4b24e2568efc7bdd2
BLAKE2b-256 2c8cbcb2d8c6c7af1e16eb3fc599f2af9e40864c679a67d99fe54f9f9f2054f0

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