Help with a If script

I’m trying to set up a light to check if the light is already on and at a certain time change the color temp. Is my code wrong? I’ve tried a few different ways but I can’t get it to work properly. I have a script similar to this that just turns the lights ON at a certain time without the check, the check is the part I can’t get working. Its a Milight connected to a milight box1. Thanks!

// If lights are on, at 8:30PM change colortemp to 50%
rule "LightTemp50"
when
    Time cron "0 30 20 1/1 * ? *"
then
    if (RgbwwColorZone1_Brightness = ON) {
        RgbwwColorZone1_ColorTemperature.sendCommand(20)
    }
end

Try RgbwwColorZone1_Brightness.state = ON

1 Like

Since it is a comparison you’ll need two =

// If lights are on, at 8:30PM change colortemp to 50%
rule "LightTemp50"
when
    Time cron "0 30 20 1/1 * ? *"
then
    if (RgbwwColorZone1_Brightness.state == ON) {
        RgbwwColorZone1_ColorTemperature.sendCommand(20)
    }
end
2 Likes

And if RgbwwColorZone1_Brightness is a percentage (dimmer) you’ll have to think again, not ON but > 20 or suchlike

1 Like

Yeah I was just running into that idea, I assumed ON would work since it has that value on the control in paperUI. I’m still playing around with it to see what I can do, so like this?
(RgbwwColorZone1_Brightness.state => 1)

Ohhh its (RgbwwColorZone1_Brightness.state >= 100)

You can command a dimmer ON or OFF, but that just sets its state to 100 or 0. If you enquire what it’s state is, it is always a number.

1 Like

Fantastic, thank you for your wisdom!