New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

hue-push-client

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hue-push-client

[![License](https://img.shields.io/badge/License-MIT-blue)](#license "Go to license section")

  • 1.0.5
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
300
increased by10.7%
Maintainers
1
Weekly downloads
 
Created
Source

hue push client

License

Allows easy access to the push API of Philips Hue Bridge

Installation

npm install hue-push-client

Usage Example

/**
 * This example connects to a Hue Bridge and closes connection after 30 seconds
 */
const HuePushClient = require('hue-push-client');

const client = new HuePushClient({ip: '10.0.0.1', user: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'});
setTimeout(() => {client.close();}, 30000);
client.addEventListener('open', function () {
    console.log('connection opened');
});
client.addEventListener('close', function () {
    console.log('connection closed');
});
client.addEventListener('error', function (e) {
    console.log('error: ' + e.message);
});
client.addEventListener('message', function (message) {
    if (!message.data) {
        console.log('empty message');
        return;
    }
    try {
        let data = JSON.parse(message.data);
        console.log(JSON.stringify(data));
    } catch (e) {
        console.log('could not parse data');
        return;
    }
});

The data part of an incomming message looks like this:

[
   {
      "creationtime":"2021-09-01T08:40:54Z",
      "data":[
         {
            "id":"d231f405-baab-406e-0000-d345a1440000",
            "id_v1":"/sensors/8",
            "light":{
               "light_level":10509,
               "light_level_valid":true
            },
            "type":"light_level"
         }
      ],
      "id":"f15d7da4-f849-44c9-0000-afc54dbe0000",
      "type":"update"
   }
]

You can also retrieve a description of all UUID's that are used in update messages:

/**
 * Be aware that uuids() returns a promise
 */
async function getUUIDs() {
    try {
        let UUIDs = await client.uuids();
        console.log(UUIDs);
    } catch (e) {
        console.log(e);
    }
};
getUUIDs();

Documentation

todo (see examples)

license

Released under ISC by @Pmant

Keywords

FAQs

Package last updated on 26 May 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc