Skip to content

added the TileApi to control real colorful lifx tiles#15

Closed
mabels wants to merge 4 commits intonode-lifx:masterfrom
mabels:master
Closed

added the TileApi to control real colorful lifx tiles#15
mabels wants to merge 4 commits intonode-lifx:masterfrom
mabels:master

Conversation

@mabels
Copy link
Copy Markdown
Contributor

@mabels mabels commented Sep 13, 2019

I need to cleanup this PR some sanity checks are missing and
i was to lazy to build the tests.
I promise that I complete this missing stuff in the next weeks.
This PR is just an reminder to me that i had to completed this!

@ristomatti
Copy link
Copy Markdown
Collaborator

@mabels Based on a quick skim, your PR looks very promising! When finalising the work, please remember to:

  • update README.md
  • follow .eslintrc

Also note that you can use arrow functions even though it's not used much if at all on the existing codebase (the ES2015 rewrite was done quite literally overnight). At least I would prefer arrow functions especially when passing an inline function as a parameter. I can't speak for @Sawtaytoes though who set up this fork though.

@mabels mabels force-pushed the master branch 2 times, most recently from acad593 to 88691bb Compare September 23, 2019 09:40
@mabels mabels marked this pull request as ready for review September 23, 2019 09:41
@mabels
Copy link
Copy Markdown
Contributor Author

mabels commented Sep 23, 2019

Hi,

just completed this including tests. There had been 2 other pull request which should applied first.

#16
#17

Thx in advance

@ristomatti
Copy link
Copy Markdown
Collaborator

Massive undertaking. I'll try to review and test this as soon as possible. Sorry if it might take a couple of days! I do have a Tile set to test though.

@ristomatti
Copy link
Copy Markdown
Collaborator

@mabels I'm sorry I haven't still had time to review and test this. Just letting you know I haven't forgot this! I just noticed a PR submitted to node-lifx-lan a couple of days ago and it'd be cool to have this merged before that. 😂 The problem is though that I'm quite busy today and away from home the rest of the weekend. I'll try to find time today but it doesn't look too good.

@ristomatti ristomatti self-requested a review October 4, 2019 16:33
@ristomatti
Copy link
Copy Markdown
Collaborator

@mabels BTW just noticed there seems to be a conflict due to merging your previous PR #17.

@ristomatti
Copy link
Copy Markdown
Collaborator

My plans for today/tomorrow got cancelled. I'll at least start reviewing/testing now.

@ristomatti
Copy link
Copy Markdown
Collaborator

@mabels All you need to do to fix the conflict is to drop the already merged commits 3de27da and
1cca93a and then rebase to upstream master.

@ristomatti
Copy link
Copy Markdown
Collaborator

It's actually not a good idea to review the code at it's current state as it contains the already merged changes. @mabels could you update your branch and force push the changes? I'll still test now if I get it to work with my Tiles.

@ristomatti
Copy link
Copy Markdown
Collaborator

Sorry a somewhat off-topic note:

Also note that you can use arrow functions even though it's not used much if at all on the existing codebase (the ES2015 rewrite was done quite literally overnight). At least I would prefer arrow functions especially when passing an inline function as a parameter. I can't speak for @Sawtaytoes though who set up this fork though.

Quoting myself - now when I started to review the changes @mabels has done, I realize there's still two open PR's from me that's aren't included in this repo. When commenting about the arrow functions, I had an odd feeling like I would have done "something" to that already: MariusRumpf/node-lifx#62. This is the rewrite I was talking about.

@Sawtaytoes It looks like I forgot PR 62 completely. Would it make sense for me to try to rebase it and do a PR? Or do you prefer working without the use of classes. I've personally been leaning towards more functinal programming approach (mainly at work) but I think using classes would make sense given how the library is written. There'd be a lot less clutter.

Copy link
Copy Markdown
Collaborator

@ristomatti ristomatti left a comment

Choose a reason for hiding this comment

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

@mabels Added a couple of comments but I'll check the other changes after you've rebased the branch.

@Sawtaytoes
Copy link
Copy Markdown
Collaborator

Sawtaytoes commented Oct 6, 2019

Sorry a somewhat off-topic note:

Also note that you can use arrow functions even though it's not used much if at all on the existing codebase (the ES2015 rewrite was done quite literally overnight). At least I would prefer arrow functions especially when passing an inline function as a parameter. I can't speak for @Sawtaytoes though who set up this fork though.

Quoting myself - now when I started to review the changes @mabels has done, I realize there's still two open PR's from me that's aren't included in this repo. When commenting about the arrow functions, I had an odd feeling like I would have done "something" to that already: MariusRumpf/node-lifx#62. This is the rewrite I was talking about.

@Sawtaytoes It looks like I forgot PR 62 completely. Would it make sense for me to try to rebase it and do a PR? Or do you prefer working without the use of classes. I've personally been leaning towards more functinal programming approach (mainly at work) but I think using classes would make sense given how the library is written. There'd be a lot less clutter.

Whatever your preference is fine. I think bringing in those old PRs from your other repo would be fantastic!

I also like arrow functions. As long as our Node.js compatibility is fine, then we're good to go; otherwise, we should just bring up the min Node.js version and everything will be easier going forward.

@mabels
Copy link
Copy Markdown
Contributor Author

mabels commented Oct 7, 2019

Node and Arrowfunctions:

for i in boron carbon dubnium   ST 1   master
do
nvm run lts/$i -e '(() => console.log(process.versions.node))()'
done
Running node v6.17.1 (npm v3.10.10)
Running node v8.16.1 (npm v6.4.1)
Running node v10.16.3 (npm v6.11.3)

we should never go to 4.x so on my expirence we are fine.
We could also rewrite arrow functions with babel

@mabels
Copy link
Copy Markdown
Contributor Author

mabels commented Oct 7, 2019

Sorry a somewhat off-topic note:

Also note that you can use arrow functions even though it's not used much if at all on the existing codebase (the ES2015 rewrite was done quite literally overnight). At least I would prefer arrow functions especially when passing an inline function as a parameter. I can't speak for @Sawtaytoes though who set up this fork though.

Quoting myself - now when I started to review the changes @mabels has done, I realize there's still two open PR's from me that's aren't included in this repo. When commenting about the arrow functions, I had an odd feeling like I would have done "something" to that already: MariusRumpf/node-lifx#62. This is the rewrite I was talking about.
@Sawtaytoes It looks like I forgot PR 62 completely. Would it make sense for me to try to rebase it and do a PR? Or do you prefer working without the use of classes. I've personally been leaning towards more functinal programming approach (mainly at work) but I think using classes would make sense given how the library is written. There'd be a lot less clutter.

Whatever your preference is fine. I think bringing in those old PRs from your other repo would be fantastic!

I also like arrow functions. As long as our Node.js compatibility is fine, then we're good to go; otherwise, we should just bring up the min Node.js version and everything will be easier going forward.

we should integrate "Arrow functions completly" after this PR is on master.
I offer my help.

@mabels mabels requested a review from ristomatti October 9, 2019 10:26
Copy link
Copy Markdown
Collaborator

@ristomatti ristomatti left a comment

Choose a reason for hiding this comment

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

Added few comments. My JS limit for today has maxed out now though. I'll see if I could get this running tomorrow or Sunday.

console.log('New light found.');
console.log('ID: ' + light.id);

light.getDeviceChain(function(err, chain) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This would now attempt to call setTileState64 on any light. Add a const TILE_LABEL = 'MyTile'; and trigger only on a light matching the label.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This does not work as light label has not resolved at this point. It was partly my bad as I didn't remember this while reviewing this the first time. It would improve the example a lot if a label could be used but for this purpose it would be enough to just rename TILE_LABEL TO TILE_LIGHT_ID for example.

@Sawtaytoes
Copy link
Copy Markdown
Collaborator

@mabels @ristomatti Just your friendly neighborhood ping :).

@ristomatti
Copy link
Copy Markdown
Collaborator

@mabels @ristomatti Just your friendly neighborhood ping :).

I'm still waiting for @mabels. I guess eventually I could try sorting the issues myself but haven't had time to think about this too much unfortunately.

On a related note, I ran across this stuff that's based on the "competing" node-lifx-lan lib that looked pretty cool. Haven't tested it though:

object and callback.
removed validation clutter from set/getTileState64
added some comments in the example
@ristomatti
Copy link
Copy Markdown
Collaborator

Thanks @mabels. I will check and test this later today (= within the next 12 hours). If I won't, you're welcome to merge this @Sawtaytoes.

@Sawtaytoes
Copy link
Copy Markdown
Collaborator

@ristomatti Merging in 1 hour.

@ristomatti
Copy link
Copy Markdown
Collaborator

ristomatti commented Dec 12, 2019

@Sawtaytoes Thanks for the heads-up (although I saw it only just now). Sadly I was blocked by a force majeure.

Would it be possible for me to email or PM you on this? You can find my email from my commit messages. Your location indicates you're 8 hours behind but I'm a night owl so there should be plenty of hours reach me.

@ristomatti
Copy link
Copy Markdown
Collaborator

Impossible things can happen - testing now.

@ristomatti
Copy link
Copy Markdown
Collaborator

@mabels Did you test this after your changes? I can't get this to work. There's multiple issues. When running example/tile.js I got this:

$ node tile.js 
Started LIFX listening on 0.0.0.0:49419

New light found.
ID: d073d5394495
/home/ristomatti/Projects/lifx-lan-client/lib/lifx/light.js:657
  validate.isUint8(tileIndex, 'setTileState64', 'tileIndex');
           ^

TypeError: validate.isUint8 is not a function
    at Light.setTileState64 (/home/ristomatti/Projects/lifx-lan-client/lib/lifx/light.js:657:12)
    at setBits (/home/ristomatti/Projects/lifx-lan-client/example/tile.js:41:9)
    at /home/ristomatti/Projects/lifx-lan-client/example/tile.js:61:5
    at Client.<anonymous> (/home/ristomatti/Projects/lifx-lan-client/lib/lifx/light.js:534:12)

After replacing renaming 3 calls to validate.isUint8 with validate.isUInt8 it crashed like so:

$ node tile.js 
Started LIFX listening on 0.0.0.0:43892

New light found.
ID: d073d5394495
/home/ristomatti/Projects/lifx-lan-client/lib/lifx/utils.js:143
    throw new TypeError('LIFX util buildColorsHsbk expects colors to be an array');
    ^

TypeError: LIFX util buildColorsHsbk expects colors to be an array
    at Object.utils.buildColorsHsbk (/home/ristomatti/Projects/lifx-lan-client/lib/lifx/utils.js:143:11)
    at Light.setTileState64 (/home/ristomatti/Projects/lifx-lan-client/lib/lifx/light.js:671:27)
    at setBits (/home/ristomatti/Projects/lifx-lan-client/example/tile.js:41:9)
    at /home/ristomatti/Projects/lifx-lan-client/example/tile.js:61:5
    at Client.<anonymous> (/home/ristomatti/Projects/lifx-lan-client/lib/lifx/light.js:534:12)

@ristomatti
Copy link
Copy Markdown
Collaborator

@Sawtaytoes Sorry but this is not ready yet. I don't think we should rush this in as there might be other issues also. For instance README.md would need to be updated.

* @param {Number} tileIndex unsigned 8-bit integer
* @param {Number} userX 32-bit float
* @param {Number} userY 32-bit float
* @param {Number} reserved 16-bit integer
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What is this reserved value and how would a user of this library know what to put there? This applies to all functions.

@mabels
Copy link
Copy Markdown
Contributor Author

mabels commented Dec 14, 2019 via email

@mabels
Copy link
Copy Markdown
Contributor Author

mabels commented Dec 14, 2019

@mabels Did you test this after your changes? I can't get this to work. There's multiple issues. When running example/tile.js I got this:

$ node tile.js 
Started LIFX listening on 0.0.0.0:49419

New light found.
ID: d073d5394495
/home/ristomatti/Projects/lifx-lan-client/lib/lifx/light.js:657
  validate.isUint8(tileIndex, 'setTileState64', 'tileIndex');
           ^

