Closed DanielBlik closed 5 years ago
Hey, thanks for creating an issue, that's actually a really good question! You were so close with the second one -- this one should do the trick:
room.setState(((BrightnessStep) State.builder()).brightness(brightness).keepCurrentState())
Replace keepCurrentState()
with on()
if you are not 100% sure that the lights are already on.
I admit this is far from an optimal solution. The justification is that the lights are actually controlled with hue, saturation and brightness, so the State builder requires you to enter those other two values first -- unless you do something clever like cast it right away into a BrightnessStep
instance. ;) However, obviously just changing the brightness only should be a supported use case -- and while at it, I suppose changing the hue and saturation alone should be supported too.
The State builder is designed to protect against creating self-contradictory states, such as a state where a user would set a color with both Color.DARK_GRAY
and a string like #A12345
. In this case it seems to go too far in requiring a hue and a saturation before allowing to change the brightness.
Thank you it worked :)
How does one change the brightness of a room i have tried it these ways
but they both don't work first one gives a ClassCastException which is logical but the 2nd gives an error on the code and gives The method setState(State) in the type Room is not applicable for the arguments (StateBuilderSteps.BuildStep) How do I properly change the brightness then?
thanks for the great api btw it has been working really well