StevenLooman / home-assistant-dlna-dmr

DLNA/DMR component for home-assistant
Other
13 stars 1 forks source link

DLNA Media players not working #11

Closed carryonrewardless closed 3 years ago

carryonrewardless commented 4 years ago

I have issues trying to set up dlna media players on Raspbian - Buster. My aim is to stream local media (music, photos, videos) to a 2014 Samsung TV and to Google Home ( music only obviously). My config is

discovery:
#   ignore:
#     - samsung_tv
  enable:
    - dlna_dmr

media_player:
  - platform: dlna_dmr
    url: http://192.168.1.120:7676/description.xml
    name: Samsung_DLNA
  - platform: dlna_dmr
    url: http://192.168.1.100
    name: Google_DLNA

and my error log with debug looks like this

2020-07-26 11:24:19 WARNING (MainThread) [homeassistant.components.media_player] Platform dlna_dmr not ready yet. Retrying in 30 seconds.
2020-07-26 11:24:19 ERROR (MainThread) [homeassistant.components.media_player] Error while setting up dlna_dmr platform for media_player
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 178, in _async_setup_platform
    await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
    return fut.result()
  File "/usr/src/homeassistant/homeassistant/components/dlna_dmr/media_player.py", line 184, in async_setup_platform
    upnp_device = await factory.async_create_device(url)
  File "/usr/local/lib/python3.7/site-packages/async_upnp_client/client_factory.py", line 52, in async_create_device
    root = await self._async_get_url_xml(description_url)
  File "/usr/local/lib/python3.7/site-packages/async_upnp_client/client_factory.py", line 293, in _async_get_url_xml
    raise UpnpError("Received status code: {}".format(status_code))
async_upnp_client.client.UpnpError: Received status code: 404

2020-07-26 11:24:43 INFO (MainThread) [homeassistant.components.discovery] Unknown service discovered: samsung_tv {'host': '192.168.1.120', 'port': 7676, 'ssdp_description': 'http://192.168.1.120:7676/smp_6_', 'name': 'Samsung', 'model_name': 'UA40F6400', 'model_number': '1.0', 'serial': '20090804RCR', 'manufacturer': 'Samsung Electronics', 'udn': 'uuid:0aba9500-00b4-1000-a14f-0c891036b631', 'upnp_device_type': 'urn:samsung.com:device:RemoteControlReceiver:1'}
2020-07-26 11:24:43 INFO (MainThread) [homeassistant.components.discovery] Unknown service discovered: home_assistant {'host': '192.168.1.29', 'port': 8123, 'hostname': '99f6da1d9db6468392f9aad35ac86a46.local.', 'properties': {'location_name': 'HomeSWHome', 'uuid': '99f6da1d9db6468392f9aad35ac86a46', 'version': '0.112.4', 'external_url': '', 'internal_url': 'http://192.168.1.29:8123', 'base_url': 'http://192.168.1.29:8123', 'requires_api_password': 'True'}}
2020-07-26 11:24:43 INFO (MainThread) [homeassistant.components.discovery] Found new service: dlna_dmr {'host': '192.168.1.120', 'port': 7676, 'ssdp_description': 'http://192.168.1.120:7676/smp_16_', 'name': '[TV] Samsung', 'model_name': 'UA40F6400', 'model_number': 'AllShare1.0', 'serial': '20110517DMR', 'manufacturer': 'Samsung Electronics', 'udn': 'uuid:0a21fe80-00aa-1000-a87f-0c891036b631', 'upnp_device_type': 'urn:schemas-upnp-org:device:MediaRenderer:1'}
2020-07-26 11:24:43 INFO (MainThread) [homeassistant.components.discovery] Unknown service discovered: igd {'host': '192.168.1.1', 'port': 52869, 'ssdp_description': 'http://192.168.1.1:52869/gatedesc.xml', 'name': 'UPNP IGD', 'model_name': 'H268A', 'model_number': 'V1.0', 'serial': 'ZTEEG8NJ3K04150', 'manufacturer': 'ZTE', 'udn': 'uuid:20809696-105a-3721-e8b8-b0acd23cc547', 'upnp_device_type': 'urn:schemas-upnp-org:device:InternetGatewayDevice:1'}
2020-07-26 11:24:44 DEBUG (MainThread) [async_upnp_client.profiles.profile] Subscribing to service: <UpnpService(urn:upnp-org:serviceId:RenderingControl, uuid:0a21fe80-00aa-1000-a87f-0c891036b631)>
2020-07-26 11:24:44 DEBUG (MainThread) [async_upnp_client.event_handler] Subscribing to: <UpnpService(urn:upnp-org:serviceId:RenderingControl, uuid:0a21fe80-00aa-1000-a87f-0c891036b631)>, callback URL: http://192.168.1.29:8301/notify
2020-07-26 11:24:44 DEBUG (MainThread) [async_upnp_client.event_handler] Got SID: uuid:0bebc200-0090-1000-93a6-0c891036b631, renewal_time: 2020-07-26 11:33:44.337781
2020-07-26 11:24:44 DEBUG (MainThread) [async_upnp_client.profiles.profile] Subscribing to service: <UpnpService(urn:upnp-org:serviceId:AVTransport, uuid:0a21fe80-00aa-1000-a87f-0c891036b631)>
2020-07-26 11:24:44 DEBUG (MainThread) [async_upnp_client.event_handler] Subscribing to: <UpnpService(urn:upnp-org:serviceId:AVTransport, uuid:0a21fe80-00aa-1000-a87f-0c891036b631)>, callback URL: http://192.168.1.29:8301/notify
2020-07-26 11:24:44 DEBUG (MainThread) [async_upnp_client.aiohttp] Received request: <BaseRequest NOTIFY /notify >
2020-07-26 11:24:44 DEBUG (MainThread) [async_upnp_client.aiohttp] NOTIFY response status: HTTPStatus.OK
2020-07-26 11:24:44 DEBUG (MainThread) [async_upnp_client.event_handler] Got SID: uuid:0bebc201-0090-1000-a9bf-0c891036b631, renewal_time: 2020-07-26 11:33:44.544005
2020-07-26 11:24:44 DEBUG (MainThread) [async_upnp_client.aiohttp] Received request: <BaseRequest NOTIFY /notify >
2020-07-26 11:24:44 DEBUG (MainThread) [async_upnp_client.aiohttp] NOTIFY response status: HTTPStatus.OK
2020-07-26 11:24:50 WARNING (MainThread) [homeassistant.components.media_player] Platform dlna_dmr not ready yet. Retrying in 60 seconds.

