Hello everyone, after a long time I am revisiting this thread once again.
My rule looked something like this in the end:
var words_to_numbers = newHashMap(
"eine" -> 1, "zwei" -> 2, "drei" -> 3, "vier" -> 4, "fünf" -> 5, "sechs" -> 6, "sieben" -> 7, "acht" -> 8, "neun" -> 9, "zehn" -> 10, "elf" -> 11, "zwölf" -> 12, "dreizehn" -> 13, "vierzehn" -> 14, "fünfzehn" -> 15, "sechzehn" -> 16, "siebzehn" -> 17, "achtzehn" -> 18, "neunzehn" -> 19, "zwanzig" -> 20
)
rule "Alexa Timer"
when
Member of gLastVoiceCommand changed
then
val last_voice_command_Kueche = KCheEchoDot_LastVoiceCommand.state.toString
if (last_voice_command_Kueche.contains("timer") && !last_voice_command_Kueche.contains("stop") && !last_voice_command_Kueche.contains("abbrechen") && !last_voice_command_Kueche.contains("wie")) {
val response_list = last_voice_command_Kueche.split(" ")
for (number : words_to_numbers.keySet) {
if (response_list.contains(number)) {
time_unit_Kueche = response_list.get(response_list.indexOf(number) + 1)
timer_duration_Kueche = null
durationKueche = words_to_numbers.get(number)
switch (time_unit_Kueche) {
case "stunde" : {
timer_duration_Kueche = now.plusHours(words_to_numbers.get(number))
}
case "minute" : {
timer_duration_Kueche = now.plusMinutes(words_to_numbers.get(number))
}
case "sekunde" : {
timer_duration_Kueche = now.plusSeconds(words_to_numbers.get(number))
}
case "stunden" : {
timer_duration_Kueche = now.plusHours(words_to_numbers.get(number))
}
case "minuten" : {
timer_duration_Kueche = now.plusMinutes(words_to_numbers.get(number))
}
case "sekunden" : {
timer_duration_Kueche = now.plusSeconds(words_to_numbers.get(number))
}
}
}
timerAlexaKueche = createTimer(timer_duration_Kueche, [|
timerAlexaKueche.cancel()
timerAlexaKueche = null
EchoShowWohnzimmer_Announcement.sendCommand('Küchentimer')
EchoShowWohnzimmer_AlarmSound.sendCommand('ECHO:system_alerts_melodic_02')
if (stopAlexaTimerSoundKueche === null) {
stopAlexaTimerSoundKueche = createTimer(now.plusSeconds(20)) [|
stopAlexaTimerSoundKueche.cancel()
stopAlexaTimerSoundKueche = null
EchoShowWohnzimmer_AlarmSound.sendCommand('')
KCheEchoDot_AlarmSound.sendCommand('')
]
}
])
The solution which 5iver has posted and has helped me fine tune in private messages back then worked quite good but is quite restrictive. Only for full commands like set timer for xx minutes but not for commands like set timer for 10 minutes and 25 seconds or set timer for 1 hour 20 minutes and 40 seconds.
I am wondering what the best approach would be to support cases like that aswell?
Is a rule like above still a good way/start of realizing it or are there more efficient ways to solve something like this nowadays?
EDIT:
Just to give a short descriptive summary of what I am trying to Achieve.
I have an Alexa Device in my Livingroom and in my Kitchen.
Almost always I set a timer while I am cooking/baking in the Kitchen for x amount of time and then leave the kitchen and go into the living room.
Now I want to have the Alexa device in the Living room to make noise/say something aswell when the timer in which I set on my Kitchen Alexa Device finished.
(Otherwise I often do not hear the timer I have set in the Kitchen)