I tried searching and didn’t see this mentioned anywhere else but I may have missed it.
I’m trying to write some rules for my lighting system and I’m using Insteon keypads. What I’d like to accomplish is pressing one button activates a scene, or a mode which adjusts the lighting, thermostat, and a few other devices, and then turns off any scene or mode buttons that should not be on. I’ve been testing this without attaching to hardware but just creating some switch items in OpenHAB and creating rules operating on them.
This is the code I have so far:
rule "Dinner Time"
when
Item LivingRoomKeypadButtonB changed
then
logDebug("LIVINGROOM","Livingroom Keypad Button B Pressed")
if (LivingRoomKeypadButtonB.state == ON){
logDebug("LIVINGROOM", "Keypad Button B ON")
gLivingRoom.members.forEach(item|{
logDebug("LIVINGROOM", "LivingRoom Memebers Item: " + item.name)
if(item.groupNames.contains("gLights")){
logDebug("LIVINGROOM", "Item " + item.name + " in gLights group")
if(item.state != DinnerSceneOnLevel){
logDebug("LIVINGROOM", "Item " + item.name + " set to " + DinnerSceneOnLevel.toString)
item.sendCommand(DinnerSceneOnLevel)
}
}
})
LivingRoomKeypadButtonE.sendCommand(OFF)
} else {
logDebug("LIVINGROOM", "Keypad Button B OFF")
gLivingRoom.members.forEach(item|{
logDebug("LIVINGROOM", "LivingRoom Memebers Item: " + item.name)
if(item.groupNames.contains("gLights")){
logDebug("LIVINGROOM", "Item " + item.name + " in gLights group")
if(item.state >= 0){
logDebug("LIVINGROOM", "Item " + item.name + " turned off.")
item.sendCommand(OFF)
}
}
})
}
end
rule "Movie Time"
when
Item LivingRoomKeypadButtonE received command
then
logInfo("LIVINGROOM","LivingRoom Keypad Button E (Movie Scene) Button Pressed - Movie Mode Started")
if (LivingRoomKeypadButtonE.state == ON){
logInfo("LIVINGROOM","LivingRoom Keypad Button E (Movie Scene) Button State==ON")
logDebug("LIVINGROOM","Starting to parse through living room group members...")
gLivingRoom.members.forEach(item|{
logDebug("LIVINGROOM", item.name + " found...")
if(item.groupNames.contains("gLights")){
logDebug("LIVINGROOM", item.name + " is of group gLights")
if(item.state != MovieSceneOnLevel){
logDebug("LIVINGROOM",item.name + " set to Movie Scene On Level: " + MovieSceneOnLevel.toString)
item.sendCommand(MovieSceneOnLevel)
} else {
logDebug("LIVINGROOM", item.name + " is not of group gLights, no command sent")
}
}
})
LivingRoomKeypadButtonB.sendCommand(OFF)
} else {
logInfo("LIVINGROOM","LivingRoom Keypad Button E (Movie Scene) Button State==OFF")
logDebug("LIVINGROOM","Starting to parse through living room group members...")
gLivingRoom.members.forEach(item|{
logDebug("LIVINGROOM", item.name + " found...")
if(item.groupNames.contains("gLights")){
logDebug("LIVINGROOM", item.name + " is of group gLights")
if(item.state != MovieSceneOnLevel){
logDebug("LIVINGROOM",item.name + " set to OFF")
item.sendCommand(OFF)
} else {
logDebug("LIVINGROOM", item.name + " is not of group gLights, no command sent")
}
}
})
}
end
The issue I have is when I turn on the movie scene it turns off the button for the dinner scene, and then all the dinner lights turn off. Is there a way to avoid this?
Any suggestions are appreciated.
Thanks,
Matt