2020-07-26 11:29:17 DEBUG (MainThread) [async_upnp_client.profiles.profile] Resubscribing to service: <UpnpService(urn:upnp-org:serviceId:RenderingControl, uuid:0a21fe80-00aa-1000-a87f-0c891036b631)>
2020-07-26 11:29:17 DEBUG (MainThread) [async_upnp_client.event_handler] Resubscribing to: <UpnpService(urn:upnp-org:serviceId:RenderingControl, uuid:0a21fe80-00aa-1000-a87f-0c891036b631)>
2020-07-26 11:29:17 DEBUG (MainThread) [async_upnp_client.event_handler] Got SID: uuid:0bebc200-0090-1000-93a6-0c891036b631, renewal_time: 2020-07-26 11:38:17.255193
2020-07-26 11:29:17 DEBUG (MainThread) [async_upnp_client.profiles.profile] Resubscribing to service: <UpnpService(urn:upnp-org:serviceId:AVTransport, uuid:0a21fe80-00aa-1000-a87f-0c891036b631)>
2020-07-26 11:29:17 DEBUG (MainThread) [async_upnp_client.event_handler] Resubscribing to: <UpnpService(urn:upnp-org:serviceId:AVTransport, uuid:0a21fe80-00aa-1000-a87f-0c891036b631)>
2020-07-26 11:29:17 DEBUG (MainThread) [async_upnp_client.event_handler] Got SID: uuid:0bebc201-0090-1000-a9bf-0c891036b631, renewal_time: 2020-07-26 11:38:17.397212
2020-07-26 11:29:23 WARNING (MainThread) [homeassistant.components.media_player] Platform dlna_dmr not ready yet. Retrying in 150 seconds.

There has been some great work done on the dlna_dmr component. I would love to make use of it on my system but need some help with these errors.

StevenLooman commented 4 years ago

