Git Product home page Git Product logo

node-milight-promise's Introduction

node-milight-promise

A node module to control Milight LED bulbs and OEM equivalents auch as Rocket LED, Limitless LED Applamp, Easybulb, s`luce, iLight, iBulb, and Kreuzer. This library use Promises to automatically synchronize the command sequences. So there is no need for nesting commands using callback. Of course, each API call returns a promise which can be used to wait for the call to be resolved or rejected.

Introduction

Milight uses a very primitive three-byte-sequence one-way communication proptocol where each command must be sent in a single UDP packet. It is fire & forget really similar to simply RF protocols fro garage door openers and such. Compared to other Milight libraries I am using a more more aggressive timing for the delay between sending UDP command packets (delayBetweenCommands property). Generally, the delay is to reduce the chances of UDP package loss on the network. A longer delay may lower the risk of data loss, however, data loss is likely to occur occasionally on a wireless network. Keep in mind, that apart from your Wifi network there is another lossy communications channel between the Milight Controller and the bulbs. My strategy against loss is to repeat each command send three times (commandRepeat property).

Usage Example

var Milight = require('../src/index').MilightController;
var commands = require('../src/index').commands;


var light = new Milight({
        ip: "255.255.255.255",
        delayBetweenCommands: 35,
        commandRepeat: 3
    }),
    zone = 1;

light.sendCommands(commands.rgbw.on(zone), commands.rgbw.brightness(100));
for (var x=0; x<256; x++) {
    light.sendCommands( commands.rgbw.on(zone), commands.rgbw.hue(x));
}
light.pause(1000);
light.sendCommands(commands.rgbw.on(zone), commands.rgbw.whiteMode(zone));

light.close();

Instead of providing the broadcast IP address which is the default, you should provide the IP address of the Milight Controller for unicast mode.

History

  • 20150426, V0.0.1

    • Initial Version
  • 20150510, V0.0.2

    • Improved and simplified synchronization of command sequences
    • Added repeat mode to send each sequences multiple times

node-milight-promise's People

Contributors

mwittig avatar

Watchers

 avatar  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.