Nightlight with Hue

Hallo,
I want to realize this scenario:
At 8 pm a Hue bulb should switch on with red light and less brightness. I should stay the whole night like that.
At 7 am in the morning it should switch to green light with the same brightness.

Any help appreciated!

This items I have in hue.items:

Group gBecky_Nachtlicht "Nachtlicht Becky"  <light> (FF_BeckysRoom)
    Dimmer BeckyNachtlicht_Farbtemperatur "Nachtlicht Becky Farbtemperatur"  <rgb>   (gBecky_Nachtlicht)    {channel="hue:0210:xxx:7:color_temperature"}
    Color BeckyNachtlicht_Farbe   "Nachtlicht Becky Farbe"   <colorwheel>    (gBecky_Nachtlicht)    {channel="hue:0210:xxx:7:color"}
    Dimmer BeckyNachtlicht_Helligkeit "Nachtlicht Becky Helligkeit"  <light> (gBecky_Nachtlicht)    {channel="hue:0210:xxx:7:color"}
    Switch BeckyNachtlicht_Schalter   "Nachtlicht Becky Schalter"    <light> (gBecky_Nachtlicht, gLampen)   {channel="hue:0210:xxx:7:color"}

What have you done so far? Did you create a rule? You need a time based trigger Rules Time based triggers

Or if you want a more advanced system, look at DP: Time of day

What I’ve done so far, which does’t work:

hue.items:

Switch BeckyNachtlicht_green "Nachlicht Becky grĂĽn" <light> (gBecky_Nachtlicht)

I created the following rule:

rule "Nachlicht Becky green"

when
Item BeckyNachtlicht_green received command ON

then
{
    var DecimalType hue = new DecimalType(120) // 0-360; 0=red, 120=green, 240=blue, 360=red(again)
    var PercentType sat = new PercentType(100) // 0-100
    var PercentType bright = new PercentType(5) // 0-100
    var HSBType green = new HSBType(hue,sat,bright)

    BeckyNachtlicht_Schalter.sendCommand(ON) 
    BeckyNachtlicht_Schalter.sendCommand(green)
}
end

This rule doesn’t has a time based trigger. I just wanted to figure out, if this rule turns the bulb on and switch to green colour.
If I switch the item “BeckyNachtlicht_green” via sitemap to on the bulb is shining but not in colour green :frowning:

Hi @donleonardo,

try to send your „green“ variable to BeckyNachtlicht_Farbe.

Bye
HFM

Nice, that worked :slight_smile: Many thanks!
Now I try to trigger by time with Laurens links…

1 Like

This rules-file workes:

rule "Nachtlicht Woche"
when
Time cron "0 45 19 ? * MON-FRI *"
then
{
    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(5) // 0-100
    var HSBType light = new HSBType(hue,sat,bright)

    BeckyNachtlicht_Schalter.sendCommand(ON) 
    BeckyNachtlicht_Farbe.sendCommand(light)
}
end

rule "Morgenlicht Woche"
when
Time cron "0 50 6 ? * MON-FRI *"
then
{
    var DecimalType hue = new DecimalType(120) // 0-360; 0=red, 120=green, 240=blue, 360=red(again)
    var PercentType sat = new PercentType(100) // 0-100
    var PercentType bright = new PercentType(5) // 0-100
    var HSBType light = new HSBType(hue,sat,bright)

    BeckyNachtlicht_Schalter.sendCommand(ON) 
    BeckyNachtlicht_Farbe.sendCommand(light)
}
end

rule "Nachtlicht Wochenende"
when
Time cron "0 45 19 ? * SAT-SUN *"
then
{
    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(5) // 0-100
    var HSBType light = new HSBType(hue,sat,bright)

    BeckyNachtlicht_Schalter.sendCommand(ON) 
    BeckyNachtlicht_Farbe.sendCommand(light)
}
end

rule "Morgenlicht Wochenende"
when
Time cron "0 30 7 ? * SAT-SUN *"
then
{
    var DecimalType hue = new DecimalType(120) // 0-360; 0=red, 120=green, 240=blue, 360=red(again)
    var PercentType sat = new PercentType(100) // 0-100
    var PercentType bright = new PercentType(5) // 0-100
    var HSBType light = new HSBType(hue,sat,bright)

    BeckyNachtlicht_Schalter.sendCommand(ON) 
    BeckyNachtlicht_Farbe.sendCommand(light)
}
end

I tried to put the variables out of the rules at the top to use them for general. But with no success…

var DecimalType hue_green = new DecimalType(120) // 0-360; 0=red, 120=green, 240=blue, 360=red(again)
var DecimalType hue_red = 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(5) // 0-100
var HSBType green = new HSBType(hue_green,sat,bright)
var HSBType red = new HSBType(hue_red,sat,bright)

rule "New rule"...

Any suggestions, what’s the problem?