Git Product home page Git Product logo

node-lifx-lan's People

Contributors

furey avatar futomi avatar nikteg avatar paddy2k avatar r1ch avatar ricpar11 avatar sansnickel avatar vancoding 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  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  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-lifx-lan's Issues

Duration Cannot Be >65,535

First, love this library, it's amazing!

The documentation for LifxLan states that the duration is an unsigned 32-bit integer with a maximum value of 4,294,967,295 for regular turnOn commands.

It looks in lifx-lan-composer.js has several methods to calculate the maximum value for duration.

102:
  typeof(duration) !== 'number' || duration % 1 !== 0 || duration < 0 || duration > 65535
117:
  typeof(v) === 'number' && v % 1 === 0 && v >= 0 && v <= 0xffffffff
501:
  typeof(v) === 'number' && v % 1 === 0 && v >= 0 && v <= 0xffffffff
715:
  typeof(duration) !== 'number' || duration % 1 !== 0 || duration < 0 || duration > 65535
508
  typeof(duration) !== 'number' || duration % 1 !== 0 || duration < 0 || duration > Math.pow(2, 64)

The maximum values set in this library do not match LIFX support maximum values.

PR incoming as soon as I figure out how to pull :)

Broadcast addrerss is not being set correctly for /26 netmask

I have a network with a netmask of 255.255.255.192, and it seems as though the broadcast address isn't being set correctly.

Stepping though the code, it looks like my broadcast address is being set to the same address as my local IP - and so no discovery is working...

Repeat Discover Error - "Error: send EACCES "

Hi,

When running my initial discovery of LIFX bulbs this library always works perfectly, however on the second check (test at both 1m and 10m later), it consistently causes the following error and never returns the object of devices. My bulbs are not on 255.

Error: send EACCES 192.168.0.255:56700
    at doSend (dgram.js:683:16)
    at defaultTriggerAsyncIdScope (internal/async_hooks.js:313:12)
    at afterDns (dgram.js:629:5)
    at processTicksAndRejections (internal/process/task_queues.js:85:21)
    at runNextTicks (internal/process/task_queues.js:66:3)
    at processTimers (internal/timers.js:489:9) {
  errno: 'EACCES',
  code: 'EACCES',
  syscall: 'send',
  address: '192.168.0.255',
  port: 56700
}

Does anyone have any suggestions what may be causing this?

Timeout on createDevice: no wait parameter

In a busy (32 devices) environment on a slow machine (a raspberry pi 3), I am seeing Timeout errors on createDevice (see below). When the LIFX is run in a non-busy environment (ie in the test module, where the only device is the LIFX bulb), no Timeout errors are encountered - but there is no wait parameter on the createDevice call (like the wait parameter on the Discover method) - is it possible to adjust the Timeout without calling Discover?

createDevice error Error: Timeout
at Timeout.setTimeout [as _onTimeout] (/home/pi/MyHouse/node_modules/node-lifx-lan/lib/lifx-lan-udp.js:127:12)
at ontimeout (timers.js:498:11)
at tryOnTimeout (timers.js:323:5)
at Timer.listOnTimeout (timers.js:290:5)

Toggle Power Function

Hi there! First off just wanna say what a great library you've created and functions incredibly well. This isn't actually an issue, more of a help/feature request.

I was just wondering if there's any way the LAN API can be implemented to toggle ALL lights (Similar to the HTTP method that LIFX has for the cloud, and similar to broadcastOn and broadcastOff functions).

Currently I'm doing this by running an interval to run Lifx.discover() and check if any lights are on, and when my action (clapping) occurs it can just check a variable. This however seems somewhat inefficient, specially with how long discover can take. Is there anyway of doing this?

CreateDevice

Ignore -- found it was my bug. Wrong IP address.

But I want to put in a strong plug for TypeScript -- it makes use of the library far easier and more readable.

Question - how to create morph effect

Wow, thanks for this package. It helps alot with the LAN protocol.

I have Lifx tiles and I would like to have dark blue and magenta colors morph with each other using the morph effect.

I was able to successfully use the lightSetWaveForm method on my tiles from your example code snippet. But I am still a bit stumped on how to create a morph effect with just two colors from this library.

Any suggestions?

Activating scenes

