Niko Home Control 2, Advanced light translators for Tuya and Home Assistant (mode-aware, brightness carry-over)
npm install node-red-contrib-nhc2-adv-lightsThis 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".
---
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
---
- 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
---
Make sure you have Node-RED and node-red-contrib-nhc2 installed:
``bash`
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.js
- tuya-adv.html
- tuya-adv.js
-
Restart Node-RED. The new nodes will appear under the function category.
---
`json`
{
"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. msg.payload
- Output 2 (OFF): emits only when OFF is requested; is {} → pass to light.turn_off.
---
`json`
{
"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.
---
If msg.format is not provided, the node outputs a friendly payload in msg.payload:
#### Example: White mode
`json`
{
"payload": {
"switch": true,
"mode": "white",
"brightness": 80,
"temperature": 30
}
}
#### Example: Colour mode
`json`
{
"payload": {
"switch": true,
"mode": "colour",
"colour_data_v2": "{"h":180,"s":1000,"v":800}"
}
}
---
package.json snippet:
`json`
"dependencies": {
"node-red-contrib-nhc2": "^1.18.0"
}
These nodes require outputs from NHC2 nodes with property: All` to function correctly.
---
MIT License