Openhab2 voice command

(Ramy Rutu) #1

How to configure or add voice command and ill be using andriod phone to speak over ???! I already tried to add string to my items and write my rules but nothing happens when i speak

(Rossko57) #2

Here’s an OH1 guide, but I believe you would follow the same principles in OH2

(Ramy Rutu) #3

I have done this already and nothing happens when i speak over !
Im using rpi3 with the latest debain and OH2 and for my andriod phone im
using habpanel with google voice command

(Ben Helps) #4

I’m tinkering with this at the moment myself. I use habdroid on my phone (can’t see habpanel in the android app store).

For me once the Google voice thing (which is SLOW) finishes the habdroid app shows the recognised phrase, and from there it’s just following your voice command rule to see if it should be matching based on keywords in that phrase.

(Ben Helps) #5

Or is habpanel just a web UI option for Chrome on android? If so that may be where it’s failing - at the point of getting the Google voice recognosed phrase into openhab

(Ramy Rutu) #6

I think i said that wrong, im using a phone website where i have saved it
to my homescreen and im trying to use voice command from habpanel !
My bad about the wrong info …

(Ben Helps) #7

Well perhaps as a test try it in the habdroid app. If it works from that then the browser based habpanel is at fault(my guess)

(Rich Koshak) #8

Yes, just a web ui, no separate app.

(Ramy Rutu) #9

Thats what i have in my items :

Switch ColorLED{ gpio=“pin:12” }
Switch RoomLIGHT{ gpio=“pin:16” }
Switch LED{ gpio=“pin:20” }
Switch TestB{ gpio=“pin:21” }
Switch TestD{ gpio=“pin:26” }
Switch TestE{ gpio=“pin:19” }

String VoiceCommand

And thats what i have in my rules :

import org.openhab.model.script.actions.*
import org.openhab.core.library.types.*
import java.util.*
rule „test example rule name“
Item VoiceCommand received command
var String command = VoiceCommand.state.toString.toLowerCase
logInfo(„Voice.Rec“,“VoiceCommand received „+command)
if (command.contains(„turn on Led“) {
else if (command.contains(„turn off led“) {

I got this from searching online and i have my website for OH2 downloaded to my home from phone browser so i can use habpanel

(Matt) #10

Hi there,
I know this is likely to be a bit late for you considering the date but I will post here anyway as this thread is placed highly on Google
I was having the same issue as you and I think I was even following the same example as you.

The way I got my set up to work was to add an additional ) in the rule.
Here is my full rule:

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

if (command.contains(“lights on”)) {
sendCommand(Light, ON)

else if (command.contains(“lights off”)) {
sendCommand(Light, OFF)


(florencio Bravo) #11

Hi, Where did you get those immages from? how do you do them?


(Ramy Rutu) #12

This is Habpenal and this pictures i posted is just from the openhab2 server… From habpenal custimize and edit

(Ramy Rutu) #13

Thank you Matt. I will try this and let you know if it works

(Pablo Rosciani) #14

I know it’s “a bit” later but as @lmarinen_946Matt said, this is the first post in google search and these are my 2 cents.

It’s necessary to enable / use Google Voice, else you wouldn’t see the mic icon in OpenHab Android App, therefore you wouldn’t be able to speak any command.


(Mathias Ewald) #15

I still couldn’t get it to work despite reading all of this. I am using the openHAB Android app and I can see the microphone icon in the top right corner. I can speak a command and can see that it was understood correctly.

In the config, I have

String VoiceCommand


rule "Voice Control"
    Item VoiceCommand received update
    val txt = VoiceCommand.state.toString.toLowerCase
    logInfo("Test","VoiceCommand received "+txt)

but this rule never triggers. I can trigger it my using Karaf to send an update to the item like

smarthome:update VoiceCommand test

(Ben Helps) #16

Just a guess, but try changing received update to received command

(Mueller Ma) #17

Please make sure Default Human Language Interpreter is set to Rule-based Interpreter: http://openhab:8080/paperui/index.html#/configuration/system and select the correct item here: http://openhab:8080/paperui/index.html#/configuration/services?tab=voice Rule Voice Interpreter => Configure => Select correct item.

(Mathias Ewald) #18

Nice, that worked!