Giter Club home page Giter Club logo

philips-hue-push-client's Introduction

About this project

Recent versions of the Hue Bridge firmware are exposing a new API version for the Hue system. The API v2 does support "push" style notifications for every change in the system, without the need for polling the Bridge.

Read the official documentation

How are notifications implemented

The Hue Bridge is now exposing an endpoint using Server-Sent Events (SSE).

The new APIs are ONLY available when using HTTPS so make sure you're connecting using HTTPS.

This library will automatically try to reconnect on failure.

How to use this package

const { SSEClient } = require('@homegraph/philips-hue-push-client');

const huePush = new SSEClient(
  'https://YOUR_BRIDGE_IP:443',
  'YOUR_API_KEY',
);

huePush.on('connected', () => console.log('Connected to the Hue Bridge'));
huePush.on('update', (data) => console.log('UPDATE RECEIVED', data));
huePush.on('error', (err) => console.error('ERROR RECEIVED, implement your logic here', err));

huePush.connect();

// To close the connection with the bridge:
// huePush.close();

update event spec

Payload example:

{
  "resource": "lights",
  "idv1": "38",
  "idv2": "3dba6784-3fa6-4e51-979c-daed68cad240",
  "creationTime": "2021-01-01T15:32:04Z",
  "dimming": { "brightness": 100 },
  "color": { "xy": { "x": 0.3691, "y": 0.3719 } },
  "color_temperature": { "mirek": 233 }
}
  • resource is the Hue API v1 resource name (e.g. lights, groups, sensors, etc)
  • idv1 is the Hue API v1 resource ID (in this example this light is available under /lights/38)
  • idv2 is the Hue API v2 resource ID. It looks like the API v2 is using UUIDs instead of incremental numeric IDs
  • all remaining props as per documentation

philips-hue-push-client's People

Contributors

paolotremadio avatar

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.