Help with hue sunrise rule

Hello, I hope this works for you too. It worked for me, but I dont have it up and running right now after i moved. One tip is to fix a way to abort the script while it is running, otherwise you can not interrupt the ignition of the lamp and you have to wait half an hour until the script is finished.

rule "Morning light"

when 
	Time cron "0 0 7 ? * MON-FRI" 
then
//ON/OFF button	
if(Morgonlampor_Sovrum_Vardagar.state==ON){
		callScript("morgonlampa 2")
	}

end

Script morgonlampa 2

var Integer Dimmer
var Integer DimmerCheck
var Integer HueVal
var Integer SatVal
var DecimalType hue = new DecimalType(0) // 0-360; 0=red, 120=green, 240=blue, 360=red(again)
var PercentType sat = new PercentType(100) // 0-100
var PercentType bright = new PercentType(0)
var HSBType light

Dimmer = 3
HueVal = 2
SatVal = 99
DimmerCheck=Dimmer

while(Dimmer<=90) // End up at 90% brightness
  {
   if (Dimmer==DimmerCheck)
     {
      bright = new PercentType(Dimmer)
      hue = new DecimalType(HueVal)
      sat = new PercentType(SatVal)
      light = new HSBType(hue,sat,bright)
      Light3_Color.sendCommand(light.toString)
      Dimmer = Dimmer + 3
      HueVal = HueVal + 2 // Increment from 0 to 60 over half an hour
      SatVal = SatVal - 1 // Decrement from 100 saturation to 70% over half an hour
		 
        Thread::sleep(60000)
        DimmerCheck = Dimmer
            }
        }

2 Likes