node-red-contrib-nhc2-adv-lights 1.1.3
Niko Home Control 2, Advanced light translators for Tuya and Home Assistant (mode-aware, brightness carry-over)
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/switchBrightness/brightnessColor(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/switchBrightness/brightness(0–100 or 0–1000)Color(hsv()/rgb())TunableWhite(cwww(kelvin,percent))ColorMode/mode
Features:
- Converts to Tuya
commandsarray whenmsg.format="commands" - Default: produces a friendly payload (
msg.payload) - Supports scaling (
pct0–100 ortuya0–1000) - Brightness carry-over between colour/white modes
- Optionally strip brightness from colour payloads
- Converts to Tuya
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.htmlha-adv.jstuya-adv.htmltuya-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 Assistantlight.turn_on. - Output 2 (OFF): emits only when OFF is requested;
msg.payloadis{}→ pass tolight.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