Help with Hue colour Rule

Hi Everyone i’m having a little problem with a rule im trying to create hope you could shed some light on this

rule "rule name"
    Item BULB6LRMAIN1_Color changed to "63,3,0" //When bulb changes to OFF
    Main1_LR_Trigger.sendCommand ("OFF") //Turn trigger OFF

The problem is you cant realy predict what the first two digits would be

eg: “63,3,0” the first two numbers could be changed to anything if someone changes the brightness or colour of the bulb is there a way to add wildcards eg: “#,#,0” so the first numbers could be anything and it just watches for the last digit being set to 0

Did you try to work with OFF instead of “63,3,0” ?
I remember I could control the Phillips colour Hue with ON/OFF via Node-Red, so maybe it does work with the rule as well . . .

Just tested it with node-red again.
If I send ON/OFF it just changes the last digit X/X/0 > X/X/100 so theoretically rules should work the same.
Node-Red works with with an ON/OFF Switch-case

yes iv tried that nothing happens you are correct tho its the last number that changes 0 is OFF 100 FULL

sending an on/off command does work i have used that myself but watching for it to change to this state doesent happen thats why i was asking if you can just watch the last number or use wild card

Telling you to use node-red is not the solution :laughing: … I get your problem, I’m thinking about a different solution.

Try it with RegEx? Some regex in a rule
RegEx would be (\d+$) tested with the string 63,3,0 with

the problem is my button that runs a rule to turn the light on stays enabled on habpannel if anyone changes the light from anywhere else like google home, hue app it takes 2 presses on the button before the light comes on ect very annoying othrwise i would just leave it how it is

A Button running a rule which turns on a Light. The Button to switch the rule stays ON if someone/something switches the light.
So you are trying to … if light switches to off, switch the rule switch back to state OFF? :dizzy_face:
Did I get this right ??

Yes pretty much there is a button on habpannel that sends on/off to a rule that checks the time of day and sets the light according (color, brightness) if someone then turns the light off not using the habpannel button but the hue app or a Google home the button that started the rule would still be on this is obviously expected that’s why a was trying to create a rule to solve this

this is the rule

    Item Main1_LR_Trigger changed
logInfo("RULE", "LRMAINBUTTON RUNNING (LR Lighting Schedules.Rules)")
if( Main1_LR_Trigger.state ==ON) {
    if     (now.getHourOfDay >  9 && now.getHourOfDay < 16) { //9AM <> 4PM COOL WHITE
    else if(now.getHourOfDay > 16 && now.getHourOfDay < 20) { //4PM <> 8PM //WHITE
    logInfo("NOTE", "LRMAIN LIGHT ON (WHITE)")}
    else if(now.getHourOfDay > 20 && now.getHourOfDay < 22) { //8PM <> 10PM //WARM WHITE
    logInfo("NOTE", "LRMAIN LIGHT ON (WHITE)")
if( Main1_LR_Trigger.state ==OFF ) {
    BULB6LRMAIN1_Color.sendCommand ("63,3,0")
    logInfo("NOTE", "LRMAIN OFF")
logInfo("RULE", "LRMAINBUTTON FINISHED (LR Lighting Schedules.Rules)")    

Sounds like your Rule listens to a ON/OFF specific change, am I right?
If my assumption is right, maybe try to use this instead of specific ON/OFF

Item GenericItem received update

your code goes here

This way you can tab the button no matter if ON or OFF and it will trigger your rule

if i just watched every change it would just always turn the light off

im still a begginer so im not sure about alot of things it could just be simple solution normally is

if( Main1_LR_Trigger.state == ON or Main1_LR_Trigger.state == OFF )

I can’t remember the rule syntax 100%
I assume this if case is the flaw.

Trigger this rule if the Main Switch is changed no matter if ON or OFF

then you tell the Rule to ONLY work when the Main switch is ON if the Main Switch is OFF just switch the HUE OFF
So your first when > then is obsolete

the rule watches for LR_Main_Trigger ON/OFF it then checks if parts to decide what too do depending on if the switch changed to ON or OFF i think this is correct, it works fine if you press the button it checks the time sets the light ON if you press it again the same rule fires but send OFF button turns off perfect its just when you turn the light off elsewhere as google home or hue dont send the command 63,3,0 its like you say it just changes the last number

I just read your code again and I see the Problem. My Idea is not a working solution. Give me a second :smiley:

take as long as you need it takes me forever to do anything its always complex , like i say if there was a way to just watch for the last digit changing to 0 that would be perfect

ofc there is. You can define variables.
Get Hue Bulb state, which returns digit,digit,digit which can be transformed via RegEx to just the last digit

then you can transform the 0 and 100 to a string ON/OFF and work with that.
or turn the string to an array and work with the index number[2] which would be much simpler :smiley:

Coming a little late to this thread, but hope it will still be helpful
I have a rule just like yours that works well. It may be that you need a new switch item definition, this works for me with a color lamp from Hue:
Item (I have other items defined for color and dimmer):

Switch	Bedroom_light "Bedroom" (gBedroom) 


rule "Bedtime Dimmer"
	Item Bedroom_light changed from ON to OFF

I tried to do what you want with the last digit in java-script. Take a look. Is this what you are looking for ?

I think so yes how would I add that and test

It would need linking to when bulbcolour changed output the number to a different switch and then set the rule from there?

im usless with code im hoping to learn but atm im a complete noob with code

To simplistic to the say check every change and have a conditional inside the function?

I think this can be solved pretty simply.

rule "rule name"
    Item BULB6LRMAIN1_Color changed
    if(BULB6LRMAIN1_Color.getStateAs(OnOffType) == OFF) Main1_LR_Trigger.sendCommand ("OFF")


rule "rule name"
    Item BULB6LRMAIN1_Color changed
    if((BULB6LRMAIN1_Color.state as HSBType).brightness == 0) Main1_LR_Trigger.sendCommand ("OFF")

I just typed in the above, I may not have remembered everything correctly.


i will have a look now i will have to copy and paste this though im not sure how it works