Перейти до вмісту
Почати роботу

Text to speech

Цей контент ще не доступний вашою мовою.

Any Home Assistant text-to-speech voice, such as Piper or Home Assistant Cloud, can speak on a panel. Home Assistant renders the phrase to an audio URL, and the panel downloads and plays it through its POST /play endpoint. Copy the three blocks under Setup, then call script.ha_paneld_say.

Voices rendered by Home Assistant are far better than the text-to-speech built into older panels.

Play an announcement with the voice assistant on

Section titled “Play an announcement with the voice assistant on”

If the panel has a microphone and its voice assistant is turned on, you do not need any of the setup below: assist_satellite.announce speaks a message on the panel directly, with no REST commands, secrets or scripts to configure. The rest of this page is for panels without a microphone, or without the voice assistant enabled.

You need a text-to-speech engine (for example tts.piper) and a long-lived access token (your Home Assistant profile, then Security) in secrets.yaml. You also write your Home Assistant’s local base URL into the script below.

secrets.yaml:

ha_token: 'Bearer eyJ…' # Long-Lived Access Token, prefixed with "Bearer "

configuration.yaml:

rest_command:
# Render a phrase with an HA TTS engine; returns {"url", "path"}.
ha_paneld_tts_get_url:
url: 'http://127.0.0.1:8123/api/tts_get_url'
method: POST
headers:
authorization: !secret ha_token
content-type: application/json
payload: '{"engine_id": "{{ engine }}", "message": "{{ message }}"}'
# Send a ready audio URL to a panel's /play (raw URL in the body).
ha_paneld_play:
url: '{{ base }}play'
method: POST
payload: '{{ media_url }}'

scripts.yaml:

ha_paneld_say:
alias: 'Panel: speak (TTS)'
fields:
message:
description: 'Phrase to speak'
example: 'Dinner is ready'
target:
description: 'Any ha-paneld entity on the target panel'
example: 'light.living_room_screen'
engine:
description: 'TTS engine entity_id'
example: 'tts.piper'
sequence:
- service: rest_command.ha_paneld_tts_get_url
data:
engine: "{{ engine | default('tts.piper') }}"
message: '{{ message }}'
response_variable: tts
- service: rest_command.ha_paneld_play
data:
# Panel address from its HA device — no IP to hardcode.
base: "{{ device_attr(device_id(target), 'configuration_url') }}"
# Rebuild on your LAN base so the panel can fetch it (tts_get_url returns the external URL).
# Inline your internal_url here (templates can't read secrets.yaml):
media_url: "http://homeassistant.local:8123{{ tts['content']['path'] }}"

From an automation or the Home Assistant interface:

- service: script.ha_paneld_say
data:
message: 'The washing machine has finished'
target: light.living_room_screen # any entity belonging to the target panel
engine: tts.piper

The panel’s volume is number.<panel>_volume; set it beforehand if needed. To speak in several rooms, call the script once for each panel.

  1. Home Assistant renders the phrase and returns an audio URL from POST /api/tts_get_url.
  2. tts_get_url returns your external URL, so the script rebuilds it from your internal_url plus the returned path, which the panel can fetch on your local network.
  3. The script posts that URL, raw, in the body of a request to the panel’s /play. The panel’s address comes from the configuration_url of its Home Assistant device (http://<ip>:8888/), so all you pass is an entity belonging to the panel.

Коментарі

Коментарі зберігаються в обговоренні цієї сторінки на GitHub, тому їх завантаження з’єднує ваш браузер із GitHub. Цей браузер запам’ятовує ваш вибір і завантажує коментарі на інших сторінках, коли ви прокручуєте до них.

Ми Home Assistant і все, що робить Open Home Foundation.

Останнє оновлення:

Build 148 · 4aa8236