Sawtaytoes / LIFX-Controller

Advanced control over your LIFX lights on your local LAN.
MIT License
8 stars 1 forks source link
home-automation iot lifx lifx-controller lifx-lights light

NOTE: This repo has moved to https://github.com/Sawtaytoes/Smart-Home-Services

LIFX Controller

WebSockets-based LIFX Controller software.

For an example use case, look at ./app.js.

Installation

npm

npm i

yarn

yarn

Custom Configuration

WebSocket Server

To configure the Webpack listener, you have 3 options available to modify in your ./localConfig.js:

module.exports = { // ... other config options ... hostname, port, protocol, }

LIFX HTTP API Token

Go to LIFX's cloud settings page and create a new token for your app. This will go in your ./localConfig.js as:

module.exports = {
    // ... other config options ...
    lifxApiToken: 'YOUR_LIFX_API_TOKEN',
}

Custom Options for lifx-lan-client

In ./projectConfig.js or ./localConfig.js, add a property lifxLanClient as an object and its options as properties on that object.

module.exports = {
    lifxLanClient: {
        debug: true,
        messageHandlerTimeout: 2000,
        resendMaxTimes: 3,
    },
}

Testing

Toggle Group

To test toggling a group, load up a browser, and go to about:blank.

Then paste this into the devtools console:

webSocket = new WebSocket('ws://localhost:3000', 'v1')
webSocket.onmessage = console.log
webSocket.onerror = console.error
webSocket.onclose = console.info
webSocket.onopen = () => {
    console.log('READY')

    webSocket
    .send(
        JSON
        .stringify({
            sceneName: 'Late Night Computing',
            type: 'REQUEST::TOGGLE_SCENE',
        })
    )
}