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

Add Tile support #25

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

Add Tile support #25

wants to merge 10 commits into from

Conversation

mabels
Copy link
Contributor

@mabels mabels commented Dec 26, 2019

Hello,
i don't know why my previous PR was closed?
There was some tests missing which I added now, and I fixed the example program.

Could you please add these now?

object and callback.
removed validation clutter from set/getTileState64
added some comments in the example
- changed api of setUserPosition to args parsed by props object
  added full stack tests
- added full stack tests to getDeviceChain
- added full stack tests to setTileState64
- added full stack tests to getTileState64
chore: remove some comment clutter
@ristomatti
Copy link
Collaborator

@mabels I believe you closed it yourself. If not, then it was by mistake...

@mabels
Copy link
Contributor Author

mabels commented Jan 23, 2020

Yes might be my fault. Is there a change to get this merged?

@ristomatti
Copy link
Collaborator

Sorry @mabels. I haven't been able to give any time for my hobby projects. Life got in the way.

I'll try to find time during next week but can't promise. Notification of this stares me every day at the top of my inbox as a starred message.

Copy link
Collaborator

@Sawtaytoes Sawtaytoes left a comment

Choose a reason for hiding this comment

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

I wrote a few comments on some things I noticed, but a lot of this is pretty low-to-the-hardware UDP on how to get a device chain and send messages for the Tile API.

@ristomatti I think this is probably safe to merge. If you wanna do a quick skim, I'd feel more comfortable.

const client = new LifxClient();

const LOOPTIME = 1000;
const TILE_LABEL = process.argv.length > 2 ? process.argv[process.argv.length - 1] : '*';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we want this to come from the command line execution or could it be done differently? Also, there's a library yargs which makes it a lot easier to pull in command line parameters. If we're doing this in Node.js anyway, why not pull it in from a config when creating the LIFX client?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Agree on this one. At least the script should fail if run without arguments and instruct on the correct usage. Example:

Usage: node tile.js <label>, e.g. node tile.js "My Tiles"

setTimeout(() => setBits(light, 0, chain), LOOPTIME);
return;
}
console.log('getBits', idx);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this debugging info that needs to be removed? There are a few instances like these. Do we want to use console.info or console.debug instead? I always think of console.log statements as temporary for local development only.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it an test example programm, so why not 'log' that something is happens here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think these are fine, they indicate at least what part of the code is currently executing. They could of course be more informative as I'm suspecting the API might be quite difficult to graps for many.

@ristomatti
Copy link
Collaborator

I can do a quick test today with my Tile set. I'm on sick leave for the
rest of the month so I have time now, although not eager to do too much "work"
yet. Got "a bit" burnt out.

@Sawtaytoes If we go ahead and pull this in, it's OK for me to publish a release but I'd
still like to keep the feature in beta to allow refining the API with
breaking changes. I think it could be simplified but like you guys know I
haven't put much thought in it.

@ristomatti
Copy link
Collaborator

Pulling the changes now. 🤞

@ristomatti
Copy link
Collaborator

I got it to do what it is supposed to do I believe on my second try. First attempt (my Tile sets label is "Tile"):

 node tile.js Tile
Started LIFX listening on 0.0.0.0:47851

Tile d073d5015228
Tile d073d501a6cd
Tile d073d53dde96
Tile d073d53dadb6
Tile d073d501b5cd
Tile d073d53db8c7
Tile d073d501ed93
Tile d073d520a8d7
Tile d073d5204f17
Tile d073d514a6b6
Tile d073d501dd80
Tile d073d5313511
Tile d073d5313422
Tile d073d5394495

I checked the code, and it's trying to match against the light id and not label. So I then tried with the light id:

$ node tile.js d073d5394495
Started LIFX listening on 0.0.0.0:53290

d073d5394495 d073d514a6b6
d073d5394495 d073d5313511
d073d5394495 d073d5204f17
d073d5394495 d073d520a8d7
d073d5394495 d073d5313422
d073d5394495 d073d501ed93
d073d5394495 d073d53dadb6
d073d5394495 d073d501dd80
d073d5394495 d073d53ddb7a
d073d5394495 d073d53dde96
d073d5394495 d073d501a6cd
d073d5394495 d073d5015228
d073d5394495 d073d53db8c7
d073d5394495 d073d501b5cd
d073d5394495 d073d5394495
New light found.
ID: d073d5394495
setBits 0 5
setBits 1 5
setBits 2 5
setBits 3 5
setBits 4 5
getBits 0
getBits 1
getBits 2
getBits 3
getBits 4
All Bits get

End result was pastel shaded randomly changing gradients. Sounds reasonable?

Copy link
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.