Thanks for this library, it is working great for me so far and the API is intuitive. But I cannot figure out how to activate scenes like is possible with the HTTP API.

Is this something that can be done with the LAN protocol without manually re-creating the scene settings?

Multiple cresteDevice even after destroy.

If you do:

Lifx.createDevice({
      mac: context.result.mac,
      ip: context.result.host
    })
    .then(device => {
        device.turnOn()
    })
    .then(() => {
        Lifx.destroy()
    })

Twice, not at the same time, you get the following error.

info: Feathers application started on http://localhost:3030
/Users/marcgodard/GitHub/remote-api/node_modules/node-lifx-lan/lib/lifx-lan-udp.js:37
				this._udp.unref()
				          ^

TypeError: Cannot read property 'unref' of null
    at Socket._udp.close (/Users/marcgodard/GitHub/remote-api/node_modules/node-lifx-lan/lib/lifx-lan-udp.js:37:15)
    at Socket.emit (events.js:185:15)
    at socketCloseNT (dgram.js:527:8)
    at process._tickCallback (internal/process/next_tick.js:114:19)

Possibly the destroy doesn't work if you used createDevice ?

Here is another stack trace:

TypeError: Cannot read property 'unref' of null
    at Promise (/Users/marcgodard/GitHub/remote-api/node_modules/node-lifx-lan/lib/lifx-lan-udp.js:42:14)
    at new Promise (<anonymous>)
    at LifxLanUdp.destroy (/Users/marcgodard/GitHub/remote-api/node_modules/node-lifx-lan/lib/lifx-lan-udp.js:34:16)
    at Promise (/Users/marcgodard/GitHub/remote-api/node_modules/node-lifx-lan/lib/lifx-lan.js:886:12)
    at new Promise (<anonymous>)
    at LifxLan.destroy (/Users/marcgodard/GitHub/remote-api/node_modules/node-lifx-lan/lib/lifx-lan.js:885:16)
    at lifxkService.patch.then.completeObj (/Users/marcgodard/GitHub/remote-api/src/services/lifx/lifx-status.js:44:25)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:118:7)

Tile support

Hi! This is a great lib. Don't think I could've gotten going with out it. I'm trying to program some Tile lights. The basic apis work appropriately, but the actual Tile requests fail. I've tried extending the library doing the following, but I'm getting errors across the board.

LifxLanDevice.prototype.tileGetDeviceChain = function(params) {
  return this._request(701, params);
};

LifxLanDevice.prototype.tileStateDeviceChain = function(params) {
  return this._request(702, params);
};

LifxLanDevice.prototype.tileSetUserPosition = function(params) {
  return this._request(703, params);
};

LifxLanDevice.prototype.tileGetTileState64 = function(params) {
  return this._request(707, params);
};

LifxLanDevice.prototype.tileStateTileState64 = function(params) {
  return this._request(711, params);
};

LifxLanDevice.prototype.tileSetTileState64 = function(params) {
  return this._request(715, params);
};

Any Ideas!?
Thanks in advance :)

Missing dgram dependency

Attempting to run this in an Angular application fails due to dgram dependency:

ERROR in ./node_modules/node-lifx-lan/lib/lifx-lan.js
Module not found: Error: Can't resolve 'dgram' in 'C:\dev\control\node_modules\node-lifx-lan\lib'
ERROR in ./node_modules/node-lifx-lan/lib/lifx-lan-udp.js
Module not found: Error: Can't resolve 'dgram' in 'C:\dev\control\node_modules\node-lifx-lan\lib'

This package appears to have been removed from npm: https://www.npmjs.com/package/dgram

multiZoneSetColorZones() does not support CSS (as per LifxLanColor)

Hi,

I've been trying to use the multiZoneSetColorZones() that should accept as color the class LifxLanColor.

It looks like the color property is not transformed properly as it only accepts LifxLanColorHSB objects. I've been trying to use LifxLanColorCSS without success.

Example:

device.multiZoneSetColorZones({
     start    : 0,
     end      : 8,
     color    :  { css: "#ff0000" },
     duration : 0,
     apply    : 1
   })

Error:

