I’m trying to create a rule for dimming some lights on my porch, but getting error when trying to use ternary expression. If I remove the line, there’s no error in the script otherwise. Here’s the scritpt;
var Timer runTimmer = null
rule "Motion sensor light"
when
Item MotionDetector_Porch changed to ON
then
if (Astro_SunPhase.state == "Dag") {
if (runTimmer === null) {
logInfo("LAMP STATE","Prev state: " + Light_Entry_Dimmer.state)
var prevLightState = (Light_Entry_Dimmer.state > 50) ? Light_Entry_Dimmer.state : 50
Lamp_Kitchen.sendCommand(50)
runTimmer = createTimer(now.plusMinutes(1), [|
Lamp_Kitchen.sendCommand(prevLightState)
runTimmer = null
])
} else {
runTimmer.reschedule(now.plusMinutes(1))
}
}
end
The error thrown is;
[WARN ] [del.core.internal.ModelRepositoryImpl] - Configuration model 'daylight.rules' has errors, therefore ignoring it: [12,57]: no viable alternative at input '?'
[12,84]: mismatched input ':' expecting '}'
[21,2]: extraneous input '}' expecting 'end'
In have used Ternary expression a lot in PHP, and what I could read the usage is the same in Xtend. Tried to search for the error, but didn’t find anything related to ternary expressions. Any idea?
[EDIT] Btw, ignore the usage of Lamp_Kitchen, it’s just so I don’t have to be outside in the cold while testing it