public class HueBridge
extends Object
| Modifier and Type | Class and Description | 
|---|---|
| static interface  | HueBridge.ScheduleCallbackCallback to specify a schedule command. | 
| Constructor and Description | 
|---|
| HueBridge(String ip)Connect with a bridge as a new user. | 
| HueBridge(String ip,
         String username)Connect with a bridge as an existing user. | 
| Modifier and Type | Method and Description | 
|---|---|
| void | authenticate(String username)Authenticate on the bridge as the specified user. | 
| Group | createGroup(List<Light> lights)Creates a new group and returns it. | 
| Group | createGroup(String name,
           List<Light> lights)Creates a new group and returns it. | 
| void | createSchedule(Date time,
              HueBridge.ScheduleCallback callback)Schedules a new command to be run at the specified time. | 
| void | createSchedule(String name,
              Date time,
              HueBridge.ScheduleCallback callback)Schedules a new command to be run at the specified time. | 
| void | createSchedule(String name,
              String description,
              Date time,
              HueBridge.ScheduleCallback callback)Schedules a new command to be run at the specified time. | 
| void | deleteGroup(Group group)Delete a group. | 
| void | deleteSchedule(Schedule schedule)Delete a schedule. | 
| Group | getAllGroup()Returns a group object representing all lights. | 
| Config | getConfig()Returns bridge configuration. | 
| FullConfig | getFullConfig()Returns the entire bridge configuration. | 
| FullGroup | getGroup(Group group)Returns detailed information for the given group. | 
| List<Group> | getGroups()Returns the list of groups, including the unmodifiable all lights group. | 
| String | getIPAddress()Returns the IP address of the bridge. | 
| Date | getLastSearch()Returns the last time a search for new lights was started. | 
| FullLight | getLight(Light light)Returns detailed information for the given light. | 
| List<Light> | getLights()Returns a list of lights known to the bridge. | 
| FullSchedule | getSchedule(Schedule schedule)Returns detailed information for the given schedule. | 
| List<Schedule> | getSchedules()Returns a list of schedules on the bridge. | 
| String | getUsername()Returns the username currently authenticated with or null if there isn't one. | 
| boolean | isAuthenticated()Returns if authentication was successful on the bridge. | 
| String | link(String devicetype)Link with bridge using the specified device type. | 
| void | link(String username,
    String devicetype)Link with bridge using the specified username and device type. | 
| void | setConfig(ConfigUpdate update)Change the configuration of the bridge. | 
| String | setGroupAttributes(Group group,
                  String name,
                  List<Light> lights)Changes the name and the lights of a group and returns the new name. | 
| void | setGroupLights(Group group,
              List<Light> lights)Changes the lights in the group. | 
| String | setGroupName(Group group,
            String name)Changes the name of the group and returns the new name. | 
| void | setGroupState(Group group,
             StateUpdate update)Changes the state of a group. | 
| String | setLightName(Light light,
            String name)Changes the name of the light and returns the new name. | 
| void | setLightState(Light light,
             StateUpdate update)Changes the state of a light. | 
| void | setSchedule(Schedule schedule,
           ScheduleUpdate update)Changes a schedule. | 
| void | setScheduleCommand(Schedule schedule,
                  HueBridge.ScheduleCallback callback)Changes the command of a schedule. | 
| void | setTimeout(int timeout)Set the connect and read timeout for HTTP requests. | 
| void | startSearch()Start searching for new lights for 1 minute. | 
| void | unlink()Unlink the current user from the bridge. | 
public HueBridge(String ip)
ip - ip address of bridgepublic HueBridge(String ip,
         String username)
          throws IOException,
                 ApiException
ip - ip address of bridgeusername - username to authenticate withIOExceptionApiExceptionpublic void setTimeout(int timeout)
timeout - timeout in milliseconds or 0 for indefinitelypublic String getIPAddress()
public String getUsername()
public boolean isAuthenticated()
public List<Light> getLights() throws IOException, ApiException
UnauthorizedException - thrown if the user no longer existsIOExceptionApiExceptionpublic Date getLastSearch()
                   throws IOException,
                          ApiException
UnauthorizedException - thrown if the user no longer existsIOExceptionApiExceptionpublic void startSearch()
                 throws IOException,
                        ApiException
