Voicecontroll repeats last voice command

Tags: #<Tag:0x00007fe746eac998> #<Tag:0x00007fe746eac858>

Hey there,

I’m new in the community and I hope you can help me out with the following problem.

I tried to implement rule-based voicecontroll via the Android-App. I can execute the programmed commands, but often the last voice command will be repeated. When I say “lampen an” the lamps switch to “ON”. Then I say “rollo ab” and nothing happens. The log shows me, that a command was received and executed (again “lampen an”).

rule "Voice"
Item VoiceCommand received command
var String command = VoiceCommand.state.toString.toLowerCase
logInfo("Voice.Rec","VoiceCommand received "+command)

if (command.contains("lampen an")) {
else if (command.contains("lampen aus")) {

else if (command.contains("rollo ab")) {
else if (command.contains("rollo auf")) {

else if (command.contains("rollo wohnzimmer ab")) {
else if (command.contains("rollo wohnzimmer auf")) {

Might the log show us as well?

That is a race condition. openHAB commands are not states.
Commands might cause a state change … eventually.
If you look in your events.log you’ll probably see this sequence.

But here, grabbing the state of an Item immediately after a command will almost always give you the old state, before the command has any effect on it.

Isn’t it the command you are really interested in, not the state?
That is available to your rule as an implicit variable receivedCommand

Thanks for the quick answer.

2020-01-09 11:51:36.090 [INFO ] [pse.smarthome.model.script.Voice.Rec] - VoiceCommand received lampen an
2020-01-09 11:51:48.819 [INFO ] [pse.smarthome.model.script.Voice.Rec] - VoiceCommand received lampen an

First time I said “Lampen an”, second time I said “Lampen aus”. Received VoiceCommand was in both times “lampen an”.

var String command = VoiceCommand.state.toString.toLowerCase

Do you mean, I have to replace “state” with “receivedCommand”? That didn’t work.

But “Received VoiceCommand” is not the command that the rule received. It is a variable that you just created using the state of an Item.
Commands and states are not the same thing.
Commands do not instantly influence states

It works. Show us what you did.
Hint ; receivedCommand is exactly what it says. It is not an Item, you do not specify an Item name. It is not an Item, you do not take the .state of it. It is the command. You can get a string version of it

var String myCommand = receivedCommand.toString.toLowerCase

As good practice, I’d really avoid naming your variable ‘command’, that’s a reserved word and could give you troubles elsewhere.


That worked!!! Thanks!

1 Like