Skip to content

Commit

Permalink
feat: allow users to configure the lights ids
Browse files Browse the repository at this point in the history
  • Loading branch information
SantiMA10 committed May 15, 2020
1 parent 9a80b7d commit 62a9fc8
Show file tree
Hide file tree
Showing 5 changed files with 3,234 additions and 43 deletions.
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ TWITCH_TOKEN=""
HUE_CLIENT_ID=""
HUE_CLIENT_SECRET=""
HUE_TOKEN=""
HUE_REFRESH_TOKEN=""
HUE_REFRESH_TOKEN=""
HUE_LIGHTS=""
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ cp .env.example .env
| HUE_CLIENT_SECRET | The client secret from a [Philips Hue Remote](https://developers.meethue.com/develop/hue-api/remote-api-quick-start-guide/) | **true** |
| HUE_TOKEN | The [hue access token](https://developers.meethue.com/develop/hue-api/remote-authentication/) generated with the same Philips Hue Remote | **true** |
| HUE_REFRESH_TOKEN | The [hue refresh token](https://developers.meethue.com/develop/hue-api/remote-authentication/) generated with the same Philips Hue Remote | **true** |
| HUE_LIGHTS | A comma separated string with the ids of the lights you want to let your streaming to turn off/on | **true** |
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"dev:hue": "nodemon -r dotenv/config src/hue.js"
},
"devDependencies": {
"jest": "^26.0.1",
"nodemon": "^2.0.3"
},
"dependencies": {
Expand Down
10 changes: 5 additions & 5 deletions src/hue.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ const updateLightStatus = async ({ on } = { on: false }) => {
process.env.HUE_REFRESH_TOKEN
);

await Promise.all([
api.lights.setLightState(5, { on }),
api.lights.setLightState(6, { on }),
api.lights.setLightState(9, { on }),
]);
await Promise.all(
process.env.HUE_LIGHTS.split(",").map((id) =>
api.lights.setLightState(id, { on })
)
);
};

module.exports = updateLightStatus;
Loading

0 comments on commit 62a9fc8

Please sign in to comment.