ZeroOne3010 / yetanotherhueapi

A Java library for controlling Philips Hue lights. Available from the Maven Central.
MIT License
68 stars 21 forks source link

Add new light #47

Closed nanaghartey closed 2 years ago

nanaghartey commented 2 years ago

How do I add a new light that didn't come with bridge. hue.getAllLights() and hue.getUnassignedLights()do not list new lights. Is there a way to scan and add a new light. A feature similar to "Add lights" in official Philips Hue android app. Thank you

ZeroOne3010 commented 2 years ago

Hi there, thanks for your message! At the moment the library does not support adding new lights, you would need to do that with the official app. I looked into the official Hue documentation though, and it seems like it would be a pretty fun and straight forward feature to add.

May I ask for your specific use case for this request? It's always good to understand the greater context around feature requests. 🙂

nanaghartey commented 2 years ago

Thanks for your prompt response!

Okay, well noted.

For my use case, I want a way to allow users add separate lights to their bridge without using the official app, even if they have to do it manually by providing the serial numbers of bulbs. I believe this would be a useful feature. For now, I direct users to install the hue app to add lights which few find cumbersome :(

ZeroOne3010 commented 2 years ago

I see, thank you! I can see the process is cumbersome indeed. How about adding the newly found lights to rooms, would you expect to need to be able to do that too?

nanaghartey commented 2 years ago

Yes that would be helpful too. Thanks

ZeroOne3010 commented 2 years ago

Ok, I'm imagining a new method into the Hue class, something like scanForNewLights(). That would make a POST request into the endpoint that triggers a scan. It would then return a Future that would be resolved once another endpoint that tells scan status would confirm the scan has ended (takes some 40 seconds according to the docs). The Future would then return a list of new Light objects.

The Hue class could then have another new method, addLightIntoRoom(Light, Room), which would do what it says on the label.

What do you think? Unfortunately I haven't got nearly as much time to dedicate to this project as I'd like, so I'd be more than happy to welcome a pull request even... 😉

ZeroOne3010 commented 2 years ago

Version 2.6.0 is now out with these features! Please try. :)