Purpose of this project

Everyone has been talking about smart home for some years now. The market is still growing and dominated by the big A, G and the other big A.

An essential part of Smart Home is the ability to control your devices by voice freeing you from complicated menu structures and GUI limitations of the vendors apps.

So far so good, BUT there is one big withdraw in all of this: the primarily interest of these companies lies in collecting and analyzing their users data. This can be for many purposes: improving recognition results, testing of audio quality but also for more disconcerting things such as user-based advertisment. With those companies already knowing way too much about their users habits e.g. by their surfing habits or cloud-based photo streams more and more people recognize the disadvantages of cloud based products. But does this mean that there is no other chance than Smart Home becoming a red rag?

The answers is: NO. My project shows a secure way of controlling a Philips Hue light bulb by voice without any users data being sent to external services. That's made possible by using the voice recognition system vicCONTROL industrial by the german company voice INTER connect GmbH and a Raspberry Pi. The natural language understanding capabilities are at least equal to the big players on the market, futhermore it supports - compared to Amazon Alexa's 7 - 23 more languages, in total 30 languages.

While there might be still people around you not being familiar with controling devices via voice a GUI solution would come in handy as well. That's why in this project we will also implement the open source automation software [OpenHAB](https://openhab.org) running on the Raspberry Pi. OpenHAB comes also with an Android/iOS companion app enabling you to control your devices also via your Smartphone.

The interface to the Philips Hue Lamp is Philips' own Hub called "Philips Hue Bridge". The light bulb itself connects via WiFi with the Bridge which enables high distances between the setup and the light bulb itself.

With this solution you're as flexible as possible at creating your speech dialog and can control the vocabulary to be recognized e.g. by adding synonyms. On the other hand you can limit the vocabulary to just the functions you need minimizing the risk of false recognitions and thus unwanted actions.

Preparations

I recommended to check the IP address of the Philips Hue Bridge, it can be found e.g. using a network scanner or through the GUI interface of the router.

After the bridge is connected to the router and the power outlet, it should get an IP automatically if DHCP is activated at the router. In my setup it is 192.168.178.32. With the help of the Philips Hue App (available in the Play Store / App Store) the lamp than can be connected.

Installation of OpenHAB at the Raspberry Pi

The easiest way to set up a new Raspberry Pi for this project is to install OpenHABianPi. This is an operating system for the Raspberry Pi with an included OpenHAB installation. The transfer from OpenHABian to the SD card for the Raspberry Pi is done just like for the vicCONTROL industrial via a tool like "Balena Etcher", otherwise the OpenHAB installation is done according to the instructions on the OpenHAB documentation page.

Once the Raspberry Pi has booted, you should be able to access the OpenHAB user interface by opening the website

http://openhabianpi:8080.

Setting up the Philips Hue lamp in OpenHAB

Click the button "PaperUI"

Navigate to "Configuration" - "Bindings"

Click the blue "+" and search for "Hue Binding" (you can also use the search bar) and install it

Follow the displayed steps (you need to press the button at the bridge briefly)

Navigate to "Inbox" - "Bindings"

Install the "MQTT Binding"

Set up of bindings inside OpenHAB

The connection between the Raspberry Pi (or any other device running an OpenHAB server) can be established with the supplied cross-over-cable or alternatively via a LAN router in between.

To directly connect the two devices

plug in the LAN cable

log in to the Raspberry Pi via SSH (e.g. with the free software "Putty") and change the IP adress of the Raspberry Pi manually to 192.168.3.10 with the command

sudo ifconfig eth0 192.168.3.10

to access the vicCONTROL industrial from the Raspberry Pi call ssh root@192.168.3.11 (factory state)

The IP adresses of both devices can of course be changed so that this setup can also be integrated into an existing network.

To connect the devices via a router

set vicCONTROL industrial to an IP adress inside the range of your router (e.g. 192.168.178.44 with the routers gateway set to 192.168.178.1)

connect the vicCONTROL industrial to the router via LAN cable

set the voice control inside the menu of the router to the same IP address

Creating the speech dialog with vicSDC

vicCONTROL industrial comes with a registration code for the web-based speech dialog creation tool "vicSDC".

Schematic connection between vicSDC and vicControl industrial hardware

Here you can set up your voice control and define the possible commands and values to fit the voice control your use case.

Navigate to https://vicsdc.voiceinterconnect.de

https://vicsdc.voiceinterconnect.de Register with the provided license code of your vicCONTROL industrial purchase

Navigate to "Settings" and setup a wake word (e.g. "Hello voice control") that acitivates the voice control

Under "Intents" create the lamp, e.g. with the name "desk_lamp"

Navigate to "Slots" and create the functions that should be controlled (in this example it is "Brightness", "Saturation" and "Hue")

Setup the values that the Slots can have under "Values and Synonyms" by clicking a previously created Slot. You can add as much synonyms as you want that you or another user might use to describe the same value (e.g. "bright" might also be "100 percent" or "maxmimum"). In this case we define 5 steps: 0%, 25%, 50%, 75% and 100%.

Go back to "Intents", click the created intent and enter example sentences that you or other users might say to trigger a desired action. Inside these example sentences mark the values (e.g. "bright") and select from the pop up menu the respective slot (e.g. "Brightness")

The result can look like this.

Set up of Slots inside vicSDC

After this the vicCONTROL industrial provides the recognized commands as a JSON formated Array which looks like this:

JSON formated output of vicCONTROL industrial hardware

OpenHAB configuration

When configuring the OpenHAB application there are several steps to do.

Create an MQTT Broker by navigating to "Configuration" - "Bindings" - "MQTT Thing Binding" and clicking "MQTT Broker"

Giving the MQTT Broker a name is optional while the IP adress is mandatory which is the same IP adress as the vicCONTROL industrial (in this case 192.168.3.11)

Repeat the first step but create now a "Generic MQTT Thing"

Also here a name is optional but "Bridge" has to be selected which is the connection to the (just created) broker (the given name is shown at clicking "Bridge Selection")

Now that it it's setup it has to be configured under "Configuration" - "Things" by choosing the just created Thing

Click the blue "+" at "Channels" and choose "Text Value" (repeat this step two times with "Text Value" and one time with "Number Value")

For a better overview it is recommended to name these Channels, e.g. "intent" and "name" for Text Values and "dimmer_speech" for the Number Value

At the input properties is a field named "MQTT state topic" where for all Channels "speech/output" has to be entered. The Channels are speciefied furthermore by clicking "Show More" in the area "Incoming Value Transformation":

"intent": JSONPATH:$.content.intent

"name": JSONPATH:$.content.slots.[0].name

"dimmer_speech": JSONPATH:$.content.slots.[0].value

Channel configuration inside OpenHAB

Creation of items and sitemap

Now that all basic configurations are done it is recommended to proceed working with the free software "VS Code" for further building the OpenHAB environment, particulary the items and sitemap configuration. An extensive documentation about this can be found here.

The configuration of three items is crucial for the voice control:

String GF_LivingRoom_Sprachsteuerung "Sprachsteuerung" <microphone> (GF_LivingRoom) {channel="mqtt:topic:speech_in:intent", channel="mqtt:topic:speech_in:dimmer_speech", channel="mqtt:topic:speech_in:name"} String LivingRoom_Sprachsteuerung_intent "Sprachsteuerung Objekt" <none> (GF_LivingRoom_Sprachsteuerung_g, gSprachsteuerung) {channel="mqtt:topic:speech_in:intent"} Number LivingRoom_Sprachsteuerung_dimmer "Sprachsteuerung Dimmer" <dimmer> (GF_LivingRoom_Sprachsteuerung_g, gSprachsteuerung) {channel="mqtt:topic:speech_in:dimmer_speech"} String LivingRoom_Sprachsteuerung_name "Sprachsteuerung Wert" <returnpipe> (GF_LivingRoom_Sprachsteuerung_g, gSprachsteuerung) {channel="mqtt:topic:speech_in:name"} Contact LivingRoom_Sprachsteuerung_aktiv "Sprachsteuerung hört" <switch> (GF_LivingRoom_Sprachsteuerung_g, gSprachsteuerung) {channel="mqtt:topic:speech_in:active"}

