LastVoiceCommand and proper handling

I’m using the LastVoiceCommand to allow shortcuts for e.g. turning on the main light in a room with a simple “light on” - because there are multiple lights in that room. For that I use a DSL rule that listens for the item change of the LastVoiceCommand.

In the past that worked good. Starting with OH 3.2 or going to the latest SNAPSHOT of the Echo Control binding that changed somehow. Now, If I say “light on”, it turns on. If I switch off the light manually and say again “light on” nothing happens. This is most likely due to the fact, that the item value does not change - since it still has the former “light on” value saved. Hence it does not trigger the rule.

Maybe I simply didn’t spot it - but I think that was not the case before. So only if I speak to Alexa in between about something else and say again “light on” it works as expected. Now I’m wondering what would be the best approach here. Setting the value to e.g. “” manually in the rule once the command was processed? Or is there some kind of option that can be set on the binding to achieve the same?

Which version of the binding is installed on your system.
Is it the latest version from the third party marketplace ( SmartHome/J Amazon Echo Control Binding ) ?

I manually installed 3.2.10 from the github repo to the addons folder.

Please use this version of the binding. You will need to manually install it. I have LOTS of rules watching LastVoiceCommand.

https://repo1.maven.org/maven2/org/smarthomej/addons/bundles/org.smarthomej.binding.amazonechocontrol/3.2.11/org.smarthomej.binding.amazonechocontrol-3.2.11.kar

Best, Jay

Jay please explain why…
The link Jay is posting is a binding version by Jan (JNK) and he has done a lot of work to fix this particular feature

From my understanding, the core of OH has an issue with flipping Things offline/online with the OH Echo version of the binding.

I have 3 other bindings doing that exact thing which is Hue, HP Printer and Onkyo. Its milliseconds between offline and online status. With my 2 Hue bridges, its taking over 30 items offline at once, very frustrating.

Jan, the developer, tried to get this fixed at the core level but it didnt go anywhere. This is one reason why there is a bunch of bindings Jan has taken on outside.

The Echo binding he’s updating is rock solid. I have 15 Echo’s on it and 9 Tiles. It is very heavily used by the household.

Again, this is my understanding.

Best, Jay

1 Like

I actually re-read this and discovered I am addressing this situation in my code.

// Global variable in .rules
var  nullValue = new DateTimeItem("should be empty").state	

// In the actual rule
Echo_Basement_LastVoiceCommand.postUpdate(nullValue)

Best, Jay

Huh so even if I upgrade from .10 to .11 it won’t fix it as it sounds. Since .10 is already the custom version provided by Jan to address the previous issue with LastVoiceCommand stopped working completely.

Maybe then it could work to create a generic rule that listens for all memebers of “Echos” for value change. If it is triggered, add a timer (or sleep) for 1-2 seconds (give actual rules the chance to process), then set the command to null or so. Then one does not have to take care for every rule. Could that work out?

That seems to do the trick for me:

rule "Reset Last Voice Command"
when
    Member of EchoCmds changed
then
    if (triggeringItem.state == "clear") {
        return;
    }

    var Timer clearTimer = createTimer(now.plusSeconds(1), [ |
        triggeringItem.postUpdate("clear");
    ]);
end

That will work, but what if two people use 2 different echos around the same time? Most likely only one would work. If that will never happen, then your solution will be fine.

Btw, the .10 to .11 version difference has some bug fixes in it also. It also includes the Tile integration piece.

Best, Jay

That indeed changed. You need to change the trigger to „received update“.

1 Like

Hey, that did the trick, thanks! So no need for the manual clear then, nice.
So

rule "Licht"
when
    Member of EchoCmds received update "licht an" or
    Member of EchoCmds received update "licht aus"
then
...

works for me.

That will work, but what if two people use 2 different echos around the same time?

That would have been no issue, as the rule would only clear the very one, that had been spoken to - after 1 second.

Background: The old implementation did the following:

  • check if the last lastVoiceCommand is equal to this lastVoiceCommand
  • if so, send an empty state update
  • if not, send the update

Effectively this missed every second update if the same command was issued again. This is clearly not what was intended (and is very counter-intuitive in my opinion, because it depends on the command before if a state update is send or discarded). Therefore we decided to change this to just send the update each time we receive it from Amazon, the drawback is what you encountered: the same command does not trigger changed.