chime_tts icon indicating copy to clipboard operation
chime_tts copied to clipboard

Chime Say forming non-public url for Cast devices

Open Maxcodesthings opened this issue 8 months ago • 1 comments

System Health details

System Information

version core-2025.3.4
installation_type Home Assistant Container
dev false
hassio false
docker true
user root
virtualenv false
python_version 3.13.2
os_name Linux
os_version 5.15.0-91-generic
arch x86_64
timezone America/Los_Angeles
config_dir /config
Home Assistant Community Store
GitHub API ok
GitHub Content ok
GitHub Web ok
HACS Data ok
GitHub API Calls Remaining 4993
Installed Version 2.0.2
Stage running
Available Repositories 1627
Downloaded Repositories 57
Home Assistant Cloud
logged_in false
can_reach_cert_server ok
can_reach_cloud_auth ok
can_reach_cloud ok
Dashboards
dashboards 5
resources 35
views 9
mode storage
Network Configuration
adapters lo (disabled), eth0 (enabled, default, auto), eth1 (disabled)
ipv4_addresses lo (127.0.0.1/8), eth0 (192.168.1.65/24), eth1 (172.18.0.18/16)
ipv6_addresses lo (), eth0 (), eth1 ()
announce_addresses 192.168.1.65
Recorder
oldest_recorder_run March 16, 2025 at 11:35 PM
current_recorder_run March 27, 2025 at 12:53 PM
estimated_db_size 1707.20 MiB
database_engine sqlite
database_version 3.48.0

Checklist

  • [x] I have enabled debug logging for my installation.
  • [x] I have filled out the issue template to the best of my ability.
  • [x] This issue only contains 1 issue (if you have multiple issues, open one issue for each issue).
  • [x] This issue is not a duplicate issue of currently previous issues..

Describe the issue

I am using version 1.2.2 and it seems like #164 has popped back up. Cast devices require a publicly hosted url but chime is not forming one. I have configured this already in my installation years ago:

homeassistant:
  external_url: https://my-domain.com/
  internal_url: https://my-domain.com/

I use an internal DNS so my hostrname is resolvable internally as well. The error message clearly shows it not placing my external domain when forming the url:

2025-03-28 02:18:48.409 ERROR (Thread-13) [homeassistant.components.cast.media_player] Failed to cast media http://192.168.1.213:8097/single/d9f243d5-0e1c-602c-bf9c-3d2bd45e49ea/e1cb8f1dd5a14daa813f417008da8a3b.flac. Please make sure the URL is: Reachable from the cast device and either a publicly resolvable hostname or an IP address

Projecting the audio to a Home Assistant Voice PE it works jsut fine, but not my Google cast devices. I tried using a path on /www as previously mentioned was working in #164 but there is a hard requirement to use a media_source path

Image

This looks to be the fix from that previous issue

If so I will add a fix so that Chime TTS will use the public URL path with cast media_players instead of the media content id.

Looks like the ability to test if it is a cast device is not working?

You can workaround the error using say_url but that feels like an unnecessary additional step. Here is a script that works for a workaround:

sequence:
  - action: chime_tts.say_url
    metadata: {}
    data:
      chime_path: ba_dum_tss
      message: test audio message
      tts_platform: google_translate
    response_variable: response
  - action: music_assistant.play_media
    metadata: {}
    data:
      enqueue: replace
      media_id: "{{ response.url }}"
    target:
      entity_id: media_player.office_speaker_2
alias: Test Chime TTS
description: ""

Reproduction steps

No actions run so here is my action's yaml to reproduce:

action: chime_tts.say
data:
  chime_path: bright
  message: test
target:
  entity_id: media_player.office_speaker_2

Debug logs

