Hi,
That’s a brilliant explanation, thanks so much.
I’ve written a rule that does almost everything I want it to do and almost works perfectly…
Item:
// Alexa command item
Switch aGF_LR_Lights_All "Living Room Lights" (gAlexa_Lights) {alexa="Switchable"}
// Groups to control items
Group:Dimmer gSpots_LR_B_All "Living Room Spots All ON"
Group:Dimmer gSpots_LR_CT_All "Living Room Spots All CT"
// Actual items
Dimmer Spot_GF_LR_1_Brightness "GF LR Spot 1 Brightness" (gSpots_LR_B_All) {channel="hue:blah:brightness"}
Dimmer Spot_GF_LR_1_ColorTemp "GF LR Spot 1 ColorTemp" (gSpots_LR_CT_All) {channel="hue:blah:color_temperature"}
Rule:
rule "Select Spotlight Scene Rule"
when
Member of gAlexa_Lights changed
then
val caseItem = triggeringItem.name.split("_").get(3)
logInfo(logName, "caseItem - " + caseItem)
val caseValue = triggeringItem.state
logInfo(logName, "caseValue - " + caseValue)
if(caseValue == OFF)
{
val caseBrightness = 0
val caseColorTemp = 0
logInfo(logName, "OFF - caseBrightness set to " + caseBrightness + " / caseColorTemp to " + caseColorTemp)
}
else
{
// Run the Spotlight Scene Selector
switch caseItem {
case "All" : {
// Settings for ALL LIGHTS
val caseBrightness = 100
val caseColorTemp = 14
logInfo(logName, "ALL - caseBrightness set to " + caseBrightness + " / caseColorTemp to " + caseColorTemp)
}
case "These" : {
// Settings for THESE LIGHTS
val caseBrightness = 100
val caseColorTemp = 14
logInfo(logName, "THESE - caseBrightness set to " + caseBrightness + " / caseColorTemp to " + caseColorTemp)
}
case "Sofa" : {
// Settings for SOFA LIGHTS
val caseBrightness = 100
val caseColorTemp = 14
logInfo(logName, "SOFA - caseBrightness set to " + caseBrightness + " / caseColorTemp to " + caseColorTemp)
}
case "3" : {
// case 3
}
case "4" : {
// case 4
}
}
}
// Create the string to send to GateKeeper
val SpotGroupB = ("gSpots_LR_B_" + caseItem + "#" + caseBrightness)
logInfo(logName, "SpotGroupB - " + SpotGroupB)
val SpotGroupTC = ("gSpots_LR_TC_" + caseItem + "#" + caseColorTemp)
logInfo(logName, "SpotGroupTC - " + SpotGroupTC)
end
It triggers when any member of my gAlexa_Lights changes, (that group consists of Alexa exposed dummy items switches)
It then gets the triggereditem name and state to let me work out which alexa command was called, (my idea is that the commands will be used to turn on the different scenes I need ‘alexa, turn on the living room lights’, ‘alexa, turn on the sofa lights’ etc).
It then runs an if statement it see if any are calling OFF, in which case turn all the lights off, else run a case statements to see what brightness and colortemp it should use.
It then gets all the different vals and puts them into a string, matching the relevant item group, to use to send to the GateKeeper.
All is working perfectly, (see the logs below), except the bit where I get the brightness to add onto the string for after the # for the GateKeeper command as per your comment:
When I tell Alexa, ‘turn on the living room lights’ I get the following in the logs:
2020-04-29 19:49:13.399 [INFO ] [clipse.smarthome.model.script.lights] - caseItem - All
2020-04-29 19:49:13.403 [INFO ] [clipse.smarthome.model.script.lights] - caseValue - ON
2020-04-29 19:49:13.410 [INFO ] [clipse.smarthome.model.script.lights] - ALL - caseBrightness set to 100 / caseColorTemp to 14
2020-04-29 19:49:13.416 [INFO ] [clipse.smarthome.model.script.lights] - SpotGroupB - gSpots_LR_B_All
2020-04-29 19:49:13.422 [INFO ] [clipse.smarthome.model.script.lights] - SpotGroupTC - gSpots_LR_TC_All
2020-04-29 19:49:13.428 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Select Spotlight Scene Rule': The name 'caseBrightness' cannot be resolved to an item or type; line 128, column 61, length 14
Everything populates ready except the caseBrightness item…my brainwave in creating this has passed and now I’m failing to see what is wrong. Once I’ve got this bit it’s onto adding the GateKeeper rule and passing it the string created here, and Bob should be my metaphorical Uncle…
Does the rule make sense and what have I missed to get the caseBrightness in please?