Linux Format

OPENHAB and Mycroft

Use the power of Ubuntu’s openhab appliance and the Mycroft Voice Assistant to voice-enable your home.

-

The open Home Automation Bus (openhab) can connect all the diverse IOT appliances that may or may not be beginning to proliferat­e around your home. Typically these devices all have their own, often proprietar­y applicatio­ns, but often under the bonnet they use open source protocols – and when they don’t, people have figured them out enough to plug them into openhab. We’ve covered installing it (and indeed Mycroft over the page) back in LXF249, but this time around we’re going to do it a little differentl­y, because Canonical recently released the openhab Ubuntu Appliance for the Raspberry Pi. This means we can write their SD card image, boot it and have a fully functional web-based home automation server.

In order to use these Ubuntu Appliances (there are currently four others besides openhab, and more are on the way), you’ll need to sign up for Ubuntu SSO (Single Sign On) at https://login.ubuntu.com. It’s free and you can use it all over the Ubuntu web ecosystem. Once you’ve done this you’ll want to generate an SSH keypair and upload the public key, so that you can use your Ssh-reinforced SSO to login to your appliance. You may already have generated an SSH key, in which case you probably don’t want to overwrite it. Check by running

$ ls ~/.ssh/id_rsa.pub

If no such file exists, generate it with

$ ssh-keygen -t rsa

and press Enter to accept the default location. Once the key is generated, run cat ~/.ssh/id_rsa.pub and copy the contents to the clipboard. Log into Ubuntu SSO and go to the SSH keys section. Paste the contents into the Public SSH Key box and hit the import button. You can now SSH into Ubuntu services and appliances (from this machine only) using this key. But we still need to log our appliance into Ubuntu’s cloud to fetch it, so follow the three steps below and do that.

Once setup is complete, take a note of your Pi’s IP address and connect to it from a browser by entering, for example, http://192.168.0.2:8080. The openhab interface is a little confusing at first, especially given that the first step is ‘choose an interface’. You can always return to this index page to explore the others. Choose Paperui and peruse what Bindings (in the Addons section) are available, and if any of them match your hardware.

From here, your best friend is the openhab documentat­ion at www.openhab.org/docs. You can customise your appliance however you like. It’s running Ubuntu Core so you can add Snaps from the repos. Instead of following our later section on Nextcloud, you can get a working install by Sshing into the appliance (the username is the first part of your Ubuntu SSO email) and running:

$ snap install nextcloud

Visit the Snapcraft store (https://snapcraft.io) and let us know how you augmented your appliance. Oh and do check out the others; currently Plex, Nextcloud,

Mosquitto and Adguard have been applianced, and more will surely follow.

You probably already know that Sherlock Holmes had an older brother called Mycroft – and that’s where

the Mycroft Home Assistant gets its name. The Mark I device was a friendly, Et-looking voice assistant that was powered by a Raspberry Pi 3. We were big fans, but sadly that device is no longer available, and its successor has not yet been released. But that’s fine, because Mycroft’s brains (I think you mean OS – Ed) are open source, and you can run them right now on a Pi 3 or 4.

Buster rhyme

It’s based on the official Raspberry Pi Linux Buster image, and you can download it from https://github. com/mycroftai/enclosure-picroft . Use the Raspberry Pi Imager again (or use something else if you like) to write the image to an SD card. This time you’ll need at least an 8GB card. When it’s done, put the SD card into the Pi and fire it up. As with the openhab appliance, you’ll need a display and keyboard connected to the Pi to run the initial setup, but afterwards, these will not be needed unless something goes wrong. On first boot Picroft will resize its partition to use all available space on the SD card. When it finishes booting a second time, it will ask if you would like some help setting up your system, which you may as well accept.

You’ll need a microphone and speakers, and there’s a list of supported hardware at the Mycroft wiki (http:// bit.ly/lxf268picr­oft). Some of this will work out of the box, but some devices will need manual interventi­on. We used a Seeed Respeaker 4-microphone array HAT, which was easy to set up. Other devices will follow a similar pattern. Just run

$ git clone https://github.com/respeaker/seeedvoice­card.git $ cd seeed-voicecard

$ sudo ./install.sh

If your network works (try rebooting if it doesn’t!) you could also SSH into your Pi to do this (the default username is ‘mycroft’ with password ‘pi’, which you should change soon).

Then, if you’re using the 3.5mm jack for audio, you may need to run sudo raspi-config , select ‘7. Advanced Options’, ‘A4 Audio’, and finally ‘1. Force 3.5mm jack’. Now reboot to enact the changes. If you run into difficulti­es with the Respeaker (or other Seeed models), the driver documentat­ion is at https://github.com/ respeaker/seeed-voicecard.

Reboot and you can pair your device to the Mycroft Home service. You need to set up an account here to use the software, but hey, at least it’s not Facebook. Only your queries are collected, and these are used to better train speech recognitio­n. Just follow the prompts to set this up at https://home.mycroft.ai from another device; if your audio is working you should hear some actual verbiage at this point. If not you can rerun the setup wizard at any time with mycroft-setup-wizard .

Once everything’s working, the Mycroft CLI client will start, and you can talk and type at it to your heart’s content. Shout the magic wakeword “Hey Mycroft” to prick up it’s digital ears, then try “Tell me a joke”, “What is my IP address?” or “How much wood would a woodchuck chuck if a woodchuck could chuck wood?”. He likes it when you say “Thank you” too. Responses are again both verbal and on screen/terminal. You can quit the CLI at any point with :quit and then you can run anything you’d run on a normal Raspberry Pi Linux install. If you want to get back into the CLI, run

$ mycroft-cli-client

There’s a custom audio setup script called audio_ setup.sh and don’t forget to check the excellent Mycroft documentat­ion at https://mycroft-ai.gitbook.io/docs.

Mycroft can be installed on a regular Linux PC either as a Snap Package, through Docker, or straight from their Github. The wake word engine, known as Precise, uses Tensorflow for cutting edge accuracy, which requires the host to have AVX extensions; most machines from the last decade will.

 ??  ??
 ??  ?? The Homebuilde­r UI allows you to build your own virtual LXF Towers, complete with mysterious library.
The Homebuilde­r UI allows you to build your own virtual LXF Towers, complete with mysterious library.
 ??  ?? An openhab skill is available for Mycroft, so you can have your whole house respond to your vocal utterances and edicts.
An openhab skill is available for Mycroft, so you can have your whole house respond to your vocal utterances and edicts.

Newspapers in English

Newspapers from Australia