I have the following rule that uses my sonos system and my hue lights to start music and do a “strobo” like behaviour of the hue lamps:
rule "Party Button Activated"
when
Channel "amazondashbutton:dashbutton:ac-63-be-0d-1e-78:press" triggered or
Item PartyButton changed or
Channel "amazondashbutton:dashbutton:44-65-0d-40-78-38:press" triggered
then
logInfo("mydata", "### PARTY BUTTON PRESSED ###")
val alarmVolume = 30
val song = "Brett"
//Turn off all lights
logInfo("mydata", "### SWITCHING OFF ALL LIGHTS ###")
sendCommand(gLights, "OFF")
//Turn on music
logInfo("mydata", "### SWITCHING OFF ALL MUSIC ###")
sendCommand(PH_Sonos5_001_volume, 0)
sendCommand(Bad_Sonos1_001_volume, 0)
Thread::sleep(1000)
logInfo("mydata", "### RAISING MUSIC VOLUME TO "+alarmVolume.toString+" ###")
sendCommand(PH_Sonos5_001_volume, alarmVolume)
sendCommand(Bad_Sonos1_001_volume, alarmVolume)
logInfo("mydata", "### SETTING MUSIC TRACK TO "+song.toString+" ###")
sendCommand(PH_Sonos5_001_favourite, song)
Thread::sleep(2000)
var i = 1
while (PH_Sonos5_001_control.state.toString == "PLAY")
{
var randomColor = new DecimalType((new java.util.Random).nextInt(360))
logInfo("mydata", "### LOOP COLOR "+randomColor.toString+" ###")
sendCommand(Flur_HueLamp_001_color, new HSBType(randomColor,new PercentType(100),new PercentType(100)))
sendCommand(Flur_HueLamp_001_color, new HSBType(randomColor,new PercentType(100),new PercentType(0)))
Thread::sleep(200)
sendCommand(Kueche_HueLamp_001_color, new HSBType(randomColor,new PercentType(100),new PercentType(100)))
sendCommand(Kueche_HueLamp_001_color, new HSBType(randomColor,new PercentType(100),new PercentType(0)))
Thread::sleep(200)
sendCommand(PH_HueLamp_001_color, new HSBType(randomColor,new PercentType(100),new PercentType(100)))
sendCommand(PH_HueLamp_001_color, new HSBType(randomColor,new PercentType(100),new PercentType(0)))
Thread::sleep(200)
sendCommand(PH_HueStrip_001_color, new HSBType(randomColor,new PercentType(100),new PercentType(100)))
sendCommand(PH_HueStrip_001_color, new HSBType(randomColor,new PercentType(100),new PercentType(0)))
Thread::sleep(200)
sendCommand(Flur_HueLamp_001_color, new HSBType(randomColor,new PercentType(100),new PercentType(100)))
sendCommand(Flur_HueLamp_001_color, new HSBType(randomColor,new PercentType(100),new PercentType(0)))
Thread::sleep(200)
sendCommand(Bad_HueLamp_001_color, new HSBType(randomColor,new PercentType(100),new PercentType(100)))
sendCommand(Bad_HueLamp_001_color, new HSBType(randomColor,new PercentType(100),new PercentType(0)))
Thread::sleep(200)
sendCommand(Kueche_HueLamp_001_color, new HSBType(randomColor,new PercentType(100),new PercentType(100)))
sendCommand(Kueche_HueLamp_001_color, new HSBType(randomColor,new PercentType(100),new PercentType(0)))
Thread::sleep(200)
}
end
It works quite good, the problem I have is that when I stop the music from playing, the lights will keep on going off and on.
I think this is due to the fact that I am sending way too many commands to the hue lamps - but I have not found any other solution for this yet. Is there a way to clear the command queue from openhab?
Regards