var variable_timer
val Integer TIMER_TIME = TestTimer.state as Number
rule "Alexa Test"
when
Item MySmartphone changed from OFF to ON
then
Echo_Livingroom_Speak.sendCommand("Hello")
variable_timer = createTimer(now.plusMinutes(TIMER_TIME), [|
Echo_Livingroom_Speak.sendCommand("Again Hello")
])
end
But when the rule starts I get the error message:
Rule ‘Alexa Test’: An error occurred during the script execution: Could not invoke method: org.joda.time.DateTime.plusMinutes(int)
Move the val to be inside the rule, opposed to being set as a global val.
Example:
var variable_timer
rule "Alexa Test"
when
Item MySmartphone changed from OFF to ON
then
Echo_Livingroom_Speak.sendCommand("Hello")
val Integer TIMER_TIME = TestTimer.state as Number
variable_timer = createTimer(now.plusMinutes(TIMER_TIME), [|
Echo_Livingroom_Speak.sendCommand("Again Hello")
])
end
Since your not doing anything in the rule with the var you can omit that as well.
rule "Alexa Test"
when
Item MySmartphone changed from OFF to ON
then
Echo_Livingroom_Speak.sendCommand("Hello")
val Integer TIMER_TIME = TestTimer.state as Number
createTimer(now.plusMinutes(TIMER_TIME), [|
Echo_Livingroom_Speak.sendCommand("Again Hello")
])
end
ok well your code matches Vincent and Udo’s versions of the code
maybe log value of TIMER_TIME before attempting to create the timer?
edit: maybe restart OH help clear old rule out?
edit2: value set in sitemap? make sure expected input sorry if did already