# philips-hue

> Philips Hue bridge API wrapper

Latest version **1.2.0** (published 2016-11-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install philips-hue
pnpm add philips-hue
yarn add philips-hue
bun add philips-hue
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2016-11-29 |
| First published | 2015-02-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+25 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 17 |
| Author | Sho Hashimoto |
| Maintainers | shokai |
| Keywords | philips, hue, light |

## Links

- npm: https://www.npmjs.com/package/philips-hue
- Repository: https://github.com/shokai/node-philips-hue
- Homepage: https://github.com/shokai/node-philips-hue/tree/master/packages/philips-hue#readme
- Issues: https://github.com/shokai/node-philips-hue/issues
- npm.io page: https://npm.io/package/philips-hue

## Dependencies (2)

- [axios](https://npm.io/package/axios.md) ^0.9.1
- [debug](https://npm.io/package/debug.md) *

## Alternatives

- [@oh-my-pi/pi-natives](https://npm.io/package/@oh-my-pi/pi-natives.md) — 51.8K weekly downloads
- [@capgo/capacitor-light-sensor](https://npm.io/package/@capgo/capacitor-light-sensor.md) — 3.0K weekly downloads
- [@heyhuynhgiabuu/pi-diff](https://npm.io/package/@heyhuynhgiabuu/pi-diff.md) — 492 weekly downloads
- [@lotsa/verdant-lang-asm](https://npm.io/package/@lotsa/verdant-lang-asm.md) — 38 weekly downloads
- [new-era-syntax](https://npm.io/package/new-era-syntax.md) — 20 weekly downloads

## Recent versions

- 1.2.0 (latest) — 2016-11-29
- 1.1.10 (stable) — 2016-04-06
- 1.1.11 — 2016-04-13
- 1.1.9 — 2016-02-05
- 1.1.7 — 2016-02-05
- 1.1.6 — 2016-02-05
- 1.1.3 — 2016-02-04
- 1.1.0 — 2016-02-03
- 1.0.2 — 2016-01-31
- 1.0.1 — 2016-01-31
- 1.0.0 — 2016-01-31
- 0.2.0 — 2016-01-29
- 0.1.2 — 2015-04-30
- 0.1.1 — 2015-03-05
- 0.1.0 — 2015-03-01
- … 2 more at https://npm.io/package/philips-hue/versions

## README

# Philips Hue

Node.js library for [Philips Hue bridge API](http://www.developers.meethue.com/philips-hue-api)

- https://github.com/shokai/node-philips-hue
- https://npmjs.com/package/philips-hue
- [CLI tool](https://www.npmjs.com/package/philips-hue-cmd) is available

[![Circle CI](https://circleci.com/gh/shokai/node-philips-hue.svg?style=svg)](https://circleci.com/gh/shokai/node-philips-hue)


## Install

    % npm i philips-hue -save


## Samples

see [samples directory](https://github.com/shokai/node-philips-hue/tree/master/packages/philips-hue/samples)


## Usage

```javascript
var Hue = require('philips-hue');
var hue = new Hue();
```

### Get Bridge's address and Auth

```javascript
hue.getBridges()
  .then(function(bridges){
    console.log(bridges);
    var bridge = bridges[0]; // use 1st bridge
    console.log("bridge: "+bridge);
    return hue.auth(bridge);
  })
  .then(function(username){
    console.log("username: "+username);

    // controll Hue lights
    hue.light(1).on();
    hue.light(2).off();
    hue.light(3).setState({hue: 50000, sat: 200, bri: 90});
  })
  .catch(function(err){
    console.error(err.stack || err);
  });
```

`username` is required for the next login.

```javascript
var hue = new Hue;
hue.bridge = "192.168.0.101";  // from hue.getBridges
hue.username = "a1b2cdef3456"; // from hue.auth
hue.light(1).on();
```

### Login

`hue.login` is useful wrapper of `getBridges` and `auth`. It automatically store/restore `username` and `bridge` address.

```javascript
var hue = new Hue;
var configFile = process.env.HOME+'/.philips-hue.json';

hue
  .login(configFile)
  .then(function(conf){
    return hue.light(1).on();
  })
  .then(function(res){
    console.log(res);
  })
  .catch(function(err){
    console.error(err.stack || err);
  });
```

### getLights

```javascript
hue.getLights()
  .then(function(lights){
    console.log(lights);
    console.log(Object.keys(lights) + " lights found!");
  })
  .catch(function(err){
    console.error(err.stack || err);
  });
```

### on / off

```javascript
var light = hue.light(1);

light.on().then(console.log).catch(console.error);
```

```javascript
hue.light(2).on().then(console.log).catch(console.error);
```

### setState

```javascript
var state = {bri: 200, sat: 120, hue: 50000};

hue.light(1).setState(state).then(console.log).catch(console.error);

hue.light(2).setState({effect: "colorloop"});

hue.light(3).setState({alert: "lselect"});
```

### getInfo / setInfo

```javascript
var light = hue.light(1);

light.setInfo({name: "myroom"});

light.getInfo()
  .then(function(info){
    console.log(info);
  });function(err, res){
```

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