Skip to main content

Python SDK for Niko Home Control 2

Project description

pynhc2

version = 0.1.1

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.

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.1.tar.gz (17.8 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.1-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pynhc2-0.1.1.tar.gz
  • Upload date:
  • Size: 17.8 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.1.tar.gz
Algorithm Hash digest
SHA256 b5f7ea6424e3223075874ff155b9f39bd43dc9f0da483f920a6a0bad84d6e123
MD5 29e5df672e5bc1003138b7964a701e43
BLAKE2b-256 a2eb9672641bc019edaf9e9452ba6b5b9f04a30410e03f6485193c014c9ea5ed

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pynhc2-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 12.3 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4d1f3b9931176af5809f26ecc2d844cf14c226e1e0d1df271bf5a536ce9c917b
MD5 a19aae8b9096e267102c16d00984b1b1
BLAKE2b-256 bdc4650112c29486cf2033f26da1571a2ffcff2dd20ba04b59775721ac85bca9

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