Fix playing TTS and local media source over DLNA
Proposed change
This fixes https://github.com/home-assistant/core/issues/139580 (described below as well).
If I try TTS or playing a local media audio file on a DLNA compatible speaker, it doesn't work and shows an error in the log:
[homeassistant.components.dlna_dmr] Error during call async_play_media: UpnpActionResponseError('Error during async_call(), status: 500, upnp error: 716 (Resource not found)')
Right before the Resource not found error above, the HA logs show that there's a HEAD request coming in from the speaker and that fails with an HTTP 500 error. I also saw somewhere someone hinting that DLNA renderers might send a HEAD request before sending the GET one.
This PR adds support for HEAD requests for local_source media and TTS (also allowing signed requests for HEAD), which fixes this problem and likely related issues mentioned below.
Type of change
- [ ] Dependency upgrade
- [X] Bugfix (non-breaking change which fixes an issue)
- [ ] New integration (thank you!)
- [ ] New feature (which adds functionality to an existing integration)
- [ ] Deprecation (breaking change to happen in the future)
- [ ] Breaking change (fix/feature causing existing functionality to break)
- [ ] Code quality improvements to existing code or addition of tests
Additional information
There are several reports around the net about this or related DLNA problems, dating back to 2022:
- #81162
- #111078
- Media Cast / DLNA not working with Samsung TVs or Smart Monitors
- DLNA Digital Media Renderer Not Working
Most replies to such issues end up pointing to configuring media_dirs (Setting up local media sources, Media Source), but nothing works, leading to complains about unclear documentation: https://github.com/home-assistant/home-assistant.io/issues/28940.
Also, the documentation says there might be hiccups with Samsung devices, but that might be exactly because of the missing support for HEAD requests:
Note that some devices, such as Samsung TVs, are rather picky about the source used to play from. The TTS action might not work in combination with these devices.
UPDATE 2025-03-01 ~~However, I haven't tried streaming videos yet. I'll check it later and submit a separate PR if necessary, and it seems to also be an issue like #67618.~~ Videos work with these changes and I also included a fix for local images.
Checklist
- [x] The code change is tested and works locally.
- [x] Local tests pass. Your PR cannot be merged unless tests pass
- [x] There is no commented out code in this PR.
- [x] I have followed the development checklist
- [x] I have followed the perfect PR recommendations
- [x] The code has been formatted using Ruff (
ruff format homeassistant tests) - [x] Tests have been added to verify that the new code works.
If user exposed functionality or configuration variables are added/changed:
- [ ] Documentation added/updated for www.home-assistant.io
If the code communicates with devices, web services, or third-party tools:
- [ ] The manifest file has all fields filled out correctly.
Updated and included derived files by running:python3 -m script.hassfest. - [ ] New or updated dependencies have been added to
requirements_all.txt.
Updated by runningpython3 -m script.gen_requirements_all. - [ ] For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
To help with the load of incoming pull requests:
- [ ] I have reviewed two other open pull requests in this repository.
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks :+1:
Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration (tts) you are listed as a code owner for? Thanks!
Code owner commands
Code owners of tts can trigger bot actions by commenting:
@home-assistant closeCloses the pull request.@home-assistant rename Awesome new titleRenames the pull request.@home-assistant reopenReopen the pull request.@home-assistant unassign ttsRemoves the current integration label and assignees on the pull request, add the integration domain after the command.@home-assistant add-label needs-more-informationAdd a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.@home-assistant remove-label needs-more-informationRemove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.
Hey there @hunterjm, mind taking a look at this pull request as it has been labeled with an integration (media_source) you are listed as a code owner for? Thanks!
Code owner commands
Code owners of media_source can trigger bot actions by commenting:
@home-assistant closeCloses the pull request.@home-assistant rename Awesome new titleRenames the pull request.@home-assistant reopenReopen the pull request.@home-assistant unassign media_sourceRemoves the current integration label and assignees on the pull request, add the integration domain after the command.@home-assistant add-label needs-more-informationAdd a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.@home-assistant remove-label needs-more-informationRemove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.
Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration (http) you are listed as a code owner for? Thanks!
Code owner commands
Code owners of http can trigger bot actions by commenting:
@home-assistant closeCloses the pull request.@home-assistant rename Awesome new titleRenames the pull request.@home-assistant reopenReopen the pull request.@home-assistant unassign httpRemoves the current integration label and assignees on the pull request, add the integration domain after the command.@home-assistant add-label needs-more-informationAdd a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.@home-assistant remove-label needs-more-informationRemove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.
Just to confirm that this also fixes streaming video to my Samsung TV.
Why is the merging blocked? I would be happy to see it in the next update. Thank you.
I actually don't know. Perhaps something in the CI didn't go well, but I can't see what I could do.
I'll create an issue and a new PR this weekend if nothing moves here (and close this one).
On Wed, Feb 12, 2025, 15:04 vitals5 @.***> wrote:
Why is the merging blocked? I would be happy to see it in the next update. Thank you.
— Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/pull/134903#issuecomment-2653981202, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAASAHMVEX43LLBZKOJJBZT2PNPF5AVCNFSM6AAAAABUV76GOSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMNJTHE4DCMRQGI . You are receiving this because you were mentioned.Message ID: @.***> [image: vitals5]vitals5 left a comment (home-assistant/core#134903) https://github.com/home-assistant/core/pull/134903#issuecomment-2653981202
Why is the merging blocked? I would be happy to see it in the next update. Thank you.
— Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/pull/134903#issuecomment-2653981202, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAASAHMVEX43LLBZKOJJBZT2PNPF5AVCNFSM6AAAAABUV76GOSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMNJTHE4DCMRQGI . You are receiving this because you were mentioned.Message ID: @.***>
Hi, did you make a new issue? If so could you link it here for us that want to stay up to date?
Thanks for doing this. This has been a issue with my home assistant.
I've marked this PR a draft, as changes are requested that need to be processed. Please un-draft it once it is ready for review again by clicking the "Ready for review" button.
Thanks! 👍
../Frenck
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. If you are the author of this PR, please leave a comment if you want to keep it open. Also, please rebase your PR onto the latest dev branch to ensure that it's up to date with the latest changes. Thank you for your contribution!
Please guys keep this PR alive I've been waiting for this fix so badly ;)
Owner please consider finishing, I have 2x Samsung TVs that are affected
Hi @chishm. Thank you for your review and apologies for the delay.
I addressed your comments and marked the PR as ready for review. Appreciate your look at it when possible.