(node:61955) UnhandledPromiseRejectionWarning: Error: The `color.hue` is required.
    at LifxLanComposer._checkColorValues (/Users/paolo/Downloads/node-lifx-lan-master/node_modules/node-lifx-lan/lib/lifx-lan-composer.js:414:12)
    at LifxLanComposer._composePayload501 (/Users/paolo/Downloads/node-lifx-lan-master/node_modules/node-lifx-lan/lib/lifx-lan-composer.js:652:29)
    at LifxLanComposer._composePayload (/Users/paolo/Downloads/node-lifx-lan-master/node_modules/node-lifx-lan/lib/lifx-lan-composer.js:135:15)
    at LifxLanComposer.compose (/Users/paolo/Downloads/node-lifx-lan-master/node_modules/node-lifx-lan/lib/lifx-lan-composer.js:44:33)
    at Promise (/Users/paolo/Downloads/node-lifx-lan-master/node_modules/node-lifx-lan/lib/lifx-lan-udp.js:131:26)
    at new Promise (<anonymous>)
    at LifxLanUdp._requestUnicast (/Users/paolo/Downloads/node-lifx-lan-master/node_modules/node-lifx-lan/lib/lifx-lan-udp.js:118:16)
    at Promise (/Users/paolo/Downloads/node-lifx-lan-master/node_modules/node-lifx-lan/lib/lifx-lan-udp.js:107:9)
    at new Promise (<anonymous>)
    at LifxLanUdp.request (/Users/paolo/Downloads/node-lifx-lan-master/node_modules/node-lifx-lan/lib/lifx-lan-udp.js:92:16)

it won't install ENOSELF error

looks like something is not named right
i keep on getting ENOSELF error how do i get it to install do i need to rename of the files in the zip?

from the log
25 verbose npm v6.14.10
26 error code ENOSELF
27 error Refusing to install package with name "node-lifx-lan" under a package
27 error also called "node-lifx-lan". Did you name your project the same
27 error as the dependency you're installing?
27 error

Add SKU to products.json (LIFX Mini variant?)

I have a LIFX Mini (productID 59) that's not properly loaded since products.json doesn't include its metadata. However, LIFX doesn't include this product ID in their API documentation. I'm not sure if this is an updated SKU or variant of LIFX Mini (productID 49). The bulb was purchased as part of their multi-pack so maybe it's defined as a separate product ID? Let me know if I should include any additional info about the light.

Model # L3A19MC08E26

Here's the payload from LifxLanParser._parsePayload (without modifying products.json):

{ vendorId: 1,
  vendorName: 'LIFX',
  productId: 59,
  productName: '',
  hwVersion: 0,
  features: null }

I'm currently working around this by appending the following in products.json:

{
  "pid": 59,
  "name": "LIFX Mini",
  "features": {
    "color": true,
    "infrared": false,
    "multizone": false
  }
}

Use LifxLanDevice directly?

Is it possible to store the device ip and mac then just make calls without the discovery process?

Will attempt it and report back.

createDevice

Hi Guys, I'm having an issue to create multiple lights using the createDevice function

for(let index = 0; index < nfixtures; index++){

Lifx.createDevice({
  mac: lifx_mac[index],
  ip: lifx_ip[index]
}).then((dev) => {
  pixels[index] = dev;
  console.log('Pixel' + index + " created.");

}).catch((error) =>{
  console.log("ERROR:" + error);
});

}

When the loop is executed just the first light is created with the remain lights i got this error: "Error: bind EADDRINUSE 0.0.0.0:56700"

No longer working with Node.js 10

Sadly, when running this with Node.js 10, buffer.readUIntLE(offset, 8) throws an exception about only accepting byte lengths up to 6.

I don't know the reason for this change, but it's probably to make sure that there are no overflows because JavaScript does not support int64 values.

But since this was never a problem before, I think it's safe work around this instead of switching an int64 library.

No Lights in Device List

For some reason, I'm not seeing any lights show up when I do a discover. I have 113 LIFX lights. All of them show up in the Windows Universal app and the LIFX Android app. Surprisingly, the exact same code runs correctly on my Raspberry Pi 3. What's up with that?

Tested using Node v8.8.1 to v8.11.3.

Cannot use more than one instances at a time

So when I now use the createDevice more than one at a time...

So what my app does is scan my network, get all ip and mac addresses of all devices, then does mac look ups to know what device is what, then confirms that by connecting to them. (I have many smart devices and building a central script to control them all)

