WS2801 is a ready-to-use package that combines WS2801-Pi, its webserver, and the Alexa voice command handler.
The wiring of the Pi is described here.
There are basically two ways to use WS2801:
- Clone this repository
- Edit the config file as described here
- Run the build script:
npm run build
- Run the start script:
npm start
- 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();
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.
config
- optional
- Type: Config
- The config for this module, as described here. If no value is set, the default config is used.
Starts the webserver and the alexa device handler.
Stops the webserver and the alexa device handler.
The available routes are described here.