-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update hex regex, fix bugs and add README (#4)
- Loading branch information
Showing
11 changed files
with
6,110 additions
and
1,271 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,8 @@ | ||
HUB_IP=127.0.0.1 | ||
HUB_USER=my_hue_user | ||
TWITCH_CHANNELS=my_channel,other_channel | ||
LIGHTS_COMMAND=lights | ||
LOOP_COMMAND=loop | ||
HUE_RESOURCE=lights #or groups | ||
HUE_RESOURCE_ID=6 | ||
HUE_TRANSITION_TIME=10 |
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 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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Operation Hue Hue Hue | ||
|
||
This app lets your Twitch viewers interact with your Philips Hue Lights using the chat. | ||
|
||
## Installation | ||
|
||
1. Clone this repo | ||
|
||
2. Install dependencies | ||
|
||
```bash | ||
npm install | ||
``` | ||
|
||
3. Rename `env.example` to `.env` and edit this values: | ||
|
||
- `HUB_IP`: This is the IP address for your Philips Hue Hub. You can find yours accessing [this URL](https://discovery.meethue.com/) from the network your hub is on. | ||
- `HUB_USER`: The user to access your hub. If you don't have one yet, you'll have to create one following the instructions on the [Philips Hue Developer portal](https://developers.meethue.com/). | ||
- `TWITCH_CHANNELS`: List of Twitch channels you want to listen to for messages, separated by commas. | ||
- `LIGHTS_COMMAND`: The command the app will listen to for light updates. | ||
- `LOOP_COMMAND`: The command the app will listen to enable the color loop. | ||
- `HUE_RESOURCE`: The type of resource you want to manage with the app (lights or groups) | ||
- `HUE_RESOURCE_ID`: The id of the light you want to update with the messages. | ||
- `HUE_TRANSITION_TIME`: Transition time for the light updates. | ||
|
||
4. Run the app locally | ||
|
||
```bash | ||
npm start | ||
``` | ||
|
||
## Usage/Examples | ||
|
||
The app supports 3 types of color inputs: | ||
|
||
- hex: `#000000` to `#ffffff` | ||
- rgb: `rgb(0, 0, 0)` to `rgb(255, 255, 255)` | ||
- CSS colors: Anything from [this list](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value) | ||
|
||
```bash | ||
// hex | ||
!{YOUR-COMMAND} #ff6347 | ||
|
||
// rgb | ||
!{YOUR-COMMAND} rgb(255, 99, 71) | ||
|
||
// CSS colors | ||
!{YOUR-COMMAND} tomato | ||
``` | ||
|
||
## License | ||
|
||
[MIT](https://choosealicense.com/licenses/mit/) |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const { hexToRGB } = require("../../src/lib/color_helpers"); | ||
|
||
describe("hexToRGB", () => { | ||
test("Returns invalid color if the hex is invalid", () => { | ||
const invalid1 = hexToRGB("invalid"); | ||
const invalid2 = hexToRGB("123123@"); | ||
const invalid3 = hexToRGB("#ff"); | ||
const invalid4 = hexToRGB("#fffffffffffffffff"); | ||
const invalid5 = hexToRGB("heello"); | ||
const invalid6 = hexToRGB("FFFFFF"); | ||
const invalid7 = hexToRGB("FFF"); | ||
|
||
expect(invalid1).toBe(undefined); | ||
expect(invalid2).toBe(undefined); | ||
expect(invalid3).toBe(undefined); | ||
expect(invalid4).toBe(undefined); | ||
expect(invalid5).toBe(undefined); | ||
expect(invalid6).toBe(undefined); | ||
expect(invalid7).toBe(undefined); | ||
}); | ||
|
||
test("Returns a valid color if the hex is valid", () => { | ||
const valid = hexToRGB("#ffffff"); | ||
const validShort = hexToRGB("#ffffff"); | ||
const valid2 = hexToRGB("#ff0000"); | ||
const valid3 = hexToRGB("#00ff00"); | ||
const valid4 = hexToRGB("#0000ff"); | ||
|
||
expect(valid).toBe("rgb(255,255,255)"); | ||
expect(validShort).toBe("rgb(255,255,255)"); | ||
expect(valid2).toBe("rgb(255,0,0)"); | ||
expect(valid3).toBe("rgb(0,255,0)"); | ||
expect(valid4).toBe("rgb(0,0,255)"); | ||
}); | ||
}); |
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
Oops, something went wrong.