ha-tts-bluetooth-speaker icon indicating copy to clipboard operation
ha-tts-bluetooth-speaker copied to clipboard

Integration tts_bluetooth_speaker not found with more recent home assistant core versions

Open miikama opened this issue 3 years ago • 10 comments

I have hass version 2022.3.1

I had some issues when adding the tts_bluetooth_speaker as a custom component. I manually added the component into the configuration.yaml as

media_player:
  - platform: "tts_bluetooth_speaker"
    address: "CC:CC:CC:CC:CC:CC"
    volume: 0.45

After adding, and checking the configuration

(env) homeassistant@raspberrypi:~/.homeassistant $ hass --script check_config
Testing configuration at /home/homeassistant/.homeassistant
Failed config
  General Errors: 
    - Platform error media_player.tts_bluetooth_speaker - Integration 'tts_bluetooth_speaker' not found.

The component should be at the correct location

(env) homeassistant@raspberrypi:~/.homeassistant $ ls /home/homeassistant/.homeassistant/custom_components/tts_bluetooth_speaker/
__init__.py  manifest.json  media_player.py

It seems that more recent hass versions require a version key in the custom component manifest.json file.

See e.g. https://community.home-assistant.io/t/no-version-key-in-the-manifest-file-for-custom-integration-environment-canada/311313/7

{
    "domain": "tts_bluetooth_speaker",
    "name": "BT Speaker",
    "documentation": "https://github.com/pkozul/ha-tts-bluetooth-speaker",
    "dependencies": [],
    "codeowners": ["@pkozul"],
-   "requirements": []
+   "requirements": [],
+   "version": "0.0.0"
}

Also, the class MediaPlayerDevice has been renamed to MediaPlayerEntity. See https://community.home-assistant.io/t/media-player-not-working-after-upgrading-to-2022-2-6/391841.

Thetts_bluetooth_speaker component can be loaded after updating the file media_player.py

from homeassistant.components.media_player import (
    SUPPORT_PLAY_MEDIA,
    SUPPORT_VOLUME_SET,
    PLATFORM_SCHEMA,
-    MediaPlayerDevice)
+    MediaPlayerEntity)

-class BluetoothSpeakerDevice(MediaPlayerDevice):
+class BluetoothSpeakerDevice(MediaPlayerEntity):

miikama avatar Mar 06 '22 17:03 miikama

Thanks @miikama for the detailed message, I was able to add tts_bluetooth thanks to you !

But when testing with the service Text-to-speech (TTS): Say an TTS message with google_translate, no sound is outputting... Is it working for you ?

I can output audio from my BT speaker with the mplayer -ao pulse::bluez_sink command, so the device is behaving correctly on the Debian host

Thanks for the help you already provided and maybe the help you could provide :)

archit3kt avatar Mar 17 '22 11:03 archit3kt

The module seems to use two command line utilities, mplayer and sox. Do you also have sox installed? (I didn't because I skipped some instruction steps).

Which environment are you running the homeassistant on? Is it the docker container, the home assistant operating system on raspberry pi, or the home assistant installed in a python virtual environment? I am running it from a Python virtual environment so it is not containerized. If you are running it in a container, can you also run the mplayer command inside the container successfully?

miikama avatar Mar 17 '22 12:03 miikama

And to answer your question @archit3kt , I am actually able to use the TTS to output speech from the speaker :)

miikama avatar Mar 17 '22 12:03 miikama

I'm running HA in supervised mode on latest Debian 11, to stay in a supported environment !

Indeed the amd64-hassio-audio container, which configure all the audio stuff, wasn't getting the bluetooth conf from the pulseaudio host... I could configure the conf file inside the container to access the bluetooth sink, but the conf would be lost at every reboot.

I went another way and installed mpd on the Debian host, configure it to use the pulseaudio bluez sink on the host, and configure HA in this very simple way :

`media_player:

  • platform: mpd host: 127.0.0.1 `

Now it is workiing like a charm, this page gave me the right instructions to add the BT player on the host, and mpd is doing the rest :)

Thanks for your help, was appreciated !

archit3kt avatar Mar 17 '22 18:03 archit3kt

I'm running HA in supervised mode on latest Debian 11, to stay in a supported environment !

I'm on the same boat, just not as advanced as you. Would you mind detailing how I can set it up?

I can get audio via bluetooth, but not tts.

elektrinis avatar May 08 '22 13:05 elektrinis

Hey @elektrinis, I followed this guide until point 5 included, so bluetooth audio was working on the Debian host.

pactl list sinks is listing correctly : bluez_sink.11_75_58_9D_B7_73.a2dp_sink

I installed mpd and configured /etc/mpd.conf with the following :

audio_output { type "pulse" name "My Pulse Output" sink "bluez_sink.11_75_58_9D_B7_73.a2dp_sink" }

Ofc enable and start the service, that's all on the Debian part. Connect to your HA instance and add to configuration.yaml :

media_player:

  • platform: mpd host: 127.0.0.1

It will connect the mpd HA object to your mpd server on Debian host. You can then use this mpd object to play audio files in HA.

For TTS, don't forget to configure it in the configuration.yaml :

tts:

  • platform: google_translate language: en cache: true cache_dir: /tmp/tts time_memory: 300 base_url: "your external URL FQDN here" service_name: google_say

or if you like marytts like me and you run the container to get local voice generation on your debian host :

tts:

  • platform: marytts

Should be working after all this :)

archit3kt avatar May 09 '22 10:05 archit3kt

Or as the simplest way to output audio to a bluetooth speaker, this is through the Mopidy addon, where we select a bluetooth speaker from the list as an audio output.

image

in configuration.yaml, we add

#MPD music player daemon
media_player:
  - platform: mpd
    name: "MPD Mopidy"
    host: localhost
    port: 6601

for example, audio output via a portable bluetooth speaker using a local rhasspy voice assistant with Silero TTS Service speech synthesis

service: tts.marytts_say
data:
  entity_id: media_player.mpd_mopidy
  message: >-
    15 years later, the life of Jean-Luc, who once plowed the cosmic expanses
    Picard

DivanX10 avatar Mar 13 '23 14:03 DivanX10