Thank you for the issue. No problem in doing it this way, though it would be better if you would make issues at the home-assistant/core issue tracker itself. This is fine too, but perhaps this issue will (be) contain(ing) some information that could be helpful to somebody else, but not easily found when searching in the hass-tracker.

Anyway, I see you've already enabled logging which is helpful. I am also guessing you are using the 'native' dlna_dmr component and not the code from this repository, correct? I am assuming this as you have explicitly enabled the discovery of this component in your configuration and also the given paths in the traceback.

In the logging I see a 404 status code, which means file from the DLNA/DMR device is requested, but not found. I am guessing the URL in the configuration for the Google_DLNA is incorrect. I would expect the URL to be something else, probably a XML file, like in the Samsung_DLNA entry.

You can find the URL by running the upnp-client search command, like so:

$ upnp-client search
{"CACHE-CONTROL": "max-age=1800", "DATE": "Mon, 27 Jul 2020 18:52:21 GMT", "EXT": "", "LOCATION": "http://192.168.178.13:7676/rcr/", "SERVER": "SHP, UPnP/1.0, Samsung UPnP SDK/1.0", "ST": "urn:samsung.com:device:RemoteControlReceiver:1", "USN": "uuid:a849a632-dcd5-4583-8077-5e0a307c353f::urn:samsung.com:device:RemoteControlReceiver:1", "Content-Length": "0", "_timestamp": "2020-07-27 20:52:22.574635", "_address": "192.168.178.13:50035", "_udn": "uuid:a849a632-dcd5-4583-8077-5e0a307c353f", "_source": "search"}
...

This gives lots of output, but you're interested in the lines which contain the address to your google home (192.168.1.100). Find those lines and try the LOCATION from those lines.

Also, the provided logging does seem to be missing some lines. If the above doesn't resolve your issue, can you check if there aren't more lines?

carryonrewardless commented 4 years ago

Thank you for the issue. No problem in doing it this way, though it would be better if you would make issues at the home-assistant/core issue tracker itself.

Yes I was not sure about where to post this and had not been to that link before. I did post in the community forum but figured you may never see it there. We can move the discussion to the above if you wish. Yes I am using the native component and I have deleted log lines that were apparently not relevant.

I tried the upnp search command and got: bash: ./upnp-client: /usr/local/bin/python: bad interpreter: No such file or directory So I tried python3 upnp-client search and got ModuleNotFoundError: No module named 'async_upnp_client'

I had to sudo su to get into the docker folder to do this. Maybe my install is not correct/complete? Thanks for yr assistance.

carryonrewardless commented 4 years ago

So I did a pip3 install async_upnp_client and it works but there are no lines for the Google Home Mini at all just for the Samsung TV and the ZTE router. See https://pastebin.com/Cj0c3zgz

Nmap scan report for 192.168.1.100
Host is up (0.014s latency).
Not shown: 994 closed ports
PORT      STATE SERVICE
7778/tcp  open  interwise
8008/tcp  open  http
8009/tcp  open  ajp13
8443/tcp  open  https-alt
9000/tcp  open  cslistener
10001/tcp open  scp-config
MAC Address: 48:D6:D5:EF:15:F0 (Google)

A more recent log is here https://pastebin.com/SGuZXLPR

When I attempt to play a track to the TV using this in HA

media_player.play_media
entity_id: media_player.tv_samsung
media_content_id: >-
  http://192.168.1.29:8123/local/Music/ColdChisel/East/01 - Cold Chisel -
  Standing on the Outside.ogg
media_content_type: music

I get the following log https://pastebin.com/z4JGSU1Y and the TV gives a message to check the network connection.

StevenLooman commented 4 years ago

SSDP (the discovery protocol UPnP uses) works by sending out a special packet on port 1900. See async_upnp_client search if you're interested. Some devices use a different port making them incompatible.

Have you tried other programs which allow you to stream to DLNA/DMR devices? For example, BubbleUPNP on Android. If those programs do find your Google Home Mini, then something is amiss in async_upnp_client. If not, then the device might not be compatible.

My own Samsung TV does not want to play anything served from the home assistant server. It does not provide the required headers in the HTTP response. Using minedlnad I could play music and video.

StevenLooman commented 4 years ago

Any luck so far?