GithubHelp home page GithubHelp logo

bjohnso5 / hue-hacking-npm Goto Github PK

View Code? Open in Web Editor NEW
21.0 3.0 2.0 1.33 MB

Hue Hacking, as a Node Package Manager module

License: MIT License

JavaScript 0.27% TypeScript 98.61% Dockerfile 1.12%
hue philips-hue-bulbs

hue-hacking-npm's Introduction

hue-hacking-npm: Hue Control Library

npm version CircleCI Coverage Status

hue-hacking is a javascript library designed to control the Philips Hue smart LED bulb system. This version has been modified to be used as a Node module.

For more information on the Philips Hue bulbs and wireless bridge system, visit meethue.com.

Initial concept and startup work inspired by Ross McKillop's post.

Getting Started

Once you've followed the instructions with your Hue starter kit and you have your lamps working through the web interface or smartphone app, it's time to configure your copy of hue.js.

For a full breakdown of what the Philips Hue API/SDK offers, check out the official developer site. Full details about how to register a new 'user' with the wireless bridge can be found at the SDK getting started page.

  1. Generate and save your MD5 hash (any MD5 generator will do). Be sure to save your hash and the passphrase used to generate it in a safe place.

  2. Find the IP address of your Hue wireless bridge. This can be gathered in a number of ways, including the meethue.com control panel, https://www.meethue.com/en-US/user/preferencessmartbridge, by clicking on the "Show me more" link. See screenshot for an example. Alternatively, you can browse to this URL, and use the value displayed in internalipaddress. This module now supports a static search operation, allowing you to find any Hue bridges attached to the local network (using the same UPNP approach as mentioned previously):

import { Hue, HueUPNPResponse } from "hue-hacking-node";

const foundBridges: HueUPNPResponse[] = await Hue.search();
const validBridgeIPs: string[] = [];
for (let bridge of foundBridges) {
  validBridgeIPs.push(bridge.internalipaddress);
}

Or, if you can't use async / await semantics in your module:

import { Hue, HueUPNPResponse } from "hue-hacking-node";

let validBridgeIPs: string[] = [];
Hue.search().then((bridges) => {
  for (let bridge of bridges) {
    validBridgeIPs.push(bridge.internalipaddress);
  }
});
  1. Quick example configuration:
import { Hue } from "hue-hacking-node";

const bridgeIP = "192.168.x.x";
const appname = "myfirsthueapp"; // This is the hash / name / id that you registered with the bridge previously using the official Hue docs

const hue = new Hue({
  ip: bridgeIP,
  key: appname,
  numberOfLamps: 3,
  retrieveInitialState: false,
});

For the best introduction to using this module, please see the hue-node.spec.ts file.

ยฉ 2024 Bryan Johnson; Licensed MIT.

hue-hacking-npm's People

Contributors

bjohnso5 avatar chmac avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

hue-hacking-npm's Issues

Coverage reporting is now broken

The npm script that is run on Travis CI to automatically generate coverage reports and ship them to coveralls.io is broken, creating empty reports.

Investigation into what change broke the toolchain and how to fix it is required.

Do the light indexes match?

Here's the getLamps() code:

public async getLamps(): Promise<Lamp[]> {
const url = this.buildLampCompositeURL();
const { data } = await this.get(url);
return Object.keys(data).map(k => data[k]);
}

In the last line, the returned data is converted from an object into an array. The object I see in my tests looks like:

{
"1": Lamp,
"2": Lamp,
"3": Lamp
}

But the resulting array is zero indexed and so to be able to call setColor I need a 1 based index. So I end up adding 1 to the index. I'm wondering if this is deliberate. I assume that the Hue API will never skip number, nor return indexes out of sequence, but I can't see any way to actually get the index out of the getLamps() response. Would you be open to a PR which added a field called index to the Lamp type?

Referenced main-file in package.json not distributed in package

Hi there,
I'm using "hue-hacking-npm" as a dependency in my project.
Everything worked fine in the past.
However, with the latest updates of some of my other frameworks (Electron, etc.) I now get the following error on startup:

Cannot find module ... node_modules/hue-hacking-node/dist/index.js'. Please verify that the package.json has a valid "main" entry.

I guess that's because "hue-hacking-npm" doesn't distribute the dist-folder itself, but the main-file being referenced in package.json lies in that folder.

...
  "description": "Utility to control Philips Hue light bulbs",
  "main": "dist/index.js",
...

Is there a chance that could be fixed with an upcoming release? ๐Ÿ˜ƒ
Thanks a lot!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.