npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

node-red-contrib-nhc2-adv-lights

v1.3.0

Published

Niko Home Control 2, Advanced light translators for Tuya and Home Assistant (mode-aware, brightness carry-over)

Readme

NHC2 Advanced Light Control Nodes for Node-RED

This repository provides two custom Node-RED nodes that extend Niko Home Control 2 (NHC2) integration by building advanced payloads for Home Assistant and Tuya smart lights.

These nodes are designed to be used together with node-red-contrib-nhc2.
Input signals should always come from NHC2 nodes with property set to "All".


Nodes

1. ha-adv

Builds Home Assistant light.turn_on payloads with mode awareness and brightness carry-over.

  • Understands inputs from NHC2 (property: All):

    • Status / switch
    • Brightness / brightness
    • Color (hsv() / rgb())
    • TunableWhite (cwww(kelvin,percent))
    • temperature (0–100% or Kelvin)
    • ColorMode / mode
  • Features:

    • Handles white vs colour modes with brightness preservation
    • Supports both Kelvin and Mireds for CT
    • Quiet status option for reduced debug noise

2. tuya-adv

Converts NHC2 signals into either a friendly payload or Tuya-native commands.

  • Understands inputs from NHC2 (property: All):

    • Status / switch
    • Brightness / brightness (0–100 or 0–1000)
    • Color (hsv() / rgb())
    • TunableWhite (cwww(kelvin,percent))
    • ColorMode / mode
  • Features:

    • Converts to Tuya commands array when msg.format="commands"
    • Default: produces a friendly payload (msg.payload)
    • Supports scaling (pct 0–100 or tuya 0–1000)
    • Brightness carry-over between colour/white modes
    • Optionally strip brightness from colour payloads

Installation

Make sure you have Node-RED and node-red-contrib-nhc2 installed:

cd ~/.node-red
npm install node-red-contrib-nhc2@^1.18.0

Copy the following files into your Node-RED ~/.node-red/nodes/ directory:

  • ha-adv.html
  • ha-adv.js
  • tuya-adv.html
  • tuya-adv.js

Restart Node-RED. The new nodes will appear under the function category.


Example Usage

Home Assistant (ha-adv)

{
  "payload": {
    "Status": "On",
    "Brightness": 75,
    "Color": "hsv(200,100,100)",
    "ColorMode": "Color"
  }
}

➡ Builds a Home Assistant light.turn_on payload.

ha-adv outputs

  • Output 1 (ON): msg.payload → pass directly into Home Assistant light.turn_on.
  • Output 2 (OFF): emits only when OFF is requested; msg.payload is {} → pass to light.turn_off.

Tuya (tuya-adv) with msg.format="commands"

{
  "payload": {
    "Status": "On",
    "TunableWhite": "cwww(3000,80)",
    "mode": "white"
  },
  "format": "commands"
}

➡ Produces Tuya-native commands such as switch_led, bright_value_v2, temp_value_v2.


Tuya (tuya-adv) default output (no format given)

If msg.format is not provided, the node outputs a friendly payload in msg.payload:

Example: White mode

{
  "payload": {
    "switch": true,
    "mode": "white",
    "brightness": 80,
    "temperature": 30
  }
}

Example: Colour mode

{
  "payload": {
    "switch": true,
    "mode": "colour",
    "colour_data_v2": "{"h":180,"s":1000,"v":800}"
  }
}

Dependencies

package.json snippet:

"dependencies": {
  "node-red-contrib-nhc2": "^1.18.0"
}

These nodes require outputs from NHC2 nodes with property: All to function correctly.


License

MIT License