.
Overview.
I will provide the voice assistant to the system using the Snips platform. This will allow user to talk to the openHAB system.
.
How it worksSnips and openHAB are running on two separate Raspberry Pi devices. The Snips is running on a Maker Kit, while openHAB is running on another Pi together with a DHT11 sensor and two LEDs (red and green)
Snips provides the voice interface for the system. User can ask for temperate and humidity data. Snips will fetch the values from openHAB thru REST API.
When user asks to turn on or off a LED. Snips will publish an intent to a MQTT topic which a rule is setup in openHAB to monitor if there is a state change. Upon a state change, openHAB will turn on or off the particular LED accordingly.
.
Setup Raspberry Pi and install Snips.
The Voice Interaction Base Kit comes with included Raspberry Pis and all the necessary software and latest Raspbian installed.
To manually install Pi, follows this link.
To manually install Snips for Pi, follow this link.
.
Test a Snips simple assistant.
I created an assistant and add the seeed's Relay&Temperature&Humidity app. I generated some audio files using Google text-to-speech API for the testing. Here is a video of the test.
Here is another video with the Ask Joke skill:
.
Install openHAB.
Initially I was thinking to use the same Raspberry Pi to house the openHAB. But when integrating the two, I found out that GPIO pins were not available as they are being used with the respeaker. So, I decided to use another Raspberry Pi for the openHAB server.
Download openHAB here.
Installation guide for Pi is here.
.
Here is a picture of the Raspberry Pi, DHT11 sensor, red and green LEDs:
Here is the control dashboard of the openHAB web:
.
Integrate Snips and openHAB.
Setup MQTT connection between Snips and openHAB
Install MQTT Binding.
Create MQTT bridge at openHAB
Create MQTT Thing Binding for green and red LEDs.
.
Create openHAB Assistant
Create the openHAB Assistant at snips.io with the "temp hum red green LEDs" (temperature, humidity and red and green LEDs) skill.
.
Add LEDs to openHAB
Install GPIO Binding.
Setup the red and green LEDS in the snips.items
file with the following items:
Switch GPIO_RED_LED "Red LED" (LivingRoom) { gpio="pin:27 force:yes" }
Switch GPIO_GREEN_LED "Green LED" (LivingRoom) { gpio="pin:17 force:yes" }
.
Setup rules to turn on/off red and green LEDs upon state changes to their MQTT channel topics:
.
Add DHT11 to openHAB
At first, I activated the device tree overlay for the DHT11. But there was problem while reading data. After reading some of the documents and tutorials, I installed the Exec Binding and create the temperature and humidity data as strings. These data can be accessed via REST API. Thus Snips can directly retrieve these data from openHAB.
.
.
This is the script (node.js and javascript) which reads the temperature value. There is a similar script reading humidity value.
var sensor = require('node-dht-sensor');
sensor.read(11, 4, function(err, temperature, humidity) {
if (!err) {
console.log(temperature.toFixed(1));
}
});
To access these values from Snips thru REST API, I use the following URL.
To read humidity data:
http://192.168.2.233:8080/rest/items/exec_command_298d9701_output/state
To read temperature data:
http://192.168.2.233:8080/rest/items/exec_command_7b587029_output/state
.
Photos and Video.
.
.
Future enhancements- Add different types of sensors and actuators
- Simpler configuration for the integration between Snips and openHAB
- Richer user interaction for the assistant
.
SummaryThis is the initial version of the system. The voice user interface has a simple intent composition. The configuration steps to integrate both the Snips and openHAB involves changes to multiple set of files and settings. In the future version, this will be simplified and consolidated.
.
Comments