I think we can merge this if you can:

  1. a) make this work with the light label and not the id (call light.getState for each found light to match against the label given by the user. OR
  2. b) make the script interactive, so that it will give a list of Tile's found using light.getHardwareVersion and allow selecting one by entering a number
  3. implement the other changes requested by me and @Sawtaytoes

This merge would be for further refinement. As there's no update on README.md, I'd vote for a only a change log comment "Experimental Tile support added" and leave the API undocumented in the README.

const client = new LifxClient();

const LOOPTIME = 1000;
const TILE_LABEL = process.argv.length > 2 ? process.argv[process.argv.length - 1] : '*';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Agree on this one. At least the script should fail if run without arguments and instruct on the correct usage. Example:

Usage: node tile.js <label>, e.g. node tile.js "My Tiles"

setTimeout(() => setBits(light, 0, chain), LOOPTIME);
return;
}
console.log('getBits', idx);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think these are fine, they indicate at least what part of the code is currently executing. They could of course be more informative as I'm suspecting the API might be quite difficult to graps for many.

}

client.on('light-new', (light) => {
console.log(TILE_LABEL, light.id);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove this console.log, it only prints out mysterious garbage of lights that aren't matching the given label (or in this case actually the id).

# Conflicts:
#	babelhook.js
#	src/lifx/light.js
#	test/unit/light-test.js
@ristomatti
Copy link
Collaborator

@mabels I managed to resurrect my problematic Tile set a while ago. I noticed you've kept these changes on your clone and even merged in some other updates. Have you been using the added functionality / has it worked throughout the 4 years of testing 😁?

@mabels
Copy link
Contributor Author

mabels commented Mar 14, 2024

I just looked into my HA and there is still this code -> and my tiles cheer me every day with some random patterns.
So my patches still working for me.

meno

@Sawtaytoes
Copy link
Collaborator

Yes! Please publish a release @ristomatti! :)

@ristomatti ristomatti changed the title Add TileSupport (again) Add Tile support Mar 16, 2024
@ristomatti
Copy link
Collaborator

@mabels I got the branch rebased to the point where tests pass but I'm hesitant to push the changes back as it's your master branch and I haven't even tested if everything works properly. That will need to wait for another day. It's 2:23 and I just ran the unit tests, forgetting there's that damn test that turns on all the lights (while my partner is asleep). 😬

@ristomatti ristomatti self-assigned this Mar 16, 2024
@ristomatti
Copy link
Collaborator

I've pushed the rebased branch here: feature/tile-support.

@ristomatti
Copy link
Collaborator

Finally when I'd be on vacation and would have had time to do this, my Tile set PSU dies.

I had just painstakingly* detached and reattached 4 of the tiles while debugging why they stopped working. This was only to find that the issue was actually a bad connection on the PSU end of the cable and the whole process was pointless. Just when I had tested the whole set works again, I then accidentally wiggled the connector while adjusting the power cable (with the set powered up). The connector started sparking. After I detached it, I realize the PSU is still sparking inside the connector. The magic smoke had escaped.

*) When detaching the tiles, 10 out of 16 of those 3M Dual Lock fasteners left the sticky side of the tape on the wall. I didn't have spare tape on hand so I had to super glue the detached locking half of each tape back before reattaching the tiles.

It looks like I'm not gonna find a replacement any time soon either. LIFX has ran out of stock of replacements and the PSU is completely custom built and not just any 24V power brick. It not only has a proprietary UC-E6 8-pin connector but it also sends a 50-60Hz 3.3V square wave "ID signal" through one of the wires. There's even this 4 year old thread on Reddit on building a custom power supply, including tips from LIFX employees but it appears no one has been able to succeed getting more than one Tile working this way.

I might give that a shot at some point though as I happen to have the required gear to do it, but first I'll need to source a cable with a female UC-E6 connector in order to even check if the Tile's got damaged in the process also.

At the end of the day, I even looked up if I could find a used or new complete Tile set but they seem to have been hunted to extinction.

phrkr7000 @ /r/lifx 1y ago:

I searched Facebook Marketplace, eBay, and Kijiji regularly over the past 2 years and I have purchased 12 boxes of the LIFX Tile in total.

I can no longer find any used boxes for sale, and I believe I have snatched up all the remaining available boxes.

Sorry everyone.

I'll end this comment with another quote.

System_Virus @ /r/lifx 7mo ago

I came here looking for a replacement power supply, and this is what I find? What the fuck are you guys even talking about? How do I even do this? What the fuck? I am not equipped to handle that if it’s really what I’m expected to do in order to make these work again. Is there not an easier solution?

@ristomatti ristomatti added help wanted Extra attention is needed on hold Waiting for decision/more info labels Jun 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed on hold Waiting for decision/more info
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants