{"id":19319051,"url":"https://github.com/ericrabil/phea.js","last_synced_at":"2025-04-22T17:31:25.012Z","repository":{"id":57322938,"uuid":"317137682","full_name":"EricRabil/phea.js","owner":"EricRabil","description":"Node.JS implementation of the Hue Entertainment API but it works","archived":false,"fork":false,"pushed_at":"2021-10-30T22:11:20.000Z","size":80,"stargazers_count":6,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-13T07:54:33.665Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EricRabil.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-11-30T07:00:54.000Z","updated_at":"2023-05-26T08:06:02.000Z","dependencies_parsed_at":"2022-08-25T22:42:33.627Z","dependency_job_id":null,"html_url":"https://github.com/EricRabil/phea.js","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EricRabil%2Fphea.js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EricRabil%2Fphea.js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EricRabil%2Fphea.js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EricRabil%2Fphea.js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EricRabil","download_url":"https://codeload.github.com/EricRabil/phea.js/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223901668,"owners_count":17222228,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T01:21:46.155Z","updated_at":"2024-11-10T01:21:46.810Z","avatar_url":"https://github.com/EricRabil.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# phea.js\nNode.JS implementation of the Hue Entertainment API but it works\n\nI wrote this library because the existing Node.JS Hue Entertainment API implementations were simply painful to use.\n\n## Installation\n```\nyarn add phea.js\n```\n\n## Example\n\nFor a real example, take a look at [spotihue](https://github.com/EricRabil/spotihue)\n\n```js\nimport HueStream, { LoopEffect, Color } from \"phea.js\";\n// Equivalent, for the plebeians:\nconst { HueStream, LoopEffect, Color } = require(\"phea.js\");\n\nasync function run() {\n    const ipAddresses = await HueStream.discover();\n\n    // Determine what IP you'll use here\n\n    const ipAddress = ipAddresses[0];\n\n    // Push the button!\n\n    console.log(\"Hey, you should click that button\");\n\n    await new Promise(resolve =\u003e setTimeout(resolve, 10000));\n\n    const credentials = await HueStream.register(ipAddress);\n\n    const lightIDs = await HueStream.lightIDs(credentials);\n    const entertainmentGroupID = await HueStream.createGroup(credentials, lightIDs);\n\n    // Yay! We're ready to use HueStream.\n\n    const stream = await HueStream.make({\n        group: entertainmentGroupID,\n        auth: credentials\n    });\n    \n    const effect = new LoopEffect({\n        colors: [\n            Color.RED,\n            Color.GREEN,\n            Color.BLUE\n        ],\n        // 50 is the default refresh rate\n        framesPerColor: 50\n    });\n\n    stream.effects.push(effect);\n\n    await stream.start();\n}\n\nrun();\n```\n\n## Writing your own effects\n\nSubclass the [Effect](https://github.com/EricRabil/phea.js/blob/main/src/effect/Effect.ts) class, then push it to `stream.effects`.\n\nThere's [a few example effects](https://github.com/EricRabil/phea.js/blob/main/src/effect/effects) to get you started.\n\n## Colors\n\nphea.js has two Color structs – `Color` and `EffectColor`, which extends `Color`.\n\n`Color` is simply an RGB object, while `EffectColor` adds opacity and brightness.\n\n- `red`, `green`, `blue`, and `brightness` are all values from 0.0 – 255.0.\n- `Color` and `EffectColor` offer a variety of utility functions for mixing and matching colors. Read about them on their respective doc pages.\n\n## Using the DTLS client directly\n\nDon't want to use my wrapper? :( That's fine. There's a `DTLS` export that lets you interact with the API directly. Pass it an instance of the Hue API per [`node-hue-api`](https://github.com/peter-murray/node-hue-api), the groupID, and the credentials.\n\n```ts\ninterface DTLSConnectionOptions {\n    host: string;\n    username: string;\n    psk: string;\n}\n\nclass DTLS {\n    constructor(public readonly hue: Api, public lights: number[], gamuts: (ColorGamut | null)[], public group: string, public options: DTLSConnectionOptions);\n}\n```\n\n## Documentation\n[Docs live here.](docs/README.md)\n\n## Feedback\nHave an issue? Made something cool? Let me know!\n\nOpen an issue or email me at [ericjrabil@gmail.com](mailto:ericjrabil@gmail.com). I'd love to hear from you!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fericrabil%2Fphea.js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fericrabil%2Fphea.js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fericrabil%2Fphea.js/lists"}