The problem is is that I have 2 lifx lights (and will be getting more). So it calls one after the other (as it discovers the IP / Mac / Company) so therefore, crashes because there is already an instance confirming the first one.

The solution I have seen for this before is using a different output port for each connection. Not sure if that would work for this.

I can rejig my app to discover using the other way of discovering and only caring of the first lifx device for now (but will return an incomplete list this way), however, a flag to know if there is already an instance, or maybe use a random open out port will work?

Sorry for the long post.

discover stops working if first calling on different network than the one with lifx devices on it

So, i have two networks in my office (let's call them A and B. B has lifx devices set up, A does not). If I make a call to discover() while connected to A, I'll see no devices, which is expected. But if I change the network to B, and then repeat the discover() call, I still won't see any devices, but I'd expect it to find them now that I'm connected to B. I've even tried setting the library variable to null, and repeating the require() call after changing to B, but i get the same result. I've also tried not only repeating the required call, but dereferencing the require cache, and I get the same result. I also tried using https://github.com/sindresorhus/import-fresh, and same result.

Note that if the first discover call happens while connected to B, then I change to A, call discover, then change back to B, the devices show up okay.

It's as if the discover call "locks" somehow to whatever network happens to be connected at the time.

Here's some more system info:

  • library version: 0.3.1
  • node version: v10.16.0
  • OS: Windows 10 Pro (Version 1809)

WSL

Sorry, the issue was in another package.

bind EADDRINUSE 0.0.0.0:56700

Trying to run the following;

// Create a LifxLan object
const Lifx=require('node-lifx-lan')

Lifx.discover().then((device_list) => {
device_list.forEach((device) => {
console.log([
device['ip'],
device['mac'],
device['deviceInfo']['label']
].join(' | '));
});
}).catch((error) => {
console.error(error);
});

and keep getting - Error: bind EADDRINUSE 0.0.0.0:56700

Any help appreciated

Custom Wave Animation

Hi ! First I have to tell you that this is a great library.
I'm trying to update de color using a custom wave form instead of the "WaveForm" feature that comes with the API, but when I try to update the color ( i'm just changing the brightness), the fixture starts to flicker. I' m updating the brightness each 1ms.

If increase the time between each update (each 500ms) it works, but is not a smooth change. Any suggestions? I'm new working with node js, so i don't know if I'm updating properly the color on the Fixture, I use a "setInterval" function to update it.

Thank you.

Unwanted network interface used for discovery

On the host I'm using node-lifx-lan with, I have two network interfaces. LifxLanAddress.get returns the address for the unwanted network (the network without LIFX devices). This is due to LifxLanAddress.get defaulting to the network interface with the higher netmask/mask_bit_num. In my case, /24 for the unwanted interface and /16 for the wanted interface.

Could logic be added to perform discovery on all found network interfaces? Maybe add an option to restrict to a specific interface?

I added some debugging to the code to illustrate. The 172.25.1.0 network is the unwanted interface, the 10.10.0.0 is the wanted interface.

> require('node-lifx-lan').discover()
lifx-lan-address.js line 52 { network_address: '10.10.0.0/16' }
lifx-lan-address.js line 53 { source_address: '10.10.1.104' }
lifx-lan-address.js line 54 { mask_bit_num_max: 16, mask_bit_num: 16 }
lifx-lan-address.js line 52 { network_address: '172.25.1.0/24' }
lifx-lan-address.js line 53 { source_address: '172.25.1.7' }
lifx-lan-address.js line 54 { mask_bit_num_max: 24, mask_bit_num: 24 }
lifx-lan-address.js line 64 (LifxLanAddress.get return): { source: '172.25.1.7',
  network: '172.25.1.0/24',
  broadcast: '172.25.1.255' }

Takes forever to load lights list

I was noticing this library takes forever to load my lights list vs the node-lifx package. I figured it might be because node-lifx gives you lights as it finds them whereas node-lifx-lan gives the final device list at the end. I have 113 LIFX lights with more coming in the future. I think the problem occurs because it takes so long to find all of them in my network.

I think I tracked the problem down to lifx-lan-udp.js where it's setting up timers and waits.

Is it possible we could have another .discover method that's async and rename this one to discoverSync similar to Node.js native libraries?

NOTE: I tested this library on a Raspberry Pi running Raspbian.

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.