This is a simple client helper to enable simple interactions with Twinkly smart lights https://www.twinkly.com/.
const Twinkly = require('./twinkly-api.js');
const twinkly = new Twinkly('192.168.0.xxx');
twinkly.setMode('off');
Currently this client is very limited, please feel free to contribute to expand it.
Set the current mode of the LED lights
- Mode (String), this can be one of the following options
- off - turns off lights
- demo - starts predefined sequence of effects that are changed after few seconds
- movie - plays predefined or uploaded effect
- rt - receive effect in real time
Returns a promise, with no data
Changes the name of the current device
- Name (String), Desired device name. At most 32 characters.
Returns a promise, with no data
Restart the current animation
- none.
Returns a promise, with no data
Generate a full frame of a solid colour
- colour - object containing r,g,b parameters you wish to set between 0-244
- lightCount - the total number of lights you wish to generate the frame for
Returns an array containing the details of a single frame
Sends a new 'movie' to the device, and displays it
- movie - js object containing the configurate
- delay - the number of milliseconds to wait between each frame
- frames - array of frames
- light -
{r: 0-244, g: 0-244, b: 0-244}
- light -
Example: Alternate between all lights set to white, and each light being a different colour, with a pause of 1 second between each change
var frames = [
twinkly.generateFullFrame({r: 244, g:244, b: 244}, 3),
[
[{r: 244, g:0, b: 0}],
[{r: 0, g:244, b: 0}],
[{r: 0, g:0, b: 244}],
]
]
twinkly.newMovieUpload({
frames: frames,
delay: 1000
});
Returns a promise, with no data