Home Automation – OpenHab @ Raspberry – Voice control Setup

How to configure Voice control in OpenHab Home Automation system

Note > I assume that you have already OpenHab up and running including your items and sitemaps. This is only description of Voice Control setup using their official Android app.

Step 1] add to items
sudo nano /opt/openhab/configurations/items/home.items
add to new line „String VoiceCommand“

Step 2] create /rule/home.rules
sudo nano /opt/openhab/configurations/rules/home.rules

my example :
import org.openhab.model.script.actions.*
import org.openhab.core.library.types.*
import java.util.*

rule „test example rule name“
when
Item VoiceCommand received command
then
var String command = VoiceCommand.state.toString.toLowerCase
logInfo(„Voice.Rec“,“VoiceCommand received „+command)

if (command.contains(„turn on led“) {
LED.sendCommand(ON)
}

else if (command.contains(„turn off led“) {
LED.sendCommand(OFF)
}

else if (command.contains(„turn off receiver“)||(command.contains(„turn off the receiver“) {
Reciever.sendCommand(OFF)
}

else if (command.contains(„turn on receiver“)||(command.contains(„turn on the receiver“) {
Reciever.sendCommand(ON)
}

end

3] install android app Openhab called „HABdroid“ to your phone and connect it to Openhab

4] TEST IT – tap record button and say your command
you will see captured wording in log (/opt/openhab/logs/openhab.log)

screenshot_2016-10-05-21-54-08

screenshot_2016-10-05-21-54-01

5] IT WORKS – simple ..

read more about it here
https://github.com/openhab/openhab/wiki/Controlling-openHAB-with-your-voice
https://github.com/openhab/openhab/wiki/Samples-Item-Definitions#how-to-set-up-voice-control-for-use-with-habdroid

Napsat komentář