import java.util.Random

var Timer timer = null
val resList = newArrayList("640/480", "320/240", "480/360")
val urlList = newArrayList("https://www.fillmurray.com", "https://www.fillmurray.com/g",
                 "https://www.placecage.com", "https://www.placecage.com/c", "https://www.placecage.com/g")
val Random random = new Random()

/**
 * This is a demo rule which simulates a real dimmer by reacting to increase/decrease commands
 * and posting an updated state on the bus
 */
rule "Dimmed Light"
when
    Item DimmedLight received command
then
    if ((receivedCommand == INCREASE) || (receivedCommand == DECREASE)) {
        var Number percent = 5
        if (DimmedLight.state instanceof DecimalType) percent = DimmedLight.state as DecimalType
        //My_Light_Work.sendCommand(15 as DecimalType)
        if (receivedCommand == INCREASE) percent = percent + 5
        if (receivedCommand == DECREASE) percent = percent - 5

        if (percent < 0)   percent = 0
        if (percent > 100) percent = 100
        postUpdate(DimmedLight, percent);
    }
end

rule "Modes"
when
    Item My_Light_Work received command
then
    if (receivedCommand == 1){
        Light2_ColorTemperature.sendCommand(1)
        Light2_Brightness.sendCommand(100)
        Thread::sleep(15000)
    }

end

rule "Modes"
when
    Item My_Light_Work2 received command
then
    if (receivedCommand == 1){
        Light2_ColorTemperature.sendCommand(1)
        Light2_Brightness.sendCommand(100)
        Thread::sleep(15000)
    }

end

rule "Modesa"
when
    Item Default_Light received command
then
    if(receivedCommand == 1) {
        Light2_ColorTemperature.sendCommand(49)
        Light2_Brightness.sendCommand(80)       
        Thread::sleep(15000)
    }
end

rule "Modesa"
when
    Item Fixed_Light2 received command
then
    if(receivedCommand == 1) {
        Light2_ColorTemperature.sendCommand(49)
        Light2_Brightness.sendCommand(80)       
        Thread::sleep(15000)
    }
end