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"
when
Item BULB6LRMAIN1_Color changed to "63,3,0" //When bulb changes to OFF
then
Main1_LR_Trigger.sendCommand ("OFF") //Turn trigger OFF
end
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 . . .
edit:
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
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?
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
rule "LRMAINBUTTON"
when
Item Main1_LR_Trigger changed
then
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
BULB6LRMAIN1_Color.sendCommand("227,30,100")
logInfo("NOTE", "LRMAIN LIGHT ON (COOL WHITE)")}
else if(now.getHourOfDay > 16 && now.getHourOfDay < 20) { //4PM <> 8PM //WHITE
BULB6LRMAIN1_Color.sendCommand("48,35,100")
logInfo("NOTE", "LRMAIN LIGHT ON (WHITE)")}
else if(now.getHourOfDay > 20 && now.getHourOfDay < 22) { //8PM <> 10PM //WARM WHITE
BULB6LRMAIN1_Color.sendCommand("39,87,100")
logInfo("NOTE", "LRMAIN LIGHT ON (WARM WHITE)")}
else
BULB6LRMAIN1_Color.sendCommand("48,35,100")
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)")
end
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
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
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):
rule "rule name"
when
Item BULB6LRMAIN1_Color changed
then
if(BULB6LRMAIN1_Color.getStateAs(OnOffType) == OFF) Main1_LR_Trigger.sendCommand ("OFF")
end
or
rule "rule name"
when
Item BULB6LRMAIN1_Color changed
then
if((BULB6LRMAIN1_Color.state as HSBType).brightness == 0) Main1_LR_Trigger.sendCommand ("OFF")
end
I just typed in the above, I may not have remembered everything correctly.