node-red-adv-lights
Version:
Niko Home Control 2, Advanced light translators for Tuya and Home Assistant (mode-aware, brightness carry-over)
34 lines (24 loc) • 1.54 kB
Markdown
# node-red-adv-lights
Two advanced, mode-aware light helpers for Node-RED to be used with Niko Home Control Hobby API (node-red-contrib-nhc2):
- **tuya-adv**: Flexible input → friendly payload or Tuya commands. Avoids flipping to white when adjusting brightness in colour mode.
- **ha-adv**: Flexible input → Home Assistant `light.turn_on` payload. Remembers brightness across colour/white mode switches.
## Requirements
- node-red-contrib-nhc2
## Install
Copy this folder into your Node-RED user directory (usually `~/.node-red/`) and run:
```bash
cd ~/.node-red/node-red-adv-lights
npm install
# then restart Node-RED
```
## Nodes
- **tuya-adv**
- Inputs: `switch`, `Status`, `Brightness`/`brightness` (0–100 or 0–1000), `Color` (`hsv()`/`rgb()`), `TunableWhite` (`cwww(kelvin,percent)`), `ColorMode`/`mode`.
- Outputs:
- default: `msg.payload` with `switch`, `mode`, `brightness` (0–100), `temperature` (0–100), `colour_data_v2`.
- if `msg.format="commands"`: `msg.commands` Tuya codes (`switch_led`, `work_mode`, `bright_value_v2`, `temp_value_v2`, `colour_data_v2`). Choose 0–100 or 0–1000 scale.
- Statefully keeps last mode/brightness/colour; applies brightness to V in colour mode. Optionally hides `brightness` in colour mode.
- **ha-adv**
- Inputs: same as above.
- Outputs: Home Assistant `light.turn_on` payload with `brightness_pct`, and either `hs_color`/`rgb_color` or `color_temp[_kelvin]` (or `color_temp` in mireds).
- Remembers last brightness and carries it when switching modes.