Code Monkey home page Code Monkey logo

node-phea's People

Contributors

ahadcove avatar dependabot[bot] avatar durss avatar jakebednard avatar xadh00m avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

node-phea's Issues

Gradient Lightstrip Zones

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.

Docs on how extension should be done

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!

Don't throw error when closing socket

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

.on("close", () => {
let msg = new Error("PHEA - DTLS: Socket Closed");
msg.code = 'PHEA.HUE_DTLS_CONTROLLER.SOCKET_CLOSED';
throw msg;
});

Thanks

Using this in a nodeAPI

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.

Add feature to launch PHEA as HTTP Server

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

import error

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

Cannot get the lights to change

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?

Brightness

Hi there, can you adjust the brightness along with the color?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.