Media Cast / DLNA not working with Samsung TVs or Smart Monitors

I’ve been trying to get the Media Cast capability to work with four different models of Samsung TV or Monitor in order to even do something as rudimentary as display a picture. Nothing seems to work and despite a lot of research, I don’t appear to have been able to find a solution to it. Things that I’ve tried so far:

  • Added the device via the DLNA and Samsung Smart TV Integrations in HA
  • Validated that the devices can be controlled via HA for basic power controls etc.
  • Validated that the cast capability works on the Samsung devices from other devices such as an Android phone and Windows Desktop. Both succeed on all tested devices.
  • Moved the Samsung Devices to the same VLAN as the HA Server and validated that there is connectivity between the devices.
  • Tried turning on Debug logging on the DLNA Renderer integration to see whether anything notable appears in the logs. I can’t see anything obvious, but I’m admittedly not an expert in this.
  • Tested the HA Media Cast to a Google Cast device and can successfully stream the test picture, TTS audio, and Unifi Protect camera streams.

I’ve been able to find in the logs that the http://tv-ip:9197/upnp/control/AVTransport1 destination does reveal the following:

<s:Envelope xmlns:s="" s:encodingStyle="">
<script id="custom-useragent-string-page-script"/>
<UPnPError xmlns="urn:schemas-upnp-org:control-1-0">
<errorDescription>Invalid Args</errorDescription>

This is the same on all screens that I’ve attempted to cast to from HA. The process which works for the Google Devices, as in the same button clicks, only occasionally results in a UI error which says “Failed to call service media_player/media_play. ‘Resource’ object has no attribute 'url”.

I don’t open a lot of requests for help as I’ve generally found that the community has a pretty decent spread of information for self help but after trying to get this working for five hours straight with no further progress and seeing that the facility work for Google Devices, but not Samsung; I’m genuinely out of ideas.

If someone could give me a nod in the right direction, that would be amazing!

UPNP is a service in your firewall/router, so maybe that is required, but disabled, for Samsung cast to work.

I appreciate the reply, but it’s also somewhat required for Chromecast, and that works flawlessly across a number of devices in the network. The main problem I get from HA is “Failed to call service media_player/media_play. ‘Resource’ object has no attribute ‘url’” and I don’t know what the crack is with that?

I looked a bit into the tests you have done and what I could find.
It sounds like you are mixing two different features up.

DLNA is a way to play a media source from a media service. The media source is transfered in the resource called media_content_id and it can be a sound og video file, like MP3, MP4, AVI or so on.

Cast is a way to play a stream from a stream service. The stream location is transfered in the resource called url and have to be a stream and it has to be a https:// url, because the protocol do not accept http://.

Yes understood on the difference to do with DLNA and Chromecast. I suppose the point of saying that I’d tested the Chromecast cast feature was to say that the functionality is working in HA, so it doesn’t appear to be an HA instance feature. I run a Ubiquiti network and there isn’t anything which I’m able to find in the new settings to enable UPnP. I’ve enabled other settings related to cast capability on the network where the HA instance runs, but I still get this same error. Unless I’m mistaken, UPnP shouldn’t be required on the WAN interface as the devices are both in the same subnet? My understanding was that UPnP is for the dynamic opening of firewall ports on demand, but this shouldn’t be necessary outside of the network unless there’s something which demands external brokering?

I do not think this is an uPNP error.
It looks like the media_plqy command gets a media-source instead of a stream url.

I’ve opened a bug for this as well here: Media Player Cast does not work with DLNA devices · Issue #111078 · home-assistant/core · GitHub. I don’t know whether the person who’s responsible for the code is around though as there are two Samsung TV bugs reported with DLNA so I don’t know if this is unique to me or if the other one is different. Do you have a Samsung TV which is working?

Can you post your parameters for your service call to cast?

This is the extract from the debug logs that I posted on the GitHub bug report:

AttributeError: 'Resource' object has no attribute 'url'. Did you mean: 'uri'?
2024-02-21 12:33:29.469 DEBUG (MainThread) [homeassistant.components.dlna_dmr] async_browse_media(app, media-source://media_source)
2024-02-21 12:33:30.390 DEBUG (MainThread) [homeassistant.components.dlna_dmr] Playing media: image/jpeg, media-source://media_source/local/20240212_192423.jpg, {'extra': {}}
2024-02-21 12:33:30.390 DEBUG (MainThread) [homeassistant.components.dlna_dmr] sourced_media is PlayMedia(url='/media/local/20240212_192423.jpg', mime_type='image/jpeg')
2024-02-21 12:33:30.391 DEBUG (MainThread) [async_upnp_client.traffic.upnp] Sending request:
HEAD http://<HAS-IP>:8123/media/local/20240212_192423.jpg?authSig=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiI2ZjFlN2JjZDdlNzM0MThmOWViY2ZmNzVjZmRkOTlmMiIsInBhdGgiOiIvbWVkaWEvbG9jYWwvMjAyNDAyMTJfMTkyNDIzLmpwZyIsInBhcmFtcyI6W10sImlhdCI6MTcwODUxODgxMCwiZXhwIjoxNzA4NjA1MjEwfQ.HHSdd75kwlNCmE9AX8AlTnR_ecOQ4eIx3SlGNZaVe0g 1

2024-02-21 12:33:30.395 DEBUG (MainThread) [async_upnp_client.traffic.upnp] Got response from HEAD http://<HAS-IP>:8123/media/local/20240212_192423.jpg?authSig=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiI2ZjFlN2JjZDdlNzM0MThmOWViY2ZmNzVjZmRkOTlmMiIsInBhdGgiOiIvbWVkaWEvbG9jYWwvMjAyNDAyMTJfMTkyNDIzLmpwZyIsInBhcmFtcyI6W10sImlhdCI6MTcwODUxODgxMCwiZXhwIjoxNzA4NjA1MjEwfQ.HHSdd75kwlNCmE9AX8AlTnR_ecOQ4eIx3SlGNZaVe0g:
Content-Type: text/plain; charset=utf-8
Referrer-Policy: no-referrer
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
Content-Length: 23
Date: Wed, 21 Feb 2024 12:33:30 GMT

2024-02-21 12:33:30.395 DEBUG (MainThread) [async_upnp_client.traffic.upnp] Sending request:
GET http://<HAS-IP>:8123/media/local/20240212_192423.jpg?authSig=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiI2ZjFlN2JjZDdlNzM0MThmOWViY2ZmNzVjZmRkOTlmMiIsInBhdGgiOiIvbWVkaWEvbG9jYWwvMjAyNDAyMTJfMTkyNDIzLmpwZyIsInBhcmFtcyI6W10sImlhdCI6MTcwODUxODgxMCwiZXhwIjoxNzA4NjA1MjEwfQ.HHSdd75kwlNCmE9AX8AlTnR_ecOQ4eIx3SlGNZaVe0g 1
Range: bytes=0-0

It is more the process to setup the cast I am interested in.

Click Media on the Side Menu > Click My Media > Click a JPG I uploaded for testing purposes > the bottom bar has the blue loading wheel briefly and then returns the following:

I then click the Play button and get the following pop up:

I’ve tried this with different media, such as the Unifi Protect cameras, but even some of those come up as incompatible for live streams with the DLNA Samsung TV sources, but will cast using Chromecast. Dashboards too are unavailable via the DLNA casting devices, though this may be related to what you were saying about the HTTP resources and how the two casting methods work differently.

DLNA and Cast is not the same.
It is two different things.