ws2801
v1.0.0
Published
This package combines the following packages: ws2801-pi, ws2801-webser and ws2801-alexa.
Downloads
5
Maintainers
Readme
WS2801
WS2801 is a ready-to-use package that combines WS2801-Pi, its webserver, and the Alexa voice command handler.
Wiring
The wiring of the Pi is described here.
Usage
There are basically two ways to use WS2801:
Using this repository
- Clone this repository
- Edit the config file as described here
- Run the build script:
npm run build
- Run the start script:
npm start
Using the npm module
- Create a new npm project folder
- Install this module:
npm i ws2801
import {Ws2801PiConfig} from 'ws2801-pi';
import {
AlexaConfig,
LedControllerConfig,
WebserverConfig,
WS2801,
WS2801Config,
} from './src/index';
const webserverConfig: WebserverConfig = {
port: 45451,
confirmationPort: 45452,
useAuth: true,
};
const ledControllerConfig: LedControllerConfig = {
debug: true,
};
const alexaConfig: AlexaConfig = {
appKey: '<your-sinricpro-app-key>',
secretKey: '<your-sinricpro-secret-key>',
deviceId: '<your-sinricpro-device-id>',
};
const config: WS2801Config = {
ledAmount: 10,
ledControllerConfig: ledControllerConfig,
webserverConfig: webserverConfig,
alexaConfig: alexaConfig,
};
const ws2801: WS2801 = new WS2801(config);
ws2801.start();
Configuration
The config can be specified when initializing WS2801. If no config was specified or if the repository is used, the defaultConfig which is stored here.
The config can look like this:
{
ledAmount: 10,
ledControllerConfig: {
debug: false,
},
webserverConfig: {
port: 12345,
useAuth: true,
confirmationPort: 54321,
},
alexaConfig: {
appKey: '',
secretKey: '',
deviceId: '',
logCommands: true,
},
};
ledAmount
is used to specify how many leds are connected to the Pi.ledControllerConfig
is described here.webserverConfig
is described here.alexaConfig
is described here.
Functions
constructor
Parameters:
config
- optional
- Type: Config
- The config for this module, as described here. If no value is set, the default config is used.
start
Starts the webserver and the alexa device handler.
stop
Stops the webserver and the alexa device handler.
Routes
The available routes are described here.