Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactoring documentation, example configuration, and removed test ha…
…rness
- Loading branch information
1 parent
7e552dc
commit 839765b
Showing
4 changed files
with
38 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
{ | ||
"name": "", | ||
"myConfigVariable": "3abxxxxxxxxxxxxxxxxx0f5", | ||
"pollInterval": 2000, | ||
"light": "Hue color lamp 2" | ||
"name": "huelog-slack", | ||
"logLevel": "info", | ||
"slackWebhookUrl": "slack address here" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,39 @@ | ||
# huelog-slack | ||
|
||
[![NPM Package](https://img.shields.io/npm/v/huestatus.svg?maxAge=2592000)](https://npmjs.com/package/huelog-slack) | ||
[![Build Status](https://travis-ci.org/APCOvernight/huelog-slack.svg?branch=master)](https://travis-ci.org/APCOvernight/huelog-slack) [![Coverage Status](https://coveralls.io/repos/github/APCOvernight/huelog-slack/badge.svg?branch=master)](https://coveralls.io/github/APCOvernight/huelog-slack?branch=master) [![Maintainability]( https://img.shields.io/codeclimate/maintainability/APCOvernight/huelog-slack.svg)](https://codeclimate.com/github/APCOvernight/huelog-slack/maintainability) | ||
[![Dependencies](https://img.shields.io/david/APCOvernight/huelog-slack.svg)](https://david-dm.org/APCOvernight/huelog-slack) [![Greenkeeper badge](https://badges.greenkeeper.io/APCOvernight/huelog-slack.svg)](https://greenkeeper.io/) | ||
|
||
Template [HueStatus](https://github.com/APCOvernight/huestatus/) module | ||
|
||
## Get Started | ||
|
||
- Clone or Fork this Repo | ||
- Add your desired module name, version, git repo, author etc to package.json | ||
- Run `npm install` to install dependencies | ||
- Make sure [HueStatus](https://github.com/APCOvernight/huestatus/) is installed globally `npm install -g huestatus` | ||
|
||
## Building your module | ||
|
||
The entry point for this module is index.js. It must export a class that extends the [BaseModule class from HueStatus](https://github.com/APCOvernight/huestatus/blob/master/src/Module.js). | ||
[Slack](https://slack.com/) output for huestatus events | ||
|
||
Your module class must have a `start` method. This is called when the module is loaded and HueStatus is ready to start updating. | ||
## Features | ||
- Broadcasts status events onto a slack channel | ||
|
||
Your module class can optionally have a `generateInstanceName` method, that generates a unique instanceName for use in debugging. If this method is omitted a uuid will be generated instead. | ||
## Installation | ||
|
||
The BaseModule constructor adds the module config object to `this.config`. It also creates an event emitter at `this.emitter` but you shouldn't have to access this directly. You should use the change method (see below). Configuration is read from the `.heurc` file, typically located in your home directory. | ||
|
||
### this.change(status, message) ⇒ <code>async function</code> | ||
The BaseModule change method is used to update the status (by emitting an event to the huestatus module). | ||
|
||
**Returns**: <code>Promise</code> | ||
``` | ||
npm install -g huestatus huelog-slack | ||
``` | ||
|
||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| status | <code>String</code> | The status to send to the Hue Light - One of '*ok*', '*alert*', '*warning*', '*working*' | | ||
| message | <code>String</code> | Message to send to the debug log. (Why is the status changing?) | | ||
Create a `.huerc` file on your home directory, see [HueStatus Docs](https://www.npmjs.com/package/huestatus) for more info. Add an object like this to the reporters array: | ||
|
||
**Example** | ||
```js | ||
if (someConditionIsMet) { | ||
await this.change('ok', 'everything is ok') | ||
{ | ||
"name": "huelog-slack", | ||
"logLevel": "info", | ||
"slackWebhookUrl": "slack address here" | ||
} | ||
|
||
``` | ||
|
||
## Testing | ||
|
||
The default codestyle in this repository is [APC-style](https://github.com/APCOvernight/apc-style). Run `npm run lint` to lint all js files in your project. | ||
|
||
Unit tests based on [mocha](https://mochajs.org/) are included in the `test` folder. Run these with `npm run test` command. Test coverage is calculated using [nyc](https://github.com/istanbuljs/nyc). | ||
|
||
[Stryker](https://stryker-mutator.github.io/) mutation tests can be run with `npm run stryker` | ||
|
||
### Running in your local environment | ||
|
||
Run `npm link` ([docs](https://docs.npmjs.com/cli/link)) from the project directory, to make it available to node globally. Then you can register it in your .huerc and run `huestatus` to test it manually. | ||
|
||
## Integrations | ||
|
||
A .travis.yml file is included for simple [Continuous Integration in Travis](https://travis-ci.org). You will need to add your repo to travis to set up automated builds. | ||
|
||
The npm coverage script is set up to send coverage to [Coveralls](https://coveralls.io/) and [Code Climate](https://codeclimate.com/) upon build. You will need to create an account and add your repositories there for this to work. | ||
|
||
## Publishing | ||
|
||
Make sure to write your own `README.md`, and to replace all references in `package.json` to your new module name. | ||
## Configuring a slack app (in slack) | ||
* Click your workspace name in the top left to open the menu. | ||
* Select Manage Apps. | ||
* Select Custom Integrations | ||
* Click on Incoming WebHooks | ||
* Click Add Configuration | ||
* Select the channel that messages will be posted to, or create a new channel | ||
* Click Add Incoming WebHooks integrations | ||
* The Webhook URL address should be copied into the `.huerc` configuration file, under the setting `slackWebhookUrl` | ||
|
||
You should include a `.huerc-example` file with an example of all the possible module config variables. | ||
|
||
When you are ready, publish to NPM with `npm publish`. | ||
Then run `huestatus`. As monitored statuses change, HueStatus will output information to the slack channel. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.