Yes, but also another problem is the space between 20 percent ; 20% havn’t spacing.
I modify the rule as follows and it works properly
rule "Voice control"
when
Item VoiceCommand received command
then
var String command = VoiceCommand.state.toString.toLowerCase
logInfo("Voice.Rec","VoiceCommand received "+command)
var State newState = null
// find new state, toggle otherwise (if possible)
if (command.contains("gradi") || command.contains("percento")) {
// extract new state (find the digits in the string)
var java.util.regex.Pattern p = java.util.regex.Pattern::compile(".* ([0-9]+) (gradi|percento).*")
var Matcher m = p.matcher(command)
if (m.matches()) {
newState = new StringType(m.group(1).trim())
}
}
else if (command.contains("%")) {
// extract new state (find the digits in the string)
var java.util.regex.Pattern p = java.util.regex.Pattern::compile(".* ([0-9]+)(%).*")
var Matcher m = p.matcher(command)
if (m.matches()) {
newState = new StringType(m.group(1).trim())
}
}
Voice control rule follow....