Hue Random Color compare with Variable


i generate a random color with:

val randHue = (Math::random * 360).intValue + 1// Math::random macht eine zufällige Zahl zwischen 0.0 und 1.0 und wird maximal 360 (Colorwheel hat 360Grad)

        val randSat = 100 //(Math::random * 100).intValue

now I only want to send a new Color if it different.

item.sendCommand(randHue+","+randSat+","+item.getStateAs(PercentType)) //Gleiche Helligkeit

How can I check if it is a new Color/ brightness ?

something like:
if (item.state == randHue)
if (item.state == randSat)
if (item.getStateAs(PercentType)) == 100) // Check if brightness 100%

I only want to change the light if necessary (different brightness or different saturation or different Hue)

Here is your answer.

Why? randSat is always 100

I try to monitor if the light makes any change.
If i want to make a change i have to send a command first. So my system will pass it.
If i want to set a brightness or color i have to know if i have to send a command first.

How can I read out the Hue and Sat and brightness and compare them with my new Values.

If you send a command for 70 and the value is already 70 then use return; at the end of the if statement. This will simply do nothing, you can then send a different value to have it change.

Use postUpdate on the item to give the current value.