The 4th item is a merging of all channels since this allows the triggering to the general event of the voice control receiving something.

Creation of rules

Rules in OpenHAB allow the running of certain processes after an event occurs. With the help of the following rule it is possible to control three items which have to have been created in vicSDC beforehand:

Ecklampe

Stehlampe

Lichter

rule "VIC" when Item GF_LivingRoom_Sprachsteuerung received update then var String intentValue = transform("JSONPATH", "$.content.slots.[0].value", LivingRoom_Sprachsteuerung_dimmer.state.toString) var String device = transform("JSONPATH", "$.content.intent", LivingRoom_Sprachsteuerung_intent.state.toString) var String which_value = transform("JSONPATH", "$.content.slots.[0].name", LivingRoom_Sprachsteuerung_name.state.toString) logInfo("Wert: ", intentValue) logInfo("Welches Gerät: ", device) logInfo("Was wird geändert: ", which_value) if (device == "ecklampe") { if (which_value == "helligkeit" && intentValue > "0") { LivingRoom_Ecklampe_Toggle.sendCommand (ON) LivingRoom_Ecklampe_Dimmer.sendCommand(intentValue) } else if (which_value == "farbtemperatur") { LivingRoom_Ecklampe_temperature_ColorTemp.sendCommand(intentValue) } else if (which_value == "helligkeit" && intentValue == "0") { LivingRoom_Ecklampe_Toggle.sendCommand(OFF) } } else if (device == "stehlampe") { if (which_value == "helligkeit" && intentValue > "0") { LivingRoom_Stehlampe_Toggle.sendCommand(ON) LivingRoom_Stehlampe_Dimmer.sendCommand(intentValue) } else if (which_value == "farbtemperatur") { LivingRoom_Stehlampe_temperature_ColorTemp.sendCommand(intentValue) } else if (which_value == "helligkeit" && intentValue == "0") { LivingRoom_Stehlampe_Toggle.sendCommand(OFF) } } else if (device == "lichter") { if (which_value == "helligkeit") { LivingRoom_Stehlampe_Dimmer.sendCommand(intentValue) LivingRoom_Ecklampe_Dimmer.sendCommand(intentValue) if (intentValue > "0") { LivingRoom_Light.sendCommand(ON) LivingRoom_Ecklampe_Toggle.sendCommand(ON) LivingRoom_Stehlampe_Toggle.sendCommand(ON) } else if (intentValue == "0"){ LivingRoom_Light.sendCommand(OFF) LivingRoom_Ecklampe_Toggle.sendCommand(OFF) LivingRoom_Stehlampe_Toggle.sendCommand(OFF) } } else if (which_value == "farbtemperatur") { LivingRoom_Ecklampe_temperature_ColorTemp.sendCommand(intentValue) LivingRoom_Stehlampe_temperature_ColorTemp.sendCommand(intentValue) } } else if (device == "farblampen"){ if (which_value == "helligkeit" && intentValue > "0") { LivingRoom_Stehlampe_Dimmer.sendCommand(intentValue) LivingRoom_Ecklampe_Dimmer.sendCommand(intentValue) } } end

This rule enables to control three things with vicCONTROL industrial. In this particular case it's two Philips Hue lamps and one switch ("LivingRoom_Light") which has an analog lamp connected. This solution is scalable, the predefined values are those defined in vicSDC. Here it's four Intents:

Ecklampe

Stehlampe

Lichter

Farblampen

and three Slots:

Helligkeit

Farbtemperatur

Sättigung

The saturation ("Sättigung") is not part of the rule. It can be easily implemented, as well as e.g. a radtiator thermostat. For the second one a Slot "Temperatur" needs to be supplemented in vicSDC to which meaningful values need to be attached (e.g. 16 °C, 18 °C,...). As additional Intent the radiator is added. A possible example sentence than would be:

Set the radiator to 20 degrees.