pkozul / ha-tts-bluetooth-speaker

TTS Bluetooth Speaker for Home Assistant
186 stars 42 forks source link

Failed to connect: org.bluez.Error.Failed #7

Open Tech-Blog opened 6 years ago

Tech-Blog commented 6 years ago

Hi buddy, thanks for your awesome work. i was trying to install it both on Raspbian Strech and Ubuntu 18.04 LTS and got this error: **

Failed to connect: org.bluez.Error.Failed

** i tried 3 devices, 2 BlueTooth Speakers 1 BlueTooth Earphone. i was able to pair but not to connect. can you help me with that?

Cheers, Tomer

orrpan commented 5 years ago

I was able to connect by adding pulse to the group bluetooth, but not much more sudo addgroup pulse bluetooth

Edit: got it to work Got an error from mplayer, so followed this thread https://ubuntuforums.org/showthread.php?t=2213319

echo lirc=no >> ~/.mplayer/config

Could still not connect, so followed this thread https://github.com/pkozul/ha-tts-bluetooth-speaker/issues/5

platform: tts_bluetooth_speaker
  address: 00:00:00:00:00:00.a2dp_sink
  volume: 0.45

(change to the intended BT-addr)

Finally a test from dev-service in hass. service: tts.google_say service_data: {"entity_id":"media_player.tts_bluetooth_speaker","message":"hello there"}

Also edited so my users 'pi' and 'homeassistant' could use bluetooth (don't know if this is needed). https://www.raspberrypi.org/forums/viewtopic.php?t=108581

sudo nano /etc/dbus-1/system.d/bluetooth.conf

Small modificaton, since both my users are in the group 'homeassistant'

<policy group="homeassistant">
    <allow send_destination="org.bluez"/>
    <allow send_interface="org.bluez.Agent1"/>
    <allow send_interface="org.bluez.GattCharacteristic1"/>
    <allow send_interface="org.bluez.GattDescriptor1"/>
    <allow send_interface="org.freedesktop.DBus.ObjectManager"/>
    <allow send_interface="org.freedesktop.DBus.Properties"/>
  </policy>

Edit2 Since the groups 'homeassistant' could control the connection/disconnection now I updated the pair_bluetooth.sh

#!/bin/bash

input=$1
if [ $input -eq $input ] 2>/dev/null; then
    if [ $input -eq 0 ]; then #unpair
        bluetoothctl <<EOF
disconnect 00:00:00:00:00:00
EOF
    else #pair
        bluetoothctl <<EOF
connect 00:00:00:00:00:00
EOF
    fi
else
    echo error
    exit -1
fi
exit 0
okarin078 commented 4 years ago

I was able to connect by adding pulse to the group bluetooth, but not much more sudo addgroup pulse bluetooth

Edit: got it to work Got an error from mplayer, so followed this thread https://ubuntuforums.org/showthread.php?t=2213319

echo lirc=no >> ~/.mplayer/config

Could still not connect, so followed this thread #5

platform: tts_bluetooth_speaker
  address: 00:00:00:00:00:00.a2dp_sink
  volume: 0.45

(change to the intended BT-addr)

Finally a test from dev-service in hass. service: tts.google_say service_data: {"entity_id":"media_player.tts_bluetooth_speaker","message":"hello there"}

Also edited so my users 'pi' and 'homeassistant' could use bluetooth (don't know if this is needed). https://www.raspberrypi.org/forums/viewtopic.php?t=108581

sudo nano /etc/dbus-1/system.d/bluetooth.conf

Small modificaton, since both my users are in the group 'homeassistant'

<policy group="homeassistant">
    <allow send_destination="org.bluez"/>
    <allow send_interface="org.bluez.Agent1"/>
    <allow send_interface="org.bluez.GattCharacteristic1"/>
    <allow send_interface="org.bluez.GattDescriptor1"/>
    <allow send_interface="org.freedesktop.DBus.ObjectManager"/>
    <allow send_interface="org.freedesktop.DBus.Properties"/>
  </policy>

Edit2 Since the groups 'homeassistant' could control the connection/disconnection now I updated the pair_bluetooth.sh

#!/bin/bash

input=$1
if [ $input -eq $input ] 2>/dev/null; then
  if [ $input -eq 0 ]; then #unpair
      bluetoothctl <<EOF
disconnect 00:00:00:00:00:00
EOF
  else #pair
      bluetoothctl <<EOF
connect 00:00:00:00:00:00
EOF
  fi
else
  echo error
  exit -1
fi
exit 0

Thx. It works for me :0