Skip to content
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

Improved the interactive-cli #28

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

mabels
Copy link
Contributor

@mabels mabels commented Jan 4, 2020

To enable multicharacter command.
Build a small repl.
Added two new api calls

console.log('Press u to request uptime from all lights');
console.log('Press r to reboot all lights');
console.log('Press 0 to exit\n');

process.stdin.setEncoding('utf8');
process.stdin.setRawMode(true);
const rl = readline.createInterface({
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we name this variable commandLineInterface instead of rl? Without seeing where it's defined, I'd be lost as to what it is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix but it is still a test progam.

'majorVersion',
'minorVersion'
]));
}, sqnNumber);
};
Light.prototype.getWifiFirmware = Light.prototype.getWifiVersion;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the rename?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Lifx Api name is getWifiFirmware.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This library is not supposed to be the LIFX API but a library to interface with it. I think this is just confusing. Confusing stuff does not belong in a usage example.

* @param {Boolean} [cache=false] return cached result if existent
* @return {Function} callback(err, group)
*/
Light.prototype.getGroup = function(callback, cache) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't realize this was missing. Nice addition!

@@ -130,6 +144,54 @@ process.stdin.on('data', function(key) {
} else if (key === '9') {
client.setDebug(false);
console.log('Debug messages are hidden');
} else if (key === 'hf') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you add all these shortcuts because you've found them useful? I'm not using this in the CLI, only via Node.js, so if it's useful to you, it's fine to add them.

Technically, this entire CLI section could be moved to its own project right? We could create this as a monorepo and add it there. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to move it out might be a good idea. And than build the cli tool from ground up again.

@ristomatti
Copy link
Collaborator

ristomatti commented Feb 11, 2020 via email

@mabels
Copy link
Contributor Author

mabels commented Feb 12, 2020

I have created a CLI tool for controlling the lights. It's pretty neat but lags a lot of features as I haven't used it much lately now that I'm primarily using Milight/Miboxer remote controllers for my lights (they're a match made in heaven for LIFX if you're willing to hook up a cheap NRF24L01 radio to an ESP8266 to act as a hub that connects to Node-RED) . You can find my interactive cli tool as lifxsh in npm. It might not be the latest version though so I'd check my GitHub instead. https://github.com/ristomatti/lifxsh Edit: I see it's still even using my old node-lifx fork which was used as the basis. PR updating it to use this one would be appreciated. Biggest annoyance currently is that autocomplete of light names does not support light names but they'll need to be given in quotes manually. I've also noticed the 'list' command gives proper values only after started. I guess I didn't implement any polling. It was for personal use and I did indeeed use it as such for several years. :)

On Tue, 11 Feb 2020 11:01 Kevin Ghadyani, @.*> wrote: @Sawtaytoes commented on this pull request. ------------------------------ In example/interactive-cli.js <#28 (comment)> : > console.log('Press u to request uptime from all lights'); console.log('Press r to reboot all lights'); console.log('Press 0 to exit\n'); -process.stdin.setEncoding('utf8'); -process.stdin.setRawMode(true); +const rl = readline.createInterface({ Could we name this variable commandLineInterface instead of rl? Without seeing where it's defined, I'd be lost as to what it is. ------------------------------ In src/lifx/light.js <#28 (comment)> : > 'majorVersion', 'minorVersion' ])); }, sqnNumber); }; +Light.prototype.getWifiFirmware = Light.prototype.getWifiVersion; Why the rename? ------------------------------ In src/lifx/light.js <#28 (comment)> : > + } + return callback(null, pick(msg, [ + 'location', + 'label', + 'updatedAt' + ])); + }, sqnNumber); +}; + +/ + * Requests the group of the light + * @param {Function} callback a function to accept the data + * @param {Boolean} [cache=false] return cached result if existent + * @return {Function} callback(err, group) + */ +Light.prototype.getGroup = function(callback, cache) { Didn't realize this was missing. Nice addition! ------------------------------ In example/interactive-cli.js <#28 (comment)> : > @@ -130,6 +144,54 @@ process.stdin.on('data', function(key) { } else if (key === '9') { client.setDebug(false); console.log('Debug messages are hidden'); + } else if (key === 'hf') { Did you add all these shortcuts because you've found them useful? I'm not using this in the CLI, only via Node.js, so if it's useful to you, it's fine to add them. Technically, this entire CLI section could be moved to its own project right? We could create this as a monorepo and add it there. What do you think? — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#28?email_source=notifications&email_token=ACE4SM7VXXQIC5MKTAE5A6LRCJSOFA5CNFSM4KCX4J32YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCU7ZYWY#pullrequestreview-356490331>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACE4SM46ZI2DZMWPYJV42TDRCJSOFANCNFSM4KCX4J3Q .

I have created a CLI tool for controlling the lights. It's pretty neat but lags a lot of features as I haven't used it much lately now that I'm primarily using Milight/Miboxer remote controllers for my lights (they're a match made in heaven for LIFX if you're willing to hook up a cheap NRF24L01 radio to an ESP8266 to act as a hub that connects to Node-RED) . You can find my interactive cli tool as lifxsh in npm. It might not be the latest version though so I'd check my GitHub instead. https://github.com/ristomatti/lifxsh Edit: I see it's still even using my old node-lifx fork which was used as the basis. PR updating it to use this one would be appreciated. Biggest annoyance currently is that autocomplete of light names does not support light names but they'll need to be given in quotes manually. I've also noticed the 'list' command gives proper values only after started. I guess I didn't implement any polling. It was for personal use and I did indeeed use it as such for several years. :)

On Tue, 11 Feb 2020 11:01 Kevin Ghadyani, @.*> wrote: @Sawtaytoes commented on this pull request. ------------------------------ In example/interactive-cli.js <#28 (comment)> : > console.log('Press u to request uptime from all lights'); console.log('Press r to reboot all lights'); console.log('Press 0 to exit\n'); -process.stdin.setEncoding('utf8'); -process.stdin.setRawMode(true); +const rl = readline.createInterface({ Could we name this variable commandLineInterface instead of rl? Without seeing where it's defined, I'd be lost as to what it is. ------------------------------ In src/lifx/light.js <#28 (comment)> : > 'majorVersion', 'minorVersion' ])); }, sqnNumber); }; +Light.prototype.getWifiFirmware = Light.prototype.getWifiVersion; Why the rename? ------------------------------ In src/lifx/light.js <#28 (comment)> : > + } + return callback(null, pick(msg, [ + 'location', + 'label', + 'updatedAt' + ])); + }, sqnNumber); +}; + +/ + * Requests the group of the light + * @param {Function} callback a function to accept the data + * @param {Boolean} [cache=false] return cached result if existent + * @return {Function} callback(err, group) + */ +Light.prototype.getGroup = function(callback, cache) { Didn't realize this was missing. Nice addition! ------------------------------ In example/interactive-cli.js <#28 (comment)> : > @@ -130,6 +144,54 @@ process.stdin.on('data', function(key) { } else if (key === '9') { client.setDebug(false); console.log('Debug messages are hidden'); + } else if (key === 'hf') { Did you add all these shortcuts because you've found them useful? I'm not using this in the CLI, only via Node.js, so if it's useful to you, it's fine to add them. Technically, this entire CLI section could be moved to its own project right? We could create this as a monorepo and add it there. What do you think? — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#28?email_source=notifications&email_token=ACE4SM7VXXQIC5MKTAE5A6LRCJSOFA5CNFSM4KCX4J32YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCU7ZYWY#pullrequestreview-356490331>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACE4SM46ZI2DZMWPYJV42TDRCJSOFANCNFSM4KCX4J3Q .

As said to have a nice cli client is not need on my opion. I missused the example to test my implementation of an lifx-clone on esps.
https://github.com/mabels/my-esp-home/blob/master/mam-wl/lifx-light.h
So there are no other motivation than support me during the development of an other component.

@ristomatti
Copy link
Collaborator

@mabels Sorry for the shitty reply, I had no idea reply from email would create all that garbage. Your project looks interesting though. I've been playing around with the idea of creating an independent ESP based LIFX controller plenty of times. I guess this is the other way round though, attempting to emulate a LIFX light using Neopixels?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants