Class GroupImpl
java.lang.Object
io.github.zeroone3010.yahueapi.v2.GroupImpl
- All Implemented Interfaces:
Group
public class GroupImpl extends Object implements Group
-
Constructor Summary
Constructors Constructor Description GroupImpl(UUID id, ResourceType type, String name, List<Scene> scenes, Supplier<Collection<Light>> lights, Supplier<GroupedLightResource> stateProvider, Function<UpdateLight,String> stateSetter, Function<Collection<Light>,String> lightsSetter) -
Method Summary
Modifier and Type Method Description Collection<Light>addLight(Light newLight)Adds the given light into this group.UUIDgetId()Returns the technical id of the room, zone, or light group, as assigned by the Bridge.Optional<Light>getLightByName(String lightName)Returns one light, if found by the given name.Collection<Light>getLights()Returns all the lights that have been assigned to this group.StringgetName()Returns the name of the room or zone, as set by the user.Optional<Scene>getSceneByName(String sceneName)Returns the scene matching the given human-readable name, if one exists.List<Scene>getScenes()Lists all scenes that can be used with this group.ResourceTypegetType()Returns the type of this group, whether it is a room, zone, or grouped light.booleanisAnyOn()Queries the state of the group of lights.Collection<Light>removeLight(Light lightToBeRemoved)Removes the given light from this group.voidsetBrightness(int brightness)Sets the brightness of the lights.voidsetState(UpdateState state)Sets a state for the light.StringtoString()voidturnOff()Turns the lights off.voidturnOn()Turns the lights on.
-
Constructor Details
-
GroupImpl
public GroupImpl(UUID id, ResourceType type, String name, List<Scene> scenes, Supplier<Collection<Light>> lights, Supplier<GroupedLightResource> stateProvider, Function<UpdateLight,String> stateSetter, Function<Collection<Light>,String> lightsSetter)
-
-
Method Details
-
getId
Description copied from interface:GroupReturns the technical id of the room, zone, or light group, as assigned by the Bridge. The id stays the same even if the room name is changed by the user.
-
getName
Description copied from interface:GroupReturns the name of the room or zone, as set by the user. -
getScenes
Description copied from interface:GroupLists all scenes that can be used with this group. -
getSceneByName
Description copied from interface:GroupReturns the scene matching the given human-readable name, if one exists.- Specified by:
getSceneByNamein interfaceGroup- Parameters:
sceneName- The human-readable name of the scene- Returns:
- Optional Scene
-
getLights
Description copied from interface:GroupReturns all the lights that have been assigned to this group. -
getLightByName
Description copied from interface:GroupReturns one light, if found by the given name.- Specified by:
getLightByNamein interfaceGroup- Parameters:
lightName- Name of a light in this group.- Returns:
- Optional.empty() if a light is not found by this name, an Optional<Light> if it is.
-
getType
Description copied from interface:GroupReturns the type of this group, whether it is a room, zone, or grouped light. -
isAnyOn
public boolean isAnyOn()Description copied from interface:GroupQueries the state of the group of lights. -
turnOn
public void turnOn()Description copied from interface:GroupTurns the lights on. -
turnOff
public void turnOff()Description copied from interface:GroupTurns the lights off. -
setBrightness
public void setBrightness(int brightness)Description copied from interface:GroupSets the brightness of the lights. If the lights are off, does not turn them on, nor does0turn them off.- Specified by:
setBrightnessin interfaceGroup- Parameters:
brightness- A value from1(minimum brightness) to100(maximum brightness).
-
setState
Description copied from interface:GroupSets a state for the light. -
addLight
Description copied from interface:GroupAdds the given light into this group. Note that if the light already belongs to a room, you must remove it from there first, or this operation will fail! -
removeLight
Description copied from interface:GroupRemoves the given light from this group.- Specified by:
removeLightin interfaceGroup- Parameters:
lightToBeRemoved- The light to be removed- Returns:
- A Collection of Lights in this group after the operation.
-
toString
-