ZeroOne3010 / yetanotherhueapi

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

How to Control Lights with hue.getRaw()? #17

Closed 1998himanshu closed 4 years ago

1998himanshu commented 4 years ago

Hello , I am New Developer and I am Unable to Implement Lights with hue.getRaw().

I have Reached Till here.

                    Root root = hue.getRaw();
                    lights = (Map<String, LightDto>) root.getLights();

As LightDto has been deprecated for implementing turning ON/OFF Function .

         LightDto  lightDto= lights.get(<name>);
         LightState s =lightDto.getState();
         s.setOn(true);
         lightDto.setState(s);

Kindly Help me how to Control Lights without Room Object .

How can we Convert LIghtDto to Light so we can further use this object to access lights .

Correct me if i am approaching wrong way.

Thanks You in Advance .

ZeroOne3010 commented 4 years ago

Hello, and thanks for your message! Why do you need to control lights without a Room object? At the moment that's not possible with this library, it has not occurred to me that that would be a viable use case.

With the getRaw() method you can not control the Bridge -- it's purely for read-only purposes. You do need to find the room (or zone) first and only then can you control a light. README.md demonstrates that under the "Using the rooms, lights, and scenes" header: https://github.com/ZeroOne3010/yetanotherhueapi/blob/master/README.md