UnauthorizedException - thrown if the user no longer existsIOExceptionApiExceptionpublic FullLight getLight(Light light) throws IOException, ApiException
light - lightUnauthorizedException - thrown if the user no longer existsEntityNotAvailableException - thrown if a light with the given id doesn't existIOExceptionApiExceptionpublic String setLightName(Light light, String name) throws IOException, ApiException
light - lightname - new name [0..32]UnauthorizedException - thrown if the user no longer existsEntityNotAvailableException - thrown if the specified light no longer existsIOExceptionApiExceptionpublic void setLightState(Light light, StateUpdate update) throws IOException, ApiException
light - lightupdate - changes to the stateUnauthorizedException - thrown if the user no longer existsEntityNotAvailableException - thrown if the specified light no longer existsDeviceOffException - thrown if the specified light is turned offIOExceptionApiExceptionpublic Group getAllGroup()
public List<Group> getGroups() throws IOException, ApiException
UnauthorizedException - thrown if the user no longer existsIOExceptionApiExceptionpublic Group createGroup(List<Light> lights) throws IOException, ApiException
lights - lights in groupUnauthorizedException - thrown if the user no longer existsGroupTableFullException - thrown if the group limit has been reachedIOExceptionApiExceptionpublic Group createGroup(String name, List<Light> lights) throws IOException, ApiException
name - new group namelights - lights in groupUnauthorizedException - thrown if the user no longer existsGroupTableFullException - thrown if the group limit has been reachedIOExceptionApiExceptionpublic FullGroup getGroup(Group group) throws IOException, ApiException
group - groupUnauthorizedException - thrown if the user no longer existsEntityNotAvailableException - thrown if a group with the given id doesn't existIOExceptionApiExceptionpublic String setGroupName(Group group, String name) throws IOException, ApiException
group - groupname - new name [0..32]UnauthorizedException - thrown if the user no longer existsEntityNotAvailableException - thrown if the specified group no longer existsIOExceptionApiExceptionpublic void setGroupLights(Group group, List<Light> lights) throws IOException, ApiException
group - grouplights - new lights [1..16]UnauthorizedException - thrown if the user no longer existsEntityNotAvailableException - thrown if the specified group no longer existsIOExceptionApiExceptionpublic String setGroupAttributes(Group group, String name, List<Light> lights) throws IOException, ApiException
group - groupname - new name [0..32]lights - [1..16]UnauthorizedException - thrown if the user no longer existsEntityNotAvailableException - thrown if the specified group no longer existsIOExceptionApiExceptionpublic void setGroupState(Group group, StateUpdate update) throws IOException, ApiException
group - groupupdate - changes to the stateUnauthorizedException - thrown if the user no longer existsEntityNotAvailableException - thrown if the specified group no longer existsIOExceptionApiExceptionpublic void deleteGroup(Group group) throws IOException, ApiException
group - groupUnauthorizedException - thrown if the user no longer existsEntityNotAvailableException - thrown if the specified group no longer existsIOExceptionApiExceptionpublic List<Schedule> getSchedules() throws IOException, ApiException
UnauthorizedException - thrown if the user no longer existsIOExceptionApiExceptionpublic void createSchedule(Date time,
                  HueBridge.ScheduleCallback callback)
                    throws IOException,
                           ApiException
time - time to run commandcallback - callback in which the command is specifiedUnauthorizedException - thrown if the user no longer existsInvalidCommandException - thrown if the scheduled command is larger than 90 bytes or otherwise invalidIOExceptionApiExceptionpublic void createSchedule(String name,
                  Date time,
                  HueBridge.ScheduleCallback callback)
                    throws IOException,
                           ApiException
name - name [0..32]time - time to run commandcallback - callback in which the command is specifiedUnauthorizedException - thrown if the user no longer existsInvalidCommandException - thrown if the scheduled command is larger than 90 bytes or otherwise invalidIOExceptionApiExceptionpublic void createSchedule(String name,
                  String description,
                  Date time,
                  HueBridge.ScheduleCallback callback)
                    throws IOException,
                           ApiException
name - name [0..32]description - description [0..64]time - time to run commandcallback - callback in which the command is specifiedUnauthorizedException - thrown if the user no longer existsInvalidCommandException - thrown if the scheduled command is larger than 90 bytes or otherwise invalidIOExceptionApiExceptionpublic FullSchedule getSchedule(Schedule schedule) throws IOException, ApiException
schedule - scheduleUnauthorizedException - thrown if the user no longer existsEntityNotAvailableException - thrown if the specified schedule no longer existsIOExceptionApiExceptionpublic void setSchedule(Schedule schedule, ScheduleUpdate update) throws IOException, ApiException
schedule - scheduleupdate - changesUnauthorizedException - thrown if the user no longer existsEntityNotAvailableException - thrown if the specified schedule no longer existsIOExceptionApiExceptionpublic void setScheduleCommand(Schedule schedule, HueBridge.ScheduleCallback callback) throws IOException, ApiException
schedule - schedulecallback - callback for new commandUnauthorizedException - thrown if the user no longer existsInvalidCommandException - thrown if the scheduled command is larger than 90 bytes or otherwise invalidIOExceptionApiExceptioncreateSchedulepublic void deleteSchedule(Schedule schedule) throws IOException, ApiException
schedule - scheduleUnauthorizedException - thrown if the user no longer existsEntityNotAvailableException - thrown if the schedule no longer existsIOExceptionApiExceptionpublic void authenticate(String username)
                  throws IOException,
                         ApiException
username - username to authenticateUnauthorizedException - thrown if authentication failedIOExceptionApiExceptionpublic void link(String username,
        String devicetype)
          throws IOException,
                 ApiException
username - username for new user [10..40]devicetype - identifier of application [0..40]LinkButtonException - thrown if the bridge button has not been pressedIOExceptionApiExceptionpublic String link(String devicetype)
            throws IOException,
                   ApiException
devicetype - identifier of application [0..40]LinkButtonException - thrown if the bridge button has not been pressedIOExceptionApiExceptionpublic Config getConfig() throws IOException, ApiException
UnauthorizedException - thrown if the user no longer existsIOExceptionApiExceptionConfigpublic void setConfig(ConfigUpdate update) throws IOException, ApiException
update - changes to the configurationUnauthorizedException - thrown if the user no longer existsIOExceptionApiExceptionpublic void unlink()
            throws IOException,
                   ApiException
UnauthorizedException - thrown if the user no longer existsIOExceptionApiExceptionpublic FullConfig getFullConfig() throws IOException, ApiException
UnauthorizedException - thrown if the user no longer existsIOExceptionApiException