jakebednard / node-phea Goto Github PK
View Code? Open in Web Editor NEWAn unoffcial Phillips Hue Entertainment API library for Node.js
License: MIT License
An unoffcial Phillips Hue Entertainment API library for Node.js
License: MIT License
Please add support for controlling the individual zones of the new Hue gradient lightstrips instead of the whole strip always changing to a single color.
Nice lib, got it to work in my home, thanks!
I am planning for a very simple use case: if my kids make too much noise, the lights will quickly flash red a few times. I tried the regular API but it's not fast enough for my taste. The entertainment API should make this possible. First I tried the transition function you have implemented. It works ok, but the timing is not perfect cause I have to wait for dim -> bright, then go back to dim and the timing of the setTimeout and the engine loop are not in sync well enough for the flashing to work properly.
My idea is to have a 'native' flashing function, which takes a from, to, time and amount to calculate the flashing in 1 smooth go. The main docs say the lib is meant as a basic start and can be extended for more advanced uses. So now my question is: what is your advised way to do that? How can I add functionality to the engine and the lights without having to change the original sources? Thanks for any advice on this!
Hi,
First I got phea working and it's awesome, thank you for making it ๐
I'm building an API that will be able start / stop entertainment sync. However, Phea throws an error when I'm closing a stream using phea.stop()
.
Is there any particular reason I'm not understanding for throwing an error when stopping a stream ?
Related code is the following
node-phea/src/hue-controller.js
Lines 142 to 146 in 101dd62
Thanks
I am trying to get this module to work in a nodeAPI, so i can use the hue entertainment api in python via this api of mine, now i am kinda running into a lot of problems, mainly that the lights don't change color or do anything at all:
i have this connect function:
router.get('/connect', async (req, res) => {
try {
let options = {
address: '192.168.1.233',
username: 'oyCbaYTEWX9QJ1X4UJNp4LZIDPa0lA6TPuwXhzc9',
psk: 'B1E654E9E1BD7D761CCD6841D590B94E'
};
running = true;
bridge = await Phea.bridge(options);
console.log(bridge);
res.send('Connected');
} catch (err) {
console.error(err.message);
res.status(500).send('Server Error');
}
});
which works fine, i removed the let before the bridge = await Phea.bridge(options);, so it can be used in different fucntions
i got a start and a stop function, stop just runs brige.stop and stops the loop which is running in basicExample (your example):
async function basicExample() {
let groupId = 5;
let transitionTime = 1000; // milliseconds
await bridge.start(groupId);
while (running) {
let color = [
// Generate Random RGB Color Array
Math.floor(55 + Math.random() * Math.floor(200)),
Math.floor(55 + Math.random() * Math.floor(200)),
Math.floor(55 + Math.random() * Math.floor(200))
];
// Set all lights to random color.
bridge.transition(0, color, transitionTime);
console.log(color);
// Sleep until next color update is needed.
await new Promise(resolve => setTimeout(resolve, transitionTime));
}
}
so bassically it does nothing whith the lights at all, it does change the stream to active, but doesn't change any lights.
Per #6, it seems super easy and applicable to port functionality to expressJS and hide this behind an API. This isn't ideal for those who need super^super performance, but super useful for those adding into a home library setup.
Assuming we can keep computation under 10-30ms, this should actually be fine. I've been testing with variable network latency (1-15ms) and not seeing a large effect. The color propagation will be a little bit more behind, maybe racy, but this is a very important use case in my opinion.
I'm going to tag this as a "new comer" bug for now. In my head, I'm thinking we might want this in a new library to separate out concerns. If you want to jump in, fork this library and build it. We'll consider merging it down the road if needed.
--Jake
Hi, I'm trying to use your package with node 8 but it seems imports / exports are not supported. I tried using node 12 but I still get the same error. Any advice ?
Thanks
/app/node_modules/phea/phea.js:3
import PheaEngine from './src/phea-engine';
^^^^^^^^^^
SyntaxError: Unexpected identifier
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:617:28)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/app/index.js:5:14)
Edit : it seems the version available on the npm registry is not up to date compared to github
First of all, awesome work on this!
But my lights won't seem to change. I've tried the basic example and everything seems to work, apart from my lights actually changing color ๐
Am I the only one with problems? Any tips?
Hi there, can you adjust the brightness along with the color?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.