npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

blue-transistor

v1.2.0

Published

A library to control RGB Bluetooth LE bulbs

Downloads

3

Readme

BlueTransistor

Control your RGB Bluetooth LE bulbs from a web UI, or use as a node package.

Bluetooth bulbs supported

  1. iota Lite (http://goiota.com/)
  2. Yeelight Blue 2 (http://www.yeelight.co.uk/yeelight-blue-ii-bulb/). Has a fake SUCCESS response as of now.
  3. More bulb support coming soon...

For protocol help on the iota Bulb, https://gist.github.com/arijitdasgupta/14f60d3189319ce707847a4f577291b8

Requirements:

  • Raspberry Pi 3 / Raspberry Pi 2 with BT LE dongle / Bluetooth LE enabled computer with BlueZ stack support.
  • BlueZ Bluetooth Stack http://www.bluez.org/ (Compile and install)
  • node preferably >=5.2.0, npm preferably >=3.3.12 (Use https://github.com/creationix/nvm for easy nodeJS setup)

###To Start:

config.json holds the MAC id array of all the bulbs and their types that you want to connect. Before running, do copy config.sample.json to config.json & fill up the MAC IDs in config.json.

npm install
bower install
node app.js

OR,

./run.sh

The webapp runs on PORT 7000.

##To to use the HTTP REST API

###POST

POST to /bulbs,

{
  "bulbs": [
    {
      "red": "<RED for Bulb 1>",
      "green": "<GREEN for Bulb 1>",
      "blue": "<BLUE for Bulb 1>",
      "alpha": "<ALPHA for Bulb 1>"
    },
    [
     {
       "red": "<RED for Bulb 2>",
       "green": "<GREEN for Bulb 2>",
       "blue": "<BLUE for Bulb 2>",
       "alpha": "<ALPHA for Bulb 2>"
     },
     {
       "red": "<RED for Bulb 2>",
       "green": "<GREEN for Bulb 2>",
       "blue": "<BLUE for Bulb 2>",
       "alpha": "<ALPHA for Bulb 2>"
     },
     {
       "red": "<RED for Bulb 2>",
       "green": "<GREEN for Bulb 2>",
       "blue": "<BLUE for Bulb 2>",
       "alpha": "<ALPHA for Bulb 2>"
     }
    ],
    "flow",
    "off",
    "stop",
    "unchanged"
  ]
}

Post an array to /bulbs endpoint with each entry on that array corresponding to the bulbs array in config.json.

  • If one entry in the array is a color object it will be treated as a color command for that bulb.
  • If one entry in the array is also an array of color objects the bulb will start cycling through the colors objects.
  • stop will stop any running color changes.
  • flow will make the corresponding bulb smoothly change to random colors.
  • off will turn the corresponding bulb off.
  • unchanged won't change anything on that bulb.

###GET GET to /bulbs will get you the status of the bulbs currently online...

###The webapp You can go to / on your browser for a angular webapp doing which has an UI for the bulbs.

###The lib You can use this repository as a node library package.

npm install blue-transistor
BlueTransistor = require('blue-transistor');
BlueTransistor.registerBulb({
  macId: '<MAC ID>',
  type: 'iota'
}).init().then(function(bulbs){
  bulbs[0].writeToBulb({
    red: 255,
    blue: 255,
    green: 255,
    alpha: 255
  }).then(function(resp){
    console.log(resp);

    // Status of the bulb
    console.log(bulbs[0].stateInfo);

    // Kill the GATTtool process
    bulbs[0].killDaemon();
  });
});

###NOTES:

  • While running the app or when used as a library it will keep polling the Bluetooth bulb and maintain it's connection status. So other Bluetooth host can't connect to the same bulbs as long as the object instances (or the application) are alive.
  • To properly kill the app kill the node process with a SIGINT. It will terminate all the child processes as well.

###TODO:

  • Write a better color selector in the UI.
  • Write auto-scan for bulbs.
  • Write a kill script for the processes.
  • Write a doc site for the library.