2025-03-28 02:11:59.988 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] ╔══════════════════════════════════════╗
2025-03-28 02:11:59.988 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] ║ Chime TTS Say Called. Version v1.2.2 ║
2025-03-28 02:11:59.988 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] ╚══════════════════════════════════════╝
2025-03-28 02:11:59.988 DEBUG (MainThread) [custom_components.chime_tts.queue_manager] Adding service call to queue
2025-03-28 02:11:59.989 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] ╭────────────────────╮
2025-03-28 02:11:59.989 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] │ General Parameters │
2025-03-28 02:11:59.989 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] ╰────────────────────╯
2025-03-28 02:11:59.989 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers]  * entity_ids = ['media_player.office_speaker_2']
2025-03-28 02:11:59.989 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers]  * chime_path = choir
2025-03-28 02:11:59.989 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers]  * cache = False
2025-03-28 02:11:59.989 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers]  * offset = 450.0
2025-03-28 02:11:59.989 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers]  * crossfade = 0
2025-03-28 02:11:59.989 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers]  * final_delay = 0.0
2025-03-28 02:11:59.989 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers]  * message = poop
2025-03-28 02:11:59.989 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers]  * tts_speed = 100.0
2025-03-28 02:11:59.989 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers]  * tts_pitch = 0
2025-03-28 02:11:59.989 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers]  * announce = False
2025-03-28 02:11:59.989 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers]  * fade_audio = False
2025-03-28 02:11:59.989 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers]  * volume_level = -1
2025-03-28 02:11:59.989 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers]  * join_players = False
2025-03-28 02:11:59.989 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers]  * unjoin_players = False
2025-03-28 02:11:59.989 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers]  * media_players_array:
2025-03-28 02:11:59.989 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers]    - 0: entity_id: media_player.office_speaker_2
2025-03-28 02:11:59.989 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers]      platform: music_assistant
2025-03-28 02:11:59.989 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers]      initial volume: 0.6
2025-03-28 02:11:59.989 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers]      target volume: -1.0
2025-03-28 02:11:59.989 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers]      now playing: False
2025-03-28 02:11:59.989 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers]      join supported: False
2025-03-28 02:11:59.989 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers]      announce supported: True
2025-03-28 02:11:59.989 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] ╭─────────────────╮
2025-03-28 02:11:59.989 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] │ Preparing Audio │
2025-03-28 02:11:59.989 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] ╰─────────────────╯
2025-03-28 02:11:59.990 DEBUG (MainThread) [custom_components.chime_tts.helpers.filesystem] Local path to chime: /config/custom_components/chime_tts/mp3s/choir.mp3
2025-03-28 02:11:59.990 DEBUG (MainThread) [custom_components.chime_tts]  - Retrieving audio from path: "/config/custom_components/chime_tts/mp3s/choir.mp3"...
2025-03-28 02:12:00.064 DEBUG (MainThread) [custom_components.chime_tts]    ...audio retrieved. Duration: 2.856s
2025-03-28 02:12:00.128 DEBUG (MainThread) [custom_components.chime_tts.helpers.tts_audio_helper]    ...TTS audio generated in 60.0ms
2025-03-28 02:12:00.128 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] Adding gap of 450.0ms
2025-03-28 02:12:00.129 DEBUG (MainThread) [custom_components.chime_tts]  - Saving mp3 file to local folder: /media/sounds/temp/chime_tts/...
2025-03-28 02:12:00.219 DEBUG (MainThread) [custom_components.chime_tts.helpers.filesystem] File saved to path: /media/sounds/temp/chime_tts/f88e60b8888ed5bb99e373f3e740b5e6.mp3
2025-03-28 02:12:00.285 DEBUG (MainThread) [custom_components.chime_tts]  - Chime TTS audio generated:
2025-03-28 02:12:00.285 DEBUG (MainThread) [custom_components.chime_tts]    * audio_duration = 4.026
2025-03-28 02:12:00.285 DEBUG (MainThread) [custom_components.chime_tts]    * local_path = "/media/sounds/temp/chime_tts/f88e60b8888ed5bb99e373f3e740b5e6.mp3"
2025-03-28 02:12:00.285 DEBUG (MainThread) [custom_components.chime_tts]    * public_path = None
2025-03-28 02:12:00.285 DEBUG (MainThread) [custom_components.chime_tts]    * media_content_id = "media-source://media_source/local/sounds/temp/chime_tts/f88e60b8888ed5bb99e373f3e740b5e6.mp3"
2025-03-28 02:12:00.285 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] ╭────────────────────╮
2025-03-28 02:12:00.285 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] │ Chime TTS playback │
2025-03-28 02:12:00.285 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] ╰────────────────────╯
2025-03-28 02:12:00.285 DEBUG (MainThread) [custom_components.chime_tts]    1 Regular media player detected:
2025-03-28 02:12:00.285 DEBUG (MainThread) [custom_components.chime_tts]      - media_player.office_speaker_2
2025-03-28 02:12:00.285 DEBUG (MainThread) [custom_components.chime_tts]    Calling media_player.play_media with data:
2025-03-28 02:12:00.285 DEBUG (MainThread) [custom_components.chime_tts]      - entity_id: ['media_player.office_speaker_2']
2025-03-28 02:12:00.285 DEBUG (MainThread) [custom_components.chime_tts]      - announce: False
2025-03-28 02:12:00.285 DEBUG (MainThread) [custom_components.chime_tts]      - media_content_type: music
2025-03-28 02:12:00.285 DEBUG (MainThread) [custom_components.chime_tts]      - media_content_id: media-source://media_source/local/sounds/temp/chime_tts/f88e60b8888ed5bb99e373f3e740b5e6.mp3
2025-03-28 02:12:00.287 DEBUG (MainThread) [custom_components.chime_tts]  - Waiting 4.026s for audio playback to complete...
2025-03-28 02:12:00.967 ERROR (Thread-13) [homeassistant.components.cast.media_player] Failed to cast media http://192.168.1.213:8097/single/d9f243d5-0e1c-602c-bf9c-3d2bd45e49ea/188926e6842341babf304015df8363ce.flac. Please make sure the URL is: Reachable from the cast device and either a publicly resolvable hostname or an IP address
2025-03-28 02:12:04.313 DEBUG (MainThread) [custom_components.chime_tts.helpers.media_player_helper]  - Waiting until 1 media_player isn't playing...
2025-03-28 02:12:04.313 DEBUG (MainThread) [custom_components.chime_tts.helpers.media_player_helper]    ✔ media_player.office_speaker_2
2025-03-28 02:12:04.313 DEBUG (MainThread) [custom_components.chime_tts] Waiting 1.0s before removing temporary file:
2025-03-28 02:12:05.314 DEBUG (MainThread) [custom_components.chime_tts.helpers.filesystem] Deleting file /media/sounds/temp/chime_tts/f88e60b8888ed5bb99e373f3e740b5e6.mp3
2025-03-28 02:12:05.314 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] ╭───────────────────────────────────────────╮
2025-03-28 02:12:05.314 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] │──── Chime TTS Say Completed in 5.33 s ────│
2025-03-28 02:12:05.314 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] ╰───────────────────────────────────────────╯

Diagnostics dump

No response

Maxcodesthings avatar Mar 28 '25 03:03 Maxcodesthings

Came across your issue while searching for something else...I had a similar issue and ended up changing my Internal URL setting in Home Assistant to the machine IP. Ugly, but seemed to fix it with no downsides.

Hope this helps.

TarheelGrad1998 avatar Apr 21 '25 19:04 TarheelGrad1998