Hi, I want to create a rule that creates a sunrise with the hue. I use openhab2. I found this example on reddit, but get an error message. Can someone help me? I have a 0210 Hue bulb according to https://github.com/eclipse/smarthome/blob/master/extensions/binding/org.eclipse.smarthome.binding.hue/README.md#full-example
Here is the reddit post:
"I made a nice script to bring my Hue lights up slowly in the morning like a sunrise. This is the best way to wake up that I’ve ever had!
Over the course of half an hour, one light (in my case an upright lamp) turns from 0% brightness red to 100% brightness yellow-white. Then one of the ceiling lights turns on, and after 15 minutes the other one.
import org.openhab.model.script.actions.Timer
import org.openhab.core.library.types.*
rule "Wake up slowly"
when
Time cron “0 30 6 ? * MON-FRI” // Monday-Friday, at 6:30am
//Item Toggle_BdrmWash changed from OFF to ON
then
var Timer timer
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 = 0
HueVal = 0
SatVal = 100
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)
sendCommand(Color_BdrmWash, light)
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
timer = createTimer(now.plusSeconds(60)) [|
DimmerCheck = Dimmer
]
}
}
var PercenType ceilB = new PercentType(100)
var DecimalType ceilH = new DecimalType(60)
var PercentType ceilS = new PercentType(30)
var HSBType ceilL = new HSBType(ceilH, ceilS, ceilB)
sendCommand(Color_BdrmDesk, ceilL)
timer = createTimer(now.plusMinutes(15)) [|
sendCommand(Color_BdrmDoor, ceilL)
]
end
"
The last part I should be able to delete because I only want to use a lamp. Right?
Does not seame like i can import the two liberaries?
My first error is at “sendCommand(Color_BdrmWash, light)”. I have changed it to my color channel item:
Ambiguous feature call. The methods sendCommand(Item, Number) in BusEvent and sendCommand(Item, Command) in BusEvent both match.
My second error is at “DimmerCheck = Dimmer” inside the if:
Cannot refer to the non-final variable DimmerCheck inside a lambda expression