RaspberryPi as bluetooth receiver for google home

  • Hello,

    I have Raspberry Pi with LibreElec and I want to use it as a bluetooth receiver to connect my old Denon receiver and speakers via hdmi so that google home can connect to it as the default bluetooth speaker. I used this link to make the settings. I follow the instructions above and my Raspberry pi works perfectly as a bluetooth receiver. The problem, however, is that with each Libreelec restart, the settings are reset and I have to repeat the procedure every time. Is there any option or command that should be written in ssh so that I don't have to do everything again after every restart? Thanks.

  • Could you help me with more advanced instructions since I'm a beginner with Kodi and Linux. What I set as ssh commands after every reboot is the following:

    1. systemctl stop kodi

    2. pactl load-module module-udev-detect

    3. pactl set-default-sink alsa_output.0.iec958-stereo

    4. pactl set-default-source bluez_source.74_9E_AF_73_EC_4F.a2dp_source

    5. systemctl start kodi

    What exactly should I write after I run the command:

    Code
    nano /storage/.config/autostart.sh

    Thank you very much in advance and I apologize if I bother with any basic questions.

    • Login by SSH
    • Open the file with the "nano" editor: nano /storage/.config/autostart.sh
    • Write this into the file:
    Bash
    #!/bin/sh
    
    systemctl stop kodi
    pactl load-module module-udev-detect
    pactl set-default-sink alsa_output.0.iec958-stereo
    pactl set-default-source bluez_source.74_9E_AF_73_EC_4F.a2dp_source
    systemctl start kodi
    • Store the file by key combination "Control" + "o", and press "Enter" to confirm writing
    • Press the key combination "Control" + "x" to finish the editor
    • Reboot LE to see whether the commands inside autostart.sh do work
    • Login by SSH
    • Open the file with the "nano" editor: nano /storage/.config/autostart.sh
    • Write this into the file:
    Bash
    #!/bin/sh
    
    systemctl stop kodi
    pactl load-module module-udev-detect
    pactl set-default-sink alsa_output.0.iec958-stereo
    pactl set-default-source bluez_source.74_9E_AF_73_EC_4F.a2dp_source
    systemctl start kodi
    • Store the file by key combination "Control" + "o", and press "Enter" to confirm writing
    • Press the key combination "Control" + "x" to finish the editor
    • Reboot LE to see whether the commands inside autostart.sh do work

    I put the above script, but when restarted, Libreelec freezes and only the logo remains. I wrote the following:

    1. # / bin / sh

    2. pactl load-module modules-udev-detect

    3. done

    Now at restart it charges like a bluetooth receiver and I don't have to write anything every time with Terminal, but every time I have to manually pair with Google Home. Can any more automated solution be found or is this the best I can expect?

  • Code
    (
    sleep 10
    systemctl stop kodi
    pactl load-module module-udev-detect
    pactl set-default-sink alsa_output.0.iec958-stereo
    pactl set-default-source bluez_source.74_9E_AF_73_EC_4F.a2dp_source
    systemctl start kodi
    )&

    autostart.sh runs at the start of userspace boot long before Kodi is running so the script will fail. If you (background)& the process with a sleep timer it will run later (10 seconds later in the above example) and should succeed.

  • I put the above script, but when restarted, Libreelec freezes and only the logo remains.

    Then there is no need to stop /start Kodi, as mentioned by comrade chewitt. Try this:

    Bash
    #!/bin/sh
    
    pactl load-module module-udev-detect
    pactl set-default-sink alsa_output.0.iec958-stereo
    pactl set-default-source bluez_source.74_9E_AF_73_EC_4F.a2dp_source
  • Both scripts work fine. The problem is that with each Libreelec restart, I have to pair the two devices manually. Isn't there something that can be added to the script so that Google Home can automatically connect to Cody every time? Just like when I connect it to a bluetooth speaker. Is the problem in Libreelec or in the built-in bluetooth module of Raspberry Pi? If I buy a separate bluetooth dongle, will it work better?