NOTE: This repo has moved to https://github.com/Sawtaytoes/Smart-Home-Services
WebSockets-based LIFX Controller software.
For an example use case, look at ./app.js
.
npm
npm i
yarn
yarn
To configure the Webpack listener, you have 3 options available to modify in your ./localConfig.js
:
module.exports = { // ... other config options ... hostname, port, protocol, }
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',
}
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,
},
}
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',
})
)
}