# node-red-contrib-node-lifx

> Control LIFX lights using Node-RED.

Latest version **0.11.0** (published 2025-05-24) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install node-red-contrib-node-lifx
pnpm add node-red-contrib-node-lifx
yarn add node-red-contrib-node-lifx
bun add node-red-contrib-node-lifx
```

## Health

**Score 25/100 (F)** — status: maintenance-mode.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.11.0 |
| Published | 2025-05-24 |
| First published | 2017-01-22 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Unpacked size | 87 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 15 |
| Author | jdomeij |
| Maintainers | ristomatti, jdomeij |
| Keywords | node-red, node-red-contrib, contrib, lifx |

## Links

- npm: https://www.npmjs.com/package/node-red-contrib-node-lifx
- Repository: https://github.com/ristomatti/node-red-contrib-node-lifx
- Issues: https://github.com/ristomatti/node-red-contrib-node-lifx/issues
- npm.io page: https://npm.io/package/node-red-contrib-node-lifx

## Dependencies (7)

- [enum](https://npm.io/package/enum.md) ^2.5.0
- [async](https://npm.io/package/async.md) ^2.6.3
- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [color-temp](https://npm.io/package/color-temp.md) 0.0.2
- [color-space](https://npm.io/package/color-space.md) ^1.16.0
- [color-convert](https://npm.io/package/color-convert.md) ^1.9.2
- [lifx-lan-client](https://npm.io/package/lifx-lan-client.md) ^2.1.1

## Recent versions

- 0.11.0 (latest) — 2025-05-24
- 0.10.2 — 2020-11-02
- 0.10.1 — 2020-04-14
- 0.10.0 — 2020-04-14
- 0.9.3 — 2018-07-20
- 0.9.2 — 2018-01-22
- 0.9.1 — 2017-02-28
- 0.9.0 — 2017-01-29
- 0.8.0 — 2017-01-22

## README

# LIFX nodes for Node-RED

A solution to control LIFX lights over local network using Node-RED that uses
[lifx-lan-client library](https://github.com/node-lifx/lifx-lan-client) for communicating with the lights.

This module provides input and output nodes for communicating with LIFX lights, the input node accepts multiple
color format and automatically converts the values to the right format. 

### Features

* Convert input arguments to light specific arguments
* Trigger events for light changes
* Self syncing, uses background polling to detect external changes to light
* Display current state for light in Node-RED UI
* Ability to set waveforms **EXPERIMENTAL**

### Examples

##### Dashboard example config:

This is an example of how to control the light using the
[node-red-dashboard](https://github.com/node-red/node-red-dashboard)
The split node can be used to get the `on` and `bri` payload from the light status message, and the join node to
combine the topic and value to an JSON object.

![UI example](./doc/example_ui.png)

##### Wakeup example config:

Simple example of using an inject node to trigger a wakeup light behavior every workday, the light transitions from
off to on with 75% brightness over a duration of 30s.

![Wakeup example](./doc/wakeup.png)

##### Hub Configuration

![Hub config](./doc/config_server.png)

##### Light Configuration

![Light config](./doc/config_light.png)

### Input node

Lights can be controlled by sending message with a payload containing the new state.

#### Set power state

Simplified control by sending the following values as payload

| Value | Info |
|---|---|
| `'on'` or `true` | Turn light on |
| `'off'`or `false` | Turn light off |
| numeric value | Turn light on and set brightness (0-100%) |

#### Set color

More advanced way to control the light is to send an object payload with one or more of the following properties set

| Property | Info |
|---|---|
| `on` | Set light state (true/false)|
| `red`, `green` and/or `blue` | Set one or more color change for light (0-255)|
| `hex` | Set color (#f49242) |
| `hue` | Set color hue (0-360) |
| `sat` or `saturation` | Set color saturation (0-100) | 
| `bri` or `brightness` | Set light brightness (0-100%) |
| `cr`, `mired` or `mirek` | Set Mired color temperature (153 - 500) |
| `kelvin` | Set kelvin color temperature (2200-6500) |
| `duration` | Transition time (ms) |

#### Set waveform

Waveform is a way to create effect in lifx bulbs, like the breath effect in the LIFX App. Setting a wave form
will be at the following JSON form.

```json5
{
  "isTransient": true,
  "color": { "hue": 0, "saturation": 65535, "brightness": 65535, "kelvin": 3500 },
  "period": 800,
  "cycles": 3,
  "skewRatio": 0,
  "waveform": "SINE"  // one of SAW, SINE, HALF_SINE, TRIANGLE, PULSE
}
```

**Notice:** to get the same behavior as with the LIFX app when modifying the color temperature you will need to
manually set the saturation to zero. This is because a LIFX light can adjust temperature and color independent
of each other, and I didn't want to limit the choices for the user.

Example: Sending the following to the light will turn it on and dim it upp to 77% over 10 seconds

```json
{
  "payload": {
    "on": true, 
    "bri": 77,
    "duration": 10000
  }
}
```


### Output node

Example output from change event 
```json
{
  "id": "d073d5015103",
  "info": {
    "id": "d073d5015103",
    "name": "LIFX Black",
    "address": "192.168.1.107", 
    "model": "Original 1000",
    "capability": ["temperature", "color"]
  },
  "payload": { 
    "on": true, 
    "reachable": true, 
    "bri": 57, 
    "hsv": [ 169, 37, 57 ], 
    "rgb": [ 91, 145, 135 ], 
    "hex": "5C9187", 
    "color": "cadetblue", 
    "kelvin": 2513, 
    "mired": 397
  },
  "state": {
    "on": true,
    "brightness": 57,
    "hue": 169,
    "saturation": 37,
    "kelvin": 2513
  },
  "event": "change",
  "_msgid": "cfd24df6.65934"
}
```


# Using independently

This library can be used independent of Node-RED, the [example/mqtt.js](./example/mqtt.js) file contains a
simple example using [MQTT.js](https://github.com/mqttjs/MQTT.js) to enable control lights on/off status
and brightness over MQTT.

The MQTT topic `lights` will contain a list of all currently detected lights.
Specific light can be controlled by sending a message to the topics `lights/<id>/on` (boolean) or
`lights/<id>/brightness` (number) with the new state.

---
_Source: https://npm.io/package/node-red-contrib-node-lifx · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
