Hi,
I am trying to use the voicecommand to set an alarm like “Alarm in 5 minutes oven”
After, the 5 minutes, it should say through my chromecast audio “Alarm over after 5 minutes oven”
rule "Voice control alarm"
when
Item VoiceCommand received command
then
var String command = VoiceCommand.state.toString.toLowerCase
logInfo("voice control" ;"VoiceCommand received----" + command+ "----";)
var String cmd = null
var Timer timer = null
if ( command.contains("alarm") || command.contains("alarme ") {
command = command.replace("alarme ")
command = command.replace("alarm ";)
command = command.replace("dans ")// command = command.replace(" in ","")//
val SplitVoiceTimer = command.state.toString.split(" ")
val myminutes = Float::parseFloat(SplitVoiceTimer get(0) ) as Number //212
val cmd = SplitVoiceTimer get(1)
if(timer==null) {
timer = createTimer(now.plusMinutes(myminutes)) [
say ("Alarme apres "+ minutes + " minutes pour "+ cmd)
timer = null
]
}
}
-
What is your opinion on this code ?
-
the fact is that if the purpose of the reminder is composed of two words, it will give back only the first.
-
i have looked inxtend/documentation, i didn’t find a method to find the first occurence of a string or to find the position in a string on array item.
Thanks in advance for your help