As long as the item “KNX_GV_Keuken_VolumeUp_10_1_1” has state “ON”, the volume should keep increasing at a certain pace. I tried doing this via a do/while approach. But that didn’t work.
rule "Increase volume Sonos Keuken"
when
Item KNX_GV_Keuken_VolumeUp_10_1_1 changed from OFF to ON
then
logInfo("Debug","Sonos Debug1")
while(KNX_GV_Keuken_VolumeUp_10_1_1.state == ON) {
Sonos_GV_Keuken_Volume = Sonos_GV_Keuken_Volume+1
Thread::sleep(1000)
}
logInfo("Debug","Sonos Debug2")
end
I’m getting in my debug-log the “Sonos Debug1” value, but never the “Sonos Debug2” value. So I’m guessing I’m doing something wrong there. I couldn’t find many do/while examples, so I’m not sure if I follow the correct approach.
@michaeljoos: thanks! That was the example I needed!
I can now control the volume of my Sonos using my KNX switch.
rule "Increase volume Sonos Keuken"
when
Item KNX_GV_Keuken_VolumeUp_10_1_1 changed from OFF to ON
then
var Number v_adjustvolume = Sonos_GV_Keuken_Volume.state as DecimalType
while(KNX_GV_Keuken_VolumeUp_10_1_1.state == ON) {
v_adjustvolume = v_adjustvolume + 1
sendCommand(Sonos_GV_Keuken_Volume, v_adjustvolume)
Thread::sleep(250)
}
end
rule "Decrease volume Sonos Keuken"
when
Item KNX_GV_Keuken_VolumeDown_10_1_2 changed from OFF to ON
then
var Number v_adjustvolume = Sonos_GV_Keuken_Volume.state as DecimalType
while(KNX_GV_Keuken_VolumeDown_10_1_2.state == ON) {
v_adjustvolume = v_adjustvolume - 1
sendCommand(Sonos_GV_Keuken_Volume, v_adjustvolume)
Thread::sleep(250)
}
end
I was looking into the same but with a KNX dimmer. I already use the ON/OFF channel to play/pause but have not integrated volume control yet.
Any idea how this would be configured?
I’ll see if my switch can support that, but I doubt I’ll be able to do it with the same sensor-button as play/pause. It’s a Basalte sentido configured as single button switch/dimmer. The dimming actions should produce INCREASE/DECREASE events if I’m not mistaken, which I can use instead of ON/OFF.
I copied your rule and replaced the items with my own.
The rule get executed but in stead of increasing by 1 for example, the only thing what happens is that the sonos volume item receives the command 1 and get set to 1…
Just to be sure, if you look at my example:
Item “KNX_GV_Keuken_VolumeUp_10_1_1” can only have two values (ON/OFF or 1/0).
Item “Sonos_GV_Keuken_Volume” is a decimaltype, so can technically have any number as a value.
So please share your rule, and tell us which item has value 1.