-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add methods to retrieve uptime and reboot bulb #63
base: master
Are you sure you want to change the base?
Conversation
@jasoncodes this looks awesome, thanks! I'll give it a try when I have the time. I wasn't aware about this functionality myself. Please bear with us as it might take quite some time until this progresses any further since @MariusRumpf has been taking time off the project. I've been given access to merge PR's but to be perfectly honest I don't feel comfortable doing that as I don't have enough information on if the develop branch should be part of the next npm release. And even if I did, I don't have the required keys to publish an npm release anyhow. The tests seem to be failing though due to an unexpected character and a linting error. You'll spot the errors with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a comment on the code diff but also check my previous comment. If possible, please also add some unit tests for the functionality. Although with the current project activity level I think they can be added later.
var low = buf.readUInt32LE(0); | ||
var high = buf.readUInt32LE(4); | ||
|
||
return (high * 2**32 + low) / 1.0E9; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The double **
here is giving issues on the tests. Please also make this line a separate function to help understand what happens here.
I tested this and both uptime and reboot seem to work. In case you're interested I merged this to master on my own fork and rebased my open PR's #60 and #61 on top of it. I also updated TypeScript typings and the interactive-cli.js example with the new functions. The stuff can be found here: https://github.com/ristomatti/node-lifx/tree/es2015-dev Note that this is a branch for my own use of the library mainly with Node-RED. |
@jasoncodes Forgot to ask if you know what the uptime figure returned is? I get a floating point number which did not seem to make much sense. Also in case you want to try out my branch mentioned in my previous comment, note that it's based on my |
Tested with LIFX Original.
I use these to monitor device uptime and reboot the bulb when connection to the cloud is lost and does not automatically reconnect.
The uptime call is officially documented. The reboot request packet was found via the no longer supported Ruby gem. The reboot response packet was found via a packet capture.