How to setup your Libre Elec / Kodi / Google Home Bluetooth / Yatse Android Remote


I have a number of Kodi Media Centre running in different rooms around the house. Some are hooked up to surround sound and some are not.
One of my media centres is hooked up to a projector with a rubbish tinny speaker. In the same room i have a google home mini that i wanted to use for the sound.

I control all of them via my mobile phone using Yatse.
At the moment i have to enable the bluetooth speaker via the GUI and thats too much like effort, so i scripted it .

Things your going to need:-

Kodi up and running with a device that supports bluetooth (or can accept a dongle)
Google Home / Google Mini speaker
SSH access to your kodi device
Yatse Android remote

Here is what i did to get everything working.

Google Home Bluetooth Setup

Enable Guest mode of your google home / google mini using this this guide
https://support.google.com/googlehome/answer/7182412?hl=en-GB

Once that is done, you need to setup kodi to trust the speaker.

Kodi

Select System in the main menu, then select OpenELEC in the sub-menu.
Select Services in the menu on the left, then select Enable Bluetooth. The circle to its right will turn blue.
Make sure your google home speaker is discoverable.
Click Bluetooth on the left of the OpenElec screen. Bluetooth will start scanning and should show your google home speaker along with any other nearby Bluetooth devices.
Click the name of your device, then select Trust and Connect in the screen that appears. OpenELEC will connect your device. You will need to enter the PIN for your google home (you will see this if you look in the Google Home app).

Image result

Next  return to the main screen. In the main menu there, select System, then select Settings from the sub-menu.
In the menu on the left, select System, then in the next screen to appear, select Audio Output. Click Audio Output Device.
In the window that appears, select PULSE: Default, Bluetooth Audio (PULSEAUDIO). Your Bluetooth speaker should now play audio.

SSH LbreElec

Now we SSH into the LibreElec device.
type in
bluetoothctl -a

This will show you your paired bluetooth devices, make a note of the MAC address of your google home speaker

you can type in info XX:XX:XX:XX:XX:XX (change this to the MAC address of your bluetooth device) to verify its the correct speaker.

once finished type exit.

Now we want to create a few folders and scripts.

mkdir ~/scripts
mkdir ~/python

go to the scripts folder and type
nano autopair.sh

Enter the below information, making sure you add your own MAC address in..

you now need to make the files executable to type in
chmod +x autopair.sh

go to the python folder and type

nano scripton.py
enter the following information

you now need to make the files executable so type in
chmod +x scripton.py

This might be a good idea to run

python scripton.py
and your speaker should connect.

reboot the device to allow for further testing when we do the Yatse steps.

YATSE

In Yatse , you can add custom commands.
We want to add the following

RunScript(/storage/python/scripton.py)

 

Click the button and bluetooth should connect.

Hope this was of some help to you also!