TypeError: validate.isUint8 is not a function
    at Light.setTileState64 (/home/ristomatti/Projects/lifx-lan-client/lib/lifx/light.js:657:12)
    at setBits (/home/ristomatti/Projects/lifx-lan-client/example/tile.js:41:9)
    at /home/ristomatti/Projects/lifx-lan-client/example/tile.js:61:5
    at Client.<anonymous> (/home/ristomatti/Projects/lifx-lan-client/lib/lifx/light.js:534:12)

After replacing renaming 3 calls to validate.isUint8 with validate.isUInt8 it crashed like so:

$ node tile.js 
Started LIFX listening on 0.0.0.0:43892

New light found.
ID: d073d5394495
/home/ristomatti/Projects/lifx-lan-client/lib/lifx/utils.js:143
    throw new TypeError('LIFX util buildColorsHsbk expects colors to be an array');
    ^

TypeError: LIFX util buildColorsHsbk expects colors to be an array
    at Object.utils.buildColorsHsbk (/home/ristomatti/Projects/lifx-lan-client/lib/lifx/utils.js:143:11)
    at Light.setTileState64 (/home/ristomatti/Projects/lifx-lan-client/lib/lifx/light.js:671:27)
    at setBits (/home/ristomatti/Projects/lifx-lan-client/example/tile.js:41:9)
    at /home/ristomatti/Projects/lifx-lan-client/example/tile.js:61:5
    at Client.<anonymous> (/home/ristomatti/Projects/lifx-lan-client/lib/lifx/light.js:534:12)

I could not test this change off course i had no lifx on hand.
I will try this if i come back home in the next week.

@mabels
Copy link
Copy Markdown
Contributor Author

mabels commented Dec 14, 2019

@mabels Did you test this after your changes? I can't get this to work. There's multiple issues. When running example/tile.js I got this:

$ node tile.js 
Started LIFX listening on 0.0.0.0:49419

New light found.
ID: d073d5394495
/home/ristomatti/Projects/lifx-lan-client/lib/lifx/light.js:657
  validate.isUint8(tileIndex, 'setTileState64', 'tileIndex');
           ^

TypeError: validate.isUint8 is not a function
    at Light.setTileState64 (/home/ristomatti/Projects/lifx-lan-client/lib/lifx/light.js:657:12)
    at setBits (/home/ristomatti/Projects/lifx-lan-client/example/tile.js:41:9)
    at /home/ristomatti/Projects/lifx-lan-client/example/tile.js:61:5
    at Client.<anonymous> (/home/ristomatti/Projects/lifx-lan-client/lib/lifx/light.js:534:12)

After replacing renaming 3 calls to validate.isUint8 with validate.isUInt8 it crashed like so:

$ node tile.js 
Started LIFX listening on 0.0.0.0:43892

New light found.
ID: d073d5394495
/home/ristomatti/Projects/lifx-lan-client/lib/lifx/utils.js:143
    throw new TypeError('LIFX util buildColorsHsbk expects colors to be an array');
    ^

TypeError: LIFX util buildColorsHsbk expects colors to be an array
    at Object.utils.buildColorsHsbk (/home/ristomatti/Projects/lifx-lan-client/lib/lifx/utils.js:143:11)
    at Light.setTileState64 (/home/ristomatti/Projects/lifx-lan-client/lib/lifx/light.js:671:27)
    at setBits (/home/ristomatti/Projects/lifx-lan-client/example/tile.js:41:9)
    at /home/ristomatti/Projects/lifx-lan-client/example/tile.js:61:5
    at Client.<anonymous> (/home/ristomatti/Projects/lifx-lan-client/lib/lifx/light.js:534:12)

I could not test this change off course i had no lifx on hand.
I will try this if i come back home in the next week.

@mabels mabels closed this Dec 14, 2019
@mabels
Copy link
Copy Markdown
Contributor Author

mabels commented Dec 14, 2019

I need to build a test for the high order function. I'm sorry for this chain of failures.

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