home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.89k stars 30.12k forks source link

DLNA DMR - Panasonic viera #20749

Closed Tony763 closed 5 years ago

Tony763 commented 5 years ago

Home Assistant release with the issue: 0.86.4

Last working Home Assistant release (if known):

Operating environment (Hass.io/Docker/Windows/etc.): Hass.io via docker on Xubuntu x64 Intel386

Component/platform: https://www.home-assistant.io/components/media_player.dlna_dmr/

Description of problem: Can't play anything on TV Panasonic viera 42AS650.

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

discovery:
    ignore:
        - panasonic_viera
    enable:
       - dlna_dmr

media_player:
  - platform: panasonic_viera
    host: "10.0.1.108"
    mac: "20:C6:EB:AB:8B:20"

Traceback (if applicable):

media_player.play_media
{
  "entity_id": "media_player.42as650_series_2",
  "media_content_type": "video/avi",
  "media_content_id": "http://10.0.1.1:8200/MediaItems/239.avi"
}

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/service.py", line 289, in _handle_service_platform_call
    await func(entity, data)
  File "/config/custom_components/media_player/dlna_dmr.py", line 306, in async_play_media
    mime_type = HOME_ASSISTANT_UPNP_MIME_TYPE_MAPPING[media_type]
KeyError: 'video/avi'
----------------------------------------------------------------------------
media_player.play_media
{
  "entity_id": "media_player.42as650_series_2",
  "media_content_type": "video",
  "media_content_id": "http://10.0.1.1:8200/MediaItems/239.avi"
}

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/service.py", line 289, in _handle_service_platform_call
    await func(entity, data)
  File "/config/custom_components/media_player/dlna_dmr.py", line 315, in async_play_media
    media_id, title, mime_type, upnp_class)
  File "/usr/local/lib/python3.6/site-packages/async_upnp_client/dlna.py", line 574, in async_set_transport_uri
    CurrentURIMetaData=meta_data)
  File "/usr/local/lib/python3.6/site-packages/async_upnp_client/__init__.py", line 626, in async_call
    (status_code, response_body))
async_upnp_client.UpnpError: Error during async_call(), status: 500, body: <?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
 <s:Body>
  <s:Fault>
   <faultcode>s:Client</faultcode>
   <faultstring>UPnPError</faultstring>
   <detail>
    <UPnPError xmlns="urn:schemas-upnp-org:control-1-0">
     <errorCode>714</errorCode>
     <errorDescription>Illegal MIME-type</errorDescription>
    </UPnPError>
   </detail>
  </s:Fault>
 </s:Body>
</s:Envelope>

Additional information: I can play same video through upnp-mediarenderer-client node https://github.com/thibauts/node-upnp-mediarenderer-client

Files puled from TV:

http://10.0.1.108:55000/nrc/ddd.xml
http://10.0.1.108:55000/dms/ddd.xml
http://10.0.1.108:55000/dms/sdd_0.xml
http://10.0.1.108:55000/dms/sdd_1.xml
http://10.0.1.108:55000/dmr/ddd.xml
http://10.0.1.108:55000/dmr/sdd_0.xml
http://10.0.1.108:55000/dmr/sdd_1.xml
http://10.0.1.108:55000/dmr/sdd_2.xml
http://10.0.1.108:55000/pac/ddd.xml
http://10.0.1.108:55000/pac/sdd_0.xml

list.txt contains available ContentType gathered trough node upnp-mediarender-client.

viera-dlna.zip

dgomes commented 5 years ago

@StevenLooman

StevenLooman commented 5 years ago

Thank you for the report. Home assistant has its own understanding of media types. These include:

In the first part you're sending video/avi. The component doesn't understand this and reports an error.

Thankfully, you've looked at the code and saw you're supposed to send the home assistant media type (video). This translates to video/*. Your device doesn't seem to be able to handle this and reports an error.

I think the component should be more flexible and support sending what the user specifies. In your case video/avi. Another problem rises however, as there is no (loose) mapping for UPnP/DIDL-Lite class mapping. We can probably work around this loosely interpreting the given media_content_type.

I'll try to fix this at the end of this week. Please stay tuned.

Tony763 commented 5 years ago

Open for testing, if you need something more just let me know.

I already tried to change to video/avi in code but it was probably wrong. Message from UPNP was same: 714 Illegal MIME-type

'video': 'video/*',    =>  'video': 'video/avi',    =>  'video': 'video/mpeg', 
StevenLooman commented 5 years ago

You can enable UPnP-traffic dumping to investigate further. Add this to your home assistant configuration:

logger:
  default: warning
  logs:
    homeassistant.components.media_player.dlna_dmr: debug
    async_upnp_client.profiles.dlna: debug
    async_upnp_client.traffic: debug

This will silence most of home assistant but the UPnP things.

I'm guessing the the meta data still contains an invalid mime type. You're looking for something that looks like:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Body>
      <u:SetAVTransportURI xmlns:u="urn:schemas-upnp-org:service:AVTransport:1">
         <InstanceID>0</InstanceID>
         <CurrentURI>http://example.org/video.avi</CurrentURI>
         <CurrentURIMetaData>&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;DIDL-Lite xmlns=&quot;urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/&quot; xmlns:upnp=&quot;urn:schemas-upnp-org:metadata-1-0/upnp/&quot; xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&quot; xmlns:sec=&quot;http://www.sec.co.kr/&quot;&gt;
&lt;item id=&quot;f-0&quot; parentID=&quot;0&quot; restricted=&quot;0&quot;&gt;
    &lt;dc:title&gt;Video&lt;/dc:title&gt;
    &lt;dc:creator&gt;Example&lt;/dc:creator&gt;
    &lt;upnp:class&gt;object.item.videoItem&lt;/upnp:class&gt;
    &lt;res protocolInfo=&quot;http-get:*:video/avi:DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=01700000000000000000000000000000&quot;&gt;http://example.org/video.avi&lt;/res&gt;
&lt;/item&gt;
&lt;/DIDL-Lite&gt;</CurrentURIMetaData>
      </u:SetAVTransportURI>
   </s:Body>
</s:Envelope>

The part in CurrentURIMetaData is what you are looking for. Please try to play something and show what is sent.

Tony763 commented 5 years ago
<CurrentURIMetaData>&lt;DIDL-Lite xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:ns1="urn:schemas-upnp-org:metadata-1-0/upnp/"
 xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"&gt;&lt;item id="0" parentID="0"
restricted="1"&gt;&lt;dc:title&gt;Home 
Assistant&lt;/dc:title&gt;&lt;ns1:class&gt;object.item.videoItem&lt;/ns1:class&gt;&lt;res
 protocolInfo="http-get:*:video/x-msvideo
:DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=01700000000000000000000000000000"&gt;
http://10.0.1.1:8200/MediaItems/239.avi&lt;/res&gt;&lt;/item&gt;&lt;/DIDL-Lite&gt;</CurrentURIMetaData>
</u:SetAVTransportURI>
</s:Body>
</s:Envelope>

So it sending video/x-msvideo but it is listed in available content:

{
    "protocol": "http-get",
    "network": "*",
    "contentFormat": "video/avi",
    "additionalInfo": "*"
  },
  {
    "protocol": "http-get",
    "network": "*",
    "contentFormat": "video/x-msvideo",
    "additionalInfo": "*"
  },
  {
    "protocol": "http-get",
    "network": "*",
    "contentFormat": "video/divx",
    "additionalInfo": "*"
  },
  {
    "protocol": "http-get",
    "network": "*",
    "contentFormat": "video/x-matroska",
    "additionalInfo": "*"
  },
  {
    "protocol": "http-get",
    "network": "*",
    "contentFormat": "video/mpeg",
    "additionalInfo": "*"
  },

I tried another video with video/x-matroska but result is same.

Complete log: home-assistant.log

StevenLooman commented 5 years ago

Looking at node-upnp-mediarenderer-client, I see that it sends a different kind of protocolInfo. It does adds a * for the last part, instead of what we send: DLNA.ORG_OP=01.... Can you try changing python-didl-lite a bit and see what the result is?

I this doesn't work, can you try dumping your network traffic? You can use a tool like wireshark for this.

StevenLooman commented 5 years ago

I this doesn't work, can you try dumping your network traffic? You can use a tool like wireshark for this.

An easier option would be to just add some console.log() statements at the right places, such as before line 162, in node-upnp-mediarenderer-client.

Tony763 commented 5 years ago

Here is console.log(params)

{ InstanceID: 0,
  CurrentURI: 'http://10.0.1.1:8200/MediaItems/239.avi',
  CurrentURIMetaData: '<DIDL-Lite xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/" 
  xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sec="http://www.sec.co.kr/"
  xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/">
  <item id="0" parentID="-1" restricted="false">
  <upnp:class>object.item.videoItem.movie</upnp:class>
  <dc:title>Some Movie Title</dc:title>
  <dc:creator>John Doe</dc:creator>
  <res protocolInfo="http-get:*:video/avi:*">http://10.0.1.1:8200/MediaItems/239.avi</res>
  <sec:CaptionInfo sec:type="srt">http://url.to.some/subtitles.srt</sec:CaptionInfo>
  <sec:CaptionInfoEx sec:type="srt">http://url.to.some/subtitles.srt</sec:CaptionInfoEx>
  <res protocolInfo="http-get:*:text/srt:*">http://url.to.some/subtitles.srt</res></item></DIDL-Lite>' }

It really sends * in aditionalinfo.

 var contentType = options.contentType || 'video/mpeg'; // Default to something generic
 var protocolInfo = 'http-get:*:' + contentType + ':*';

I tried to change a node-upnp-mediarenderer-client:

video/mpeg:*  worked
video/mpeg:blabla  not worked
video/x-msvideo:DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=01700000000000000000000000000000 not worked
video/mpeg:DLNA.ORG_PN=AVC_TS_HD_24_AC3_ISO;DLNA.ORG_FLAGS=8d100000000000000000000000000000  worked

So TV need exactly defined content and reject anything other. Last entry I get bynode-upnp-mediarenderer-client.

var MediaRendererClient = require('upnp-mediarenderer-client');

var client = new MediaRendererClient('http://10.0.1.108:55000/dmr/ddd.xml');

client.getSupportedProtocols(function(err, protocols) {
  if(err) throw err;
  console.log(JSON.stringify(protocols, null, 2));
});

Is it possible to integrate this to HA and check available protocols after discovery or before playing a media?

StevenLooman commented 5 years ago

What is the result from getSupportedProtocols?

I don't think the call getSupportedProtocols has anything to do with this. I does not appear in any of the DLNA/DMR specifications (AVTransport:1-3, ConnectionManager:1-3, RenderingControl:1-3). It is present in the DeviceProtection:1 spec though.

Some devices are very picky about the flags. When I worked on this part, I never saw * being used (or was even aware that that would work), thus I never used it. The used library (async_upnp_client) tries to get the flags from the source and uses these. If these are not present, it defaults to DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=00000000000000000000000000000000. Maybe the default should be *. If you google the terms, such as DLNA.ORG_OP, you can find an explanation for it.

The default, however, is not used in your case, DLNA.ORG_FLAGS are not 0. I'm uncertain whether the library should always send *, or copy the source. I need to do some experimenting myself first.

Feel free to keep trying things!

Tony763 commented 5 years ago

As You can read here https://github.com/thibauts/node-upnp-mediarenderer-client/issues/11 getSupportedProtocols will list all supported content by TV. It's way I get a list of supported content. list.txt in viera-dlna.zip.

My though is to use it like this:

Check flags by default method (async_upnp_client) => if not found try getSupportedProtocols => if not found try default flags.

Sending always * could make problems on other TVs.

I think its working for me because it is supported on my TV. If You open list.txt You can see this:

For video/mpeg there are many available flags:

"protocol": "http-get","network": "*","contentFormat": "video/mpeg","additionalInfo": "DLNA.ORG_PN=AVC_TS_HD_24_AC3_ISO;DLNA.ORG_FLAGS=8d100000000000000000000000000000"
"protocol": "http-get","network": "*","contentFormat": "video/mpeg","additionalInfo": "DLNA.ORG_PN=MPEG_TS_HD_NA_ISO;DLNA.ORG_FLAGS=8d100000000000000000000000000000"
"protocol": "http-get","network": "*","contentFormat": "video/mpeg","additionalInfo": "DLNA.ORG_PN=MPEG_PS_PAL;DLNA.ORG_FLAGS=8d100000000000000000000000000000"
"protocol": "http-get","network": "*","contentFormat": "video/mpeg","additionalInfo": "*"

But for video/x-msvideo or video/avi or video/x-matroska and so, there is only one instance with *

"protocol": "http-get","network": "*","contentFormat": "video/x-matroska","additionalInfo": "*"
"protocol": "http-get","network": "*","contentFormat": "video/avi","additionalInfo": "*"
"protocol": "http-get","network": "*","contentFormat": "video/x-msvideo","additionalInfo": "*"
"protocol": "http-get","network": "*","contentFormat": "video/divx","additionalInfo": "*"
Tony763 commented 5 years ago

Another thing. My log is full of :


Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
    await self.async_device_update()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 347, in async_device_update
    await self.async_update()
  File "/config/custom_components/media_player/dlna_dmr.py", line 192, in async_update
    await self._device.async_update()
  File "/config/deps/lib/python3.6/site-packages/async_upnp_client/profiles/dlna.py", line 147, in async_update
    await self._async_poll_transport_info()
  File "/config/deps/lib/python3.6/site-packages/async_upnp_client/profiles/dlna.py", line 161, in _async_poll_transport_info
    result = await action.async_call(InstanceID=0)
  File "/config/deps/lib/python3.6/site-packages/async_upnp_client/client.py", line 511, in async_call
    (status_code, response_body))
async_upnp_client.client.UpnpError: Error during async_call(), status: 400, body: ```
StevenLooman commented 5 years ago

Home Assistant polls every N-seconds for transport info. It defaults to InstanceID=0. Maybe your TV doesn't have an InstanceID of 0?

async_upnp_client includes a CLI utility called upnp-client. Can you try to find a combination of parameters which work for you? An example is:

❯❯❯ upnp-client --pprint call-action http://192.168.178.69:49152/description.xml AVT/GetTransportInfo InstanceID=0
{
    "timestamp": 1550004181.8096402,
    "service_id": "urn:upnp-org:serviceId:AVTransport",
    "service_type": "urn:schemas-upnp-org:service:AVTransport:1",
    "action": "GetTransportInfo",
    "in_parameters": {
        "InstanceID": 0
    },
    "out_parameters": {
        "CurrentTransportState": "PLAYING",
        "CurrentTransportStatus": "OK",
        "CurrentSpeed": "1"
    }
}

You can get more info by adding the --debug parameter.

StevenLooman commented 5 years ago

Only now I see the call isn't getSupportedProtocols, but GetProtocolInfo. I'll try to incorporate this.

❯❯❯ upnp-client --pprint call-action http://192.168.178.69:49152/description.xml CM/GetProtocolInfo
{
    "timestamp": 1550004452.5558414,
    "service_id": "urn:upnp-org:serviceId:ConnectionManager",
    "service_type": "urn:schemas-upnp-org:service:ConnectionManager:1",
    "action": "GetProtocolInfo",
    "in_parameters": {},
    "out_parameters": {
        "Source": "",
        "Sink": "http-get:*:application/flac:*,http-get:*:audio/flac:*,http-get:*:audio/x-flac:*,http-get:*:audio/aac:*,http-get:*:audio/x-aiff:*,http-get:*:audio/dff:*,http-get:*:audio/x-dff:*,http-get:*:audio/dsd:*,http-get:*:audio/x-dsd:*,http-get:*:audio/dsf:*,http-get:*:audio/x-dsf:*,http-get:*:audio/m4a:*,http-get:*:audio/x-m4a:*,http-get:*:audio/mp1:*,http-get:*:audio/mp4:*,http-get:*:audio/mpeg:*,http-get:*:audio/x-mpeg:*,http-get:*:audio/ogg:*,http-get:*:audio/vorbis:*,http-get:*:audio/wav:*,http-get:*:audio/x-wav:*,http-get:*:audio/wave:*,http-get:*:audio/x-ms-wma:*,http-get:*:audio/x-ogg:*,http-get:*:audio/x-scpls:*,http-get:*:audio/x-vorbis+ogg:*,http-get:*:audio/x-vorbis:*,http-get:*:video/mp4:*"
    }
}
Tony763 commented 5 years ago

Only instanceID=0 works, higher number give me Error 718 - Invalid InstanceID and my TV appears it have no /description.xml. upnp-client give me Recieved status code: 403. I have to use /dmr/ddd.xml in your command.

>>> upnp-client --pprint call-action http://10.0.1.108:55000/dmr/ddd.xml AVT/GetTransportInfo InstanceID=0
{
    "timestamp": 1550092127.9422202,
    "service_id": "urn:upnp-org:serviceId:AVTransport",
    "service_type": "urn:schemas-upnp-org:service:AVTransport:1",
    "action": "GetTransportInfo",
    "in_parameters": {
        "InstanceID": 0
    },
    "out_parameters": {
        "CurrentTransportState": "NO_MEDIA_PRESENT",
        "CurrentTransportStatus": "OK",
        "CurrentSpeed": "1"
    }
}

upnp-client --pprint call-action http://10.0.1.108:55000/dmr/ddd.xml CM/GetProtocolInfo
{
    "timestamp": 1550092313.9720783,
    "service_id": "urn:upnp-org:serviceId:ConnectionManager",
    "service_type": "urn:schemas-upnp-org:service:ConnectionManager:1",
    "action": "GetProtocolInfo",
    "in_parameters": {},
    "out_parameters": {
        "Source": "",
        "Sink": "http-get:*:image/jpeg:DLNA.ORG_PN=JPEG_SM;DLNA.ORG_FLAGS=8c900000000000000000000000000000,http-get:*:image/jpeg:DLNA.ORG_PN=JPEG_MED;DLNA.ORG_FLAGS=8c900000000000000000000000000000,http-get:*:image/jpeg:DLNA.ORG_PN=JPEG_LRG;DLNA.ORG_FLAGS=8c900000000000000000000000000000,http-get:*:image/jpeg:DLNA.ORG_PN=JPEG_TN;DLNA.ORG_FLAGS=8c900000000000000000000000000000,http-get:*:image/jpeg:DLNA.ORG_PN=JPEG_SM_ICO;DLNA.ORG_FLAGS=8c900000000000000000000000000000,http-get:*:image/jpeg:DLNA.ORG_PN=JPEG_LRG_ICO;DLNA.ORG_FLAGS=8c900000000000000000000000000000,http-get:*:video/mpeg:DLNA.ORG_PN=MPEG_PS_PAL;DLNA.ORG_FLAGS=8d100000000000000000000000000000,http-get:*:video/mpeg:DLNA.ORG_PN=MPEG_PS_PAL_XAC3;DLNA.ORG_FLAGS=8d100000000000000000000000000000,http-get:*:application/x-dtcp1;CONTENTFORMAT=\"video/mpeg\":DLNA.ORG_PN=DTCP_MPEG_PS_PAL;DLNA.ORG_FLAGS=8d118000000000000000000000000000,http-get:*:application/x-dtcp1;CONTENTFORMAT=\"video/mpeg\":DLNA.ORG_PN=DTCP_MPEG_PS_PAL_XAC3;DLNA.ORG_FLAGS=8d118000000000000000000000000000,http-get:*:video/mpeg:DLNA.ORG_PN=MPEG_PS_NTSC;DLNA.ORG_FLAGS=8d100000000000000000000000000000,http-get:*:video/mpeg:DLNA.ORG_PN=MPEG_PS_NTSC_XAC3;DLNA.ORG_FLAGS=8d100000000000000000000000000000,http-get:*:application/x-dtcp1;CONTENTFORMAT=\"video/mpeg\":DLNA.ORG_PN=DTCP_MPEG_PS_NTSC;DLNA.ORG_FLAGS=8d118000000000000000000000000000,http-get:*:application/x-dtcp1;CONTENTFORMAT=\"video/mpeg\":DLNA.ORG_PN=DTCP_MPEG_PS_NTSC_XAC3;DLNA.ORG_FLAGS=8d118000000000000000000000000000,http-get:*:video/vnd.dlna.mpeg-tts:DLNA.ORG_PN=MPEG_TS_SD_EU_T;DLNA.ORG_FLAGS=8d100000000000000000000000000000,http-get:*:video/vnd.dlna.mpetts:DLNA.ORG_PN=MPEG_TS_SD_EU;DLNA.ORG_FLAGS=8d100000000000000000000000000000,http-get:*:video/mpeg:DLNA.ORG_PN=MPEG_TS_SD_EU_ISO;DLNA.ORG_FLAGS=8d100000000000000000000000000000,http-get:*:video/vnd.dlna.mpeg-tts:DLNA.ORG_PN=MPEG_TS_SD_EU_AC3_T;DLNA.ORG_FLAGS=8d100000000000000000000000000000,http-get:*:video/mpeg:DLNA.ORG_PN=MPEG_TS_SD_EU_AC3_ISO;DLNA.ORG_FLAGS=8d100000000000000000000000000000,http-get:*:video/vnd.dlna.mpeg-tts:DLNA.ORG_PN=AVC_TS_HD_50_AC3_T;DLNA.ORG_FLAGS=8d100000000000000000000000000000,http-get:*:video/vnd.dlna.mpeg-tts:DLNA.ORG_PN=AVC_TS_HD_50_AC3;DLNA.ORG_FLAGS=8d100000000000000000000000000000,http-get:*:video/mpeg:DLNA.ORG_PN=AVC_TS_HD_50_AC3_ISO;DLNA.ORG_FLAGS=8d100000000000000000000000000000,http-get:*:application/x-dtcp1;CONTENTFORMAT=\"video/vnd.dlna.mpeg-tts\":DLNA.ORG_PN=DTCP_MPEG_TS_SD_EU_T;DLNA.ORG_FLAGS=8d118000000000000000000000000000,http-get:*:application/x-dtcp1;CONTENTFORMAT=\"video/vnd.dlna.mpeg-tts\":DLNA.ORG_PN=DTCP_MPEG_TS_SD_EU;DLNA.ORG_FLAGS=8d118000000000000000000000000000,http-get:*:application/x-dtcp1;CONTENTFORMAT=\"video/mpeg\":DLNA.ORG_PN=DTCP_MPEG_TS_SD_EU_ISO;DLNA.ORG_FLAGS=8d118000000000000000000000000000,http-get:*:application/x-dtcp1;CONTENTFORMAT=\"video/vnd.dlna.mpeg-tts\":DLNA.ORG_PN=DTCP_MPEG_TS_SD_EU_AC3_T;DLNA.ORG_FLAGS=8d118000000000000000000000000000,http-get:*:application/x-dtcp1;CONTENTFORMAT=\"video/mpeg\":DLNA.ORG_PN=DTCP_MPEG_TS_SD_EU_AC3_ISO;DLNA.ORG_FLAGS=8d118000000000000000000000000000,http-get:*:application/x-dtcp1;CONTENTFORMAT=\"video/vnd.dlna.mpeg-tts\":DLNA.ORG_PN=DTCP_AVC_TS_HD_50_AC3_T;DLNA.ORG_FLAGS=8d118000000000000000000000000000,http-get:*:application/x-dtcp1;CONTENTFORMAT=\"video/vnd.dlna.mpeg-tts\":DLNA.ORG_PN=DTCP_AVC_TS_HD_50_AC3;DLNA.ORG_FLAGS=8d118000000000000000000000000000,http-get:*:application/x-dtcp1;CONTENTFORMAT=\"video/mpeg\":DLNA.ORG_PN=DTCP_AVC_TS_HD_50_AC3_ISO;DLNA.ORG_FLAGS=8d118000000000000000000000000000,http-get:*:video/vnd.dlna.mpeg-tts:DLNA.ORG_PN=MPEG_TS_JP_T;DLNA.ORG_FLAGS=8d100000000000000000000000000000,http-get:*:video/vnd.dlna.mpeg-tts:DLNA.ORG_PN=MPEG_TS_SD_JP_MPEG1_L2_T;DLNA.ORG_FLAGS=8d100000000000000000000000000000,http-get:*:video/vnd.dlna.mpeg-tts:DLNA.ORG_PN=AVC_TS_JP_AAC_T;DLNA.ORG_FLAGS=8d100000000000000000000000000000,http-get:*:video/vnd.dlna.mpeg-tts:DLNA.ORG_PN=MPEG_TS_SD_NA_T;DLNA.ORG_FLAGS=8d100000000000000000000000000000,http-get:*:video/vnd.dlna.mpeg-tts:DLNA.ORG_PN=MPEG_TS_SD_NA;DLNA.ORG_FLAGS=8d100000000000000000000000000000,http-get:*:video/mpeg:DLNA.ORG_PN=MPEG_TS_SD_NA_ISO;DLNA.ORG_FLAGS=8d100000000000000000000000000000,http-get:*:video/vnd.dlna.mpeg-tts:DLNA.ORG_PN=MPEG_TS_HD_NA_T;DLNA.ORG_FLAGS=8d100000000000000000000000000000,http-get:*:video/vnd.dlna.mpeg-tts:DLNA.ORG_PN=MPEG_TS_HD_NA;DLNA.ORG_FLAGS=8d100000000000000000000000000000,http-get:*:video/mpeg:DLNA.ORG_PN=MPEG_TS_HD_NA_ISO;DLNA.ORG_FLAGS=8d100000000000000000000000000000,http-get:*:video/vnd.dlna.mpeg-tts:DLNA.ORG_PN=MPEG_TS_SD_60_AC3_T;DLNA.ORG_FLAGS=8d100000000000000000000000000000,http-get:*:video/vnd.dlna.mpeg-tts:DLNA.ORG_PN=AVC_TS_HD_60_AC3_X_T;DLNA.ORG_FLAGS=8d100000000000000000000000000000,http-get:*:video/vnd.dlna.mpeg-tts:DLNA.ORG_PN=AVC_TS_HD_60_AC3_T;DLNA.ORG_FLAGS=8d100000000000000000000000000000,http-get:*:video/vnd.dlna.mpeg-tts:DLNA.ORG_PN=AVC_TS_HD_60_AC3;DLNA.ORG_FLAGS=8d100000000000000000000000000000,http-get:*:video/mpeg:DLNA.ORG_PN=AVC_TS_HD_60_AC3_ISO;DLNA.ORG_FLAGS=8d100000000000000000000000000000,http-get:*:video/vnd.dlna.mpeg-tts:DLNA.ORG_PN=AVC_TS_HD_24_AC3_T;DLNA.ORG_FLAGS=8d100000000000000000000000000000,http-get:*:video/vnd.dlna.mpeg-tts:DLNA.ORG_PN=AVC_TS_HD_24_AC3;DLNA.ORG_FLAGS=8d100000000000000000000000000000,http-get:*:video/mpeg:DLNA.ORG_PN=AVC_TS_HD_24_AC3_ISO;DLNA.ORG_FLAGS=8d100000000000000000000000000000,http-get:*:video/vnd.dlna.mpeg-tts:DLNA.ORG_PN=AVC_TS_MP_HD_AAC_LTP_T;DLNA.ORG_FLAGS=8d100000000000000000000000000000,http-get:*:application/x-dtcp1;CONTENTFORMAT=\"video/vnd.dlna.mpeg-tts\":DLNA.ORG_PN=DTCP_MPEG_TS_JP_T;ARIB.OR.JP_PN=MPEG_TTS_CP;DLNA.ORG_FLAGS=8d118000000000000000000000000000,http-get:*:application/x-dtcp1;CONTENTFORMAT=\"video/vnd.dlna.mpeg-tts\":DLNA.ORG_PN=DTCP_MPEG_TS_SD_JP_MPEG1_L2_T;DLNA.ORG_FLAGS=8d118000000000000000000000000000,http-get:*:application/x-dtcp1;CONTENTFORMAT=\"video/vnd.dlna.mpeg-tts\":DLNA.ORG_PN=DTCP_AVC_TS_JP_AAC_T;DLNA.ORG_FLAGS=8d118000000000000000000000000000,http-get:*:application/x-dtcp1;CONTENTFORMAT=\"video/vnd.dlna.mpeg-tts\":DLNA.ORG_PN=DTCP_MPEG_TS_SD_NA_T;DLNA.ORG_FLAGS=8d118000000000000000000000000000,http-get:*:application/x-dtcp1;CONTENTFORMAT=\"video/vnd.dlna.mpeg-tts\":DLNA.ORG_PN=DTCP_MPEG_TS_SD_NA;DLNA.ORG_FLAGS=8d118000000000000000000000000000,http-get:*:application/x-dtcp1;CONTENTFORMAT=\"video/mpeg\":DLNA.ORG_PN=DTCP_MPEG_TS_SD_NA_ISO;DLNA.ORG_FLAGS=8d118000000000000000000000000000,http-get:*:application/x-dtcp1;CONTENTFORMAT=\"video/vnd.dlna.mpeg-tts\":DLNA.ORG_PN=DTCP_MPEG_TS_HD_NA_T;DLNA.ORG_FLAGS=8d118000000000000000000000000000,http-get:*:application/x-dtcp1;CONTENTFORMAT=\"video/vnd.dlna.mpeg-tts\":DLNA.ORG_PN=DTCP_MPEG_TS_HD_NA;DLNA.ORG_FLAGS=8d118000000000000000000000000000,http-get:*:application/x-dtcp1;CONTENTFORMAT=\"video/mpeg\":DLNA.ORG_PN=DTCP_MPEG_TS_HD_NA_ISO;DLNA.ORG_FLAGS=8d118000000000000000000000000000,http-get:*:application/x-dtcp1;CONTENTFORMAT=\"video/vnd.dlna.mpeg-tts\":DLNA.ORG_PN=DTCP_MPEG_TS_SD_60_AC3_T;DLNA.ORG_FLAGS=8d118000000000000000000000000000,http-get:*:application/x-dtcp1;CONTENTFORMAT=\"video/vnd.dlna.mpeg-tts\":DLNA.ORG_PN=DTCP_AVC_TS_HD_60_AC3_X_T;DLNA.ORG_FLAGS=8d118000000000000000000000000000,http-get:*:application/x-dtcp1;CONTENTFORMAT=\"video/vnd.dlna.mpeg-tts\":DLNA.ORG_PN=DTCP_AVC_TS_HD_60_AC3_T;DLNA.ORG_FLAGS=8d118000000000000000000000000000,http-get:*:application/x-dtcp1;CONTENTFORMAT=\"video/vnd.dlna.mpeg-tts\":DLNA.ORG_PN=DTCP_AVC_TS_HD_60_AC3;DLNA.ORG_FLAGS=8d118000000000000000000000000000,http-get:*:application/x-dtcp1;CONTENTFORMAT=\"video/mpeg\":DLNA.ORG_PN=DTCP_AVC_TS_HD_60_AC3_ISO;DLNA.ORG_FLAGS=8d118000000000000000000000000000,http-get:*:application/x-dtcp1;CONTENTFORMAT=\"video/vnd.dlna.mpeg-tts\":DLNA.ORG_PN=DTCP_AVC_TS_HD_24_AC3_T;DLNA.ORG_FLAGS=8d118000000000000000000000000000,http-get:*:application/x-dtcp1;CONTENTFORMAT=\"video/vnd.dlna.mpeg-tts\":DLNA.ORG_PN=DTCP_AVC_TS_HD_24_AC3;DLNA.ORG_FLAGS=8d118000000000000000000000000000,http-get:*:application/x-dtcp1;CONTENTFORMAT=\"video/mpeg\":DLNA.ORG_PN=DTCP_AVC_TS_HD_24_AC3_ISO;DLNA.ORG_FLAGS=8d118000000000000000000000000000,http-get:*:application/x-dtcp1;CONTENTFORMAT=\"video/vnd.dlna.mpeg-tts\":DLNA.ORG_PN=DTCP_AVC_TS_MP_HD_AAC_LTP_T;DLNA.ORG_FLAGS=8d118000000000000000000000000000,http-get:*:audio/mpeg:DLNA.ORG_PN=MP3,http-get:*:audio/L16:DLNA.ORG_PN=LPCM,http-get:*:image/jpeg:PANASONIC.COM_PN=MPO_3D,http-get:*:image/jpeg:*,http-get:*:video/avi:*,http-get:*:video/x-msvideo:*,http-get:*:video/divx:*,http-get:*:video/x-matroska:*,http-get:*:video/mpeg:*,http-get:*:video/vnd.dlna.mpeg-tts:*,http-get:*:application/x-dtcp1;CONTENTFORMAT=\"video/mpeg\":*,http-get:*:application/x-dtcp1;CONTENTFORMAT=\"video/vnd.dlna.mpeg-tts\":*,http-get:*:video/mp4:*,http-get:*:video/x-flv:*,http-get:*:video/flv:*,http-get:*:video/x-ms-wmv:*,http-get:*:video/x-ms-asf:*,http-get:*:video/3gpp:*,http-get:*:video/3gpp2:*,http-get:*:audio/mpeg:*,http-get:*:audio/mp4:*,http-get:*:audio/x-m4a:*,http-get:*:audio/x-ms-wma:*,http-get:*:audio/x-ms-asf:*,http-get:*:audio/wav:*,http-get:*:audio/wave:*,http-get:*:audio/x-wav:*,http-get:*:audio/flac:*,http-get:*:audio/x-flac:*,http-get:*:audio/aac:*,http-get:*:audio/x-aac:*,http-get:*:audio/vnd.dlna.adts:*,http-get:*:audio/L16:*"
    }
}
StevenLooman commented 5 years ago

Only instanceID=0 works, higher number give me Error 718 - Invalid InstanceID and my TV appears it have no /description.xml. upnp-client give me Recieved status code: 403. I have to use /dmr/ddd.xml in your command.

Yes, the given URL was specific for this/my device.

Strange though, You're sending InstanceID=0 and get a valid reply, while the same request (or at least should be) from home assistant results in a 400-error (Bad request.)

Tony763 commented 5 years ago

Tried call it from Hass.io but I'm getting error. There is missing package. From Ubuntu it's work.

➜  bin ./upnp-client --pprint call-action http://10.0.1.108:55000/dmr/ddd.xml AVT/GetTransportInfo InstanceID=0
Traceback (most recent call last):
  File "./upnp-client", line 7, in <module>
    from async_upnp_client.cli import main
ModuleNotFoundError: No module named 'async_upnp_client'

It only occur when TV is off.

2019-02-14 21:58:33 DEBUG (MainThread) [async_upnp_client.client.traffic] Sending request:
POST http://10.0.1.108:55000/dmr/control_2
SOAPAction: "urn:schemas-upnp-org:service:AVTransport:1#GetTransportInfo"
Host: 10.0.1.108:55000
Content-Type: text/xml; charset="utf-8"
Content-Length: 295
<?xml version="1.0"?><s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><u:GetTransportInfo xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"><InstanceID>0</InstanceID></u:GetTransportInfo></s:Body></s:Envelope>

2019-02-14 21:58:33 DEBUG (MainThread) [async_upnp_client.client.traffic] Got response:
400
Connection: close

2019-02-14 21:58:33 ERROR (MainThread) [homeassistant.helpers.entity] Update for media_player.42as650_series_2 fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
    await self.async_device_update()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 347, in async_device_update
    await self.async_update()
  File "/config/custom_components/media_player/dlna_dmr.py", line 192, in async_update
    await self._device.async_update()
  File "/config/deps/lib/python3.6/site-packages/async_upnp_client/profiles/dlna.py", line 147, in async_update
    await self._async_poll_transport_info()
  File "/config/deps/lib/python3.6/site-packages/async_upnp_client/profiles/dlna.py", line 161, in _async_poll_transport_info
    result = await action.async_call(InstanceID=0)
  File "/config/deps/lib/python3.6/site-packages/async_upnp_client/client.py", line 511, in async_call
    (status_code, response_body))
async_upnp_client.client.UpnpError: Error during async_call(), status: 400, body: 

When on its OK.

2019-02-14 21:56:23 DEBUG (MainThread) [async_upnp_client.client.traffic] Sending request:
POST http://10.0.1.108:55000/dmr/control_2
SOAPAction: "urn:schemas-upnp-org:service:AVTransport:1#GetTransportInfo"
Host: 10.0.1.108:55000
Content-Type: text/xml; charset="utf-8"
Content-Length: 295
<?xml version="1.0"?><s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><u:GetTransportInfo xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"><InstanceID>0</InstanceID></u:GetTransportInfo></s:Body></s:Envelope>

2019-02-14 21:56:23 DEBUG (MainThread) [async_upnp_client.client.traffic] Got response:
200
Content-Length: 471
Content-Type: text/xml; charset="utf-8"
EXT: 
Server: Panasonic-VIErA/1, UPnP/1.0, Panasonic MIL DLNA SERVER
Connection: close

<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
 <s:Body>
  <u:GetTransportInfoResponse xmlns:u="urn:schemas-upnp-org:service:AVTransport:1">
   <CurrentTransportState>NO_MEDIA_PRESENT</CurrentTransportState>
   <CurrentTransportStatus>OK</CurrentTransportStatus>
   <CurrentSpeed>1</CurrentSpeed>
  </u:GetTransportInfoResponse>
 </s:Body>
</s:Envelope>

http://10.0.1.108:55000/dmr/control_2 is accessible only when TV is on. I tried to open it in browser: When off - response is 400 when on - response 403.

StevenLooman commented 5 years ago

Thank you for your responses. I hope to fix this during this week.

StevenLooman commented 5 years ago

video/x-msvideo is chosen because the server hosting the media reports this. Also, the flags are taken from the server.

Can you try copying this changed async_upnp_client/profiles/dlna.py into your local installation and try again?

The approach is as follows:

Edit: Note the URL to the file has changed since the last edit.

Tony763 commented 5 years ago

Not working.

2019-03-08 20:23:17 DEBUG (MainThread) [async_upnp_client.client.traffic] Got response:
200
Content-Length: 1055000576
Accept-Ranges: bytes
Content-Type: video/x-msvideo
Date: Fri, 08 Mar 2019 19:23:17 GMT
Last-Modified: Sat, 15 Sep 2018 14:48:55 GMT
Server: Linux/4.15.0-45-generic, UPnP/1.0, Portable SDK for UPnP devices/1.8.3
X-User-Agent: redsonic
Content-Disposition: attachment; filename="babovresky_2_-2014.avi"
Accept-Ranges: bytes
transferMode.dlna.org: StreamingCONNECTION: close

async_upnp_client: OMITTING BODY
2019-03-08 20:23:17 DEBUG (MainThread) [async_upnp_client.client.traffic] Sending request:
POST http://10.0.1.108:55000/dmr/control_2
SOAPAction: "urn:schemas-upnp-org:service:AVTransport:1#SetAVTransportURI"
Host: 10.0.1.108:55000
Content-Type: text/xml; charset="utf-8"
Content-Length: 925
<?xml version="1.0"?><s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><u:SetAVTransportURI xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"><InstanceID>0</InstanceID>
<CurrentURI>http://10.0.1.1:49152/content/media/object_id/61001/res_id/0/ext/file.avi</CurrentURI>
<CurrentURIMetaData>&lt;DIDL-Lite xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:ns1="urn:schemas-upnp-org:metadata-1-0/upnp/" xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"&gt;&lt;item id="0" parentID="0" restricted="1"&gt;&lt;dc:title&gt;Home Assistant&lt;/dc:title&gt;&lt;ns1:class&gt;object.item.videoItem&lt;/ns1:class&gt;&lt;res protocolInfo="http-get:*:video/x-msvideo:*"&gt;http://10.0.1.1:49152/content/media/object_id/61001/res_id/0/ext/file.avi&lt;/res&gt;&lt;/item&gt;&lt;/DIDL-Lite&gt;</CurrentURIMetaData></u:SetAVTransportURI></s:Body></s:Envelope>

2019-03-08 20:23:17 DEBUG (MainThread) [async_upnp_client.client.traffic] Got response:
500
Content-Length: 490
Content-Type: text/xml; charset="utf-8"
EXT: 
Server: Panasonic-VIErA/1, UPnP/1.0, Panasonic MIL DLNA SERVER
Connection: close

<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
 <s:Body>
  <s:Fault>
   <faultcode>s:Client</faultcode>
   <faultstring>UPnPError</faultstring>
   <detail>
    <UPnPError xmlns="urn:schemas-upnp-org:control-1-0">
     <errorCode>714</errorCode>
     <errorDescription>Illegal MIME-type</errorDescription>
    </UPnPError>
   </detail>
  </s:Fault>
 </s:Body>
</s:Envelope>

2019-03-08 20:23:17 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.140545825791504] Error during async_call(), status: 500, body: <?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
 <s:Body>
  <s:Fault>
   <faultcode>s:Client</faultcode>
   <faultstring>UPnPError</faultstring>
   <detail>
    <UPnPError xmlns="urn:schemas-upnp-org:control-1-0">
     <errorCode>714</errorCode>
     <errorDescription>Illegal MIME-type</errorDescription>
    </UPnPError>
   </detail>
  </s:Fault>
 </s:Body>
</s:Envelope>
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/websocket_api/commands.py", line 148, in handle_call_service
    connection.context(msg))
  File "/usr/local/lib/python3.7/site-packages/homeassistant/core.py", line 1133, in async_call
    self._execute_service(handler, service_call))
  File "/usr/local/lib/python3.7/site-packages/homeassistant/core.py", line 1155, in _execute_service
    await handler.func(service_call)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity_component.py", line 188, in handle_service
    self._platforms.values(), func, call, service_name
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/service.py", line 278, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/service.py", line 294, in _handle_service_platform_call
    await func(entity, data)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/media_player/dlna_dmr.py", line 315, in async_play_media
    media_id, title, mime_type, upnp_class)
  File "/usr/local/lib/python3.7/site-packages/async_upnp_client/profiles/dlna.py", line 627, in async_set_transport_uri
    CurrentURIMetaData=meta_data)
  File "/usr/local/lib/python3.7/site-packages/async_upnp_client/client.py", line 511, in async_call
    (status_code, response_body))
async_upnp_client.client.UpnpError: Error during async_call(), status: 500, body: <?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
 <s:Body>
  <s:Fault>
   <faultcode>s:Client</faultcode>
   <faultstring>UPnPError</faultstring>
   <detail>
    <UPnPError xmlns="urn:schemas-upnp-org:control-1-0">
     <errorCode>714</errorCode>
     <errorDescription>Illegal MIME-type</errorDescription>
    </UPnPError>
   </detail>
  </s:Fault>
 </s:Body>
</s:Envelope>
StevenLooman commented 5 years ago

Thank you for testing. So now it sends http-get:*:video/x-msvideo:*, but this is not accepted as well. The mime type is provided by the source. Flags are overridden due to * being accepted by the renderer.

Earlier you stated that video/x-msvideo:DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=01700000000000000000000000000000 did not work. Can you try a test a bit more and see which combination does work for this mime type?

Tony763 commented 5 years ago

Tried again: Not works in HA:

async_upnp_client: OMITTING BODY
2019-03-10 22:51:02 DEBUG (MainThread) [async_upnp_client.client.traffic] Sending request:
POST http://10.0.1.108:55000/dmr/control_2
SOAPAction: "urn:schemas-upnp-org:service:AVTransport:1#SetAVTransportURI"
Host: 10.0.1.108:55000
Content-Type: text/xml; charset="utf-8"
Content-Length: 930
<?xml version="1.0"?><s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body><u:SetAVTransportURI xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"><InstanceID>0</InstanceID>
<CurrentURI>http://10.0.1.1:8200/MediaItems/37.avi</CurrentURI>
<CurrentURIMetaData>&lt;DIDL-Lite xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:ns1="urn:schemas-upnp-org:metadata-1-0/upnp/"
 xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"&gt;&lt;item id="0" parentID="0" restricted="1"&gt;&lt;dc:title&gt;Home Assistant&lt;
 /dc:title&gt;&lt;ns1:class&gt;object.item.videoItem&lt;/ns1:class&gt;&lt;
 res protocolInfo="http-get:*:video/x-msvideo:DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=01700000000000000000000000000000"&gt;
 http://10.0.1.1:8200/MediaItems/37.avi&lt;/res&gt;&lt;/item&gt;&lt;/DIDL-Lite&gt;</CurrentURIMetaData></u:SetAVTransportURI></s:Body></s:Envelope>

Works in node with *:

<DIDL-Lite xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sec="http://www.sec.co.kr/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/">
<item id="0" parentID="-1" restricted="false"><upnp:class>object.item.videoItem.movie</upnp:class>
<dc:title>Some Movie Title</dc:title><dc:creator>John Doe</dc:creator>
<res protocolInfo="http-get:*:video/x-msvideo:DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=01700000000000000000000000000000">http://10.0.1.1:8200/MediaItems/239.avi</res>
<sec:CaptionInfo sec:type="srt">http://url.to.some/subtitles.srt</sec:CaptionInfo><sec:CaptionInfoEx sec:type="srt">http://url.to.some/subtitles.srt</sec:CaptionInfoEx>
<res protocolInfo="http-get:*:text/srt:*">http://url.to.some/subtitles.srt</res></item></DIDL-Lite>',
  CurrentTrackURI: 'http://10.0.1.1:8200/MediaItems/239.avi',
  AVTransportURI: 'http://10.0.1.1:8200/MediaItems/239.avi',
  AVTransportURIMetaData: '<DIDL-Lite xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sec="http://www.sec.co.kr/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/">
  <item id="0" parentID="-1" restricted="false">
  <upnp:class>object.item.videoItem.movie</upnp:class>
  <dc:title>Some Movie Title</dc:title><dc:creator>John Doe</dc:creator>
  <res protocolInfo="http-get:*:video/x-msvideo:DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=01700000000000000000000000000000">http://10.0.1.1:8200/MediaItems/239.avi</res>
  <sec:CaptionInfo sec:type="srt">http://url.to.some/subtitles.srt</sec:CaptionInfo><sec:CaptionInfoEx sec:type="srt">http://url.to.some/subtitles.srt</sec:CaptionInfoEx>
  <res protocolInfo="http-get:*:text/srt:*">http://url.to.some/subtitles.srt</res></item></DIDL-Lite>',
  NextAVTransportURI: '',

Works in node with *:

<DIDL-Lite xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sec="http://www.sec.co.kr/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/">
<item id="0" parentID="-1" restricted="false">
<upnp:class>object.item.videoItem.movie</upnp:class>
<dc:title>Some Movie Title</dc:title><dc:creator>John Doe</dc:creator>
<res protocolInfo="http-get:*:video/x-msvideo:*">http://10.0.1.1:8200/MediaItems/239.avi</res>
<sec:CaptionInfo sec:type="srt">http://url.to.some/subtitles.srt</sec:CaptionInfo><sec:CaptionInfoEx sec:type="srt">http://url.to.some/subtitles.srt</sec:CaptionInfoEx>
<res protocolInfo="http-get:*:text/srt:*">http://url.to.some/subtitles.srt</res></item></DIDL-Lite>',
  CurrentTrackURI: 'http://10.0.1.1:8200/MediaItems/239.avi',
  AVTransportURI: 'http://10.0.1.1:8200/MediaItems/239.avi',
  AVTransportURIMetaData: '<DIDL-Lite xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sec="http://www.sec.co.kr/"
  xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/"><item id="0" parentID="-1" restricted="false"><upnp:class>object.item.videoItem.movie</upnp:class><dc:title>Some Movie Title</dc:title>
  <dc:creator>John Doe</dc:creator><res protocolInfo="http-get:*:video/x-msvideo:*">http://10.0.1.1:8200/MediaItems/239.avi</res>
  <sec:CaptionInfo sec:type="srt">http://url.to.some/subtitles.srt</sec:CaptionInfo><sec:CaptionInfoEx sec:type="srt">http://url.to.some/subtitles.srt</sec:CaptionInfoEx>
  <res protocolInfo="http-get:*:text/srt:*">http://url.to.some/subtitles.srt</res></item></DIDL-Lite>

Differences at first sight ( HA vs Node ): Using &gt; &lt; and < > <ns1:class>object.item.videoItem vs <upnp:class>object.item.videoItem.movie <item id="0" parentID="0" restricted="1" vs <item id="0" parentID="-1" restricted="false">

<DIDL-Lite xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:ns1="urn:schemas-upnp-org:metadata-1-0/upnp/" xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"> Vs <DIDL-Lite xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sec="http://www.sec.co.kr/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/">

StevenLooman commented 5 years ago

The differences I see are and which I think are possible causes for not working:

* I doubt these are causing problems.

I've made changes for the first two items. Can you test this changed async_upnp_client/profiles/dlna.py file?

Tony763 commented 5 years ago

I just reworked my installation. Thanks to ipv6 and docker. Now I run HA 0.89.2 on x86_64 with virtualenv and python 3.6.7. No hassio no docker.

Tried it. Values changed but TV still sends a Illegal MIME type.

<CurrentURIMetaData>&lt;DIDL-Lite xmlns:dc="http://purl.org/dc/elements/1.1/" 
xmlns:ns1="urn:schemas-upnp-org:metadata-1-0/upnp/"
 xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"&gt;&lt;
item id="0" parentID="-1" restricted="false"&gt;&lt;dc:title&gt;
Home Assistant&lt;/dc:title&gt;&lt;ns1:class&gt;object.item.videoItem
&lt;/ns1:class&gt;&lt;res protocolInfo="http-get:*:video/x-msvideo:
DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=01700000000000000000000000000000"
&gt;http://10.0.1.1:8200/MediaItems/239.avi&lt;/res&gt;&lt;/item&gt;&lt;/DIDL-Lite&gt;
</CurrentURIMetaData></u:SetAVTransportURI></s:Body></s:Envelope>

2019-03-13 22:42:24 DEBUG (MainThread) [async_upnp_client.client.traffic] Got response:
500
Content-Length: 490
Content-Type: text/xml; charset="utf-8"
EXT: 
Server: Panasonic-VIErA/1, UPnP/1.0, Panasonic MIL DLNA SERVER
Connection: close

<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
 <s:Body>
  <s:Fault>
   <faultcode>s:Client</faultcode>
   <faultstring>UPnPError</faultstring>
   <detail>
    <UPnPError xmlns="urn:schemas-upnp-org:control-1-0">
     <errorCode>714</errorCode>
     <errorDescription>Illegal MIME-type</errorDescription>
    </UPnPError>
   </detail>
  </s:Fault>
 </s:Body>
</s:Envelope>

2019-03-13 22:42:24 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.140408861922416] Error during async_call(), status: 500, body: <?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
 <s:Body>
  <s:Fault>
   <faultcode>s:Client</faultcode>
   <faultstring>UPnPError</faultstring>
   <detail>
    <UPnPError xmlns="urn:schemas-upnp-org:control-1-0">
     <errorCode>714</errorCode>
     <errorDescription>Illegal MIME-type</errorDescription>
    </UPnPError>
   </detail>
  </s:Fault>
 </s:Body>
</s:Envelope>
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/websocket_api/commands.py", line 148, in handle_call_service
    connection.context(msg))
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/core.py", line 1133, in async_call
    self._execute_service(handler, service_call))
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/core.py", line 1155, in _execute_service
    await handler.func(service_call)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity_component.py", line 188, in handle_service
    self._platforms.values(), func, call, service_name
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/service.py", line 278, in entity_service_call
    future.result()  # pop exception if have
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/service.py", line 294, in _handle_service_platform_call
    await func(entity, data)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/media_player/dlna_dmr.py", line 315, in async_play_media
    media_id, title, mime_type, upnp_class)
  File "/srv/homeassistant/lib/python3.6/site-packages/async_upnp_client/profiles/dlna.py", line 627, in async_set_transport_uri
    CurrentURIMetaData=meta_data)
  File "/srv/homeassistant/lib/python3.6/site-packages/async_upnp_client/client.py", line 511, in async_call
    (status_code, response_body))
async_upnp_client.client.UpnpError: Error during async_call(), status: 500, body: <?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
 <s:Body>
  <s:Fault>
   <faultcode>s:Client</faultcode>
   <faultstring>UPnPError</faultstring>
   <detail>
    <UPnPError xmlns="urn:schemas-upnp-org:control-1-0">
     <errorCode>714</errorCode>
     <errorDescription>Illegal MIME-type</errorDescription>
    </UPnPError>
   </detail>
  </s:Fault>
 </s:Body>
</s:Envelope>
StevenLooman commented 5 years ago

Ok, there are still a few things we can try:

  1. urn:schemas-upnp-org:metadata-1-0/upnp/-namespace called ns1 vs upnp
  2. missing sec-namespace
  3. class object.item.videoItem vs object.item.videoItem.movie
  4. dc:creator missing vs given, but this is optional according to the standard

For 1 and 2, can you find the file python-didl-lite/didl_lite/didl_lite.py and replace it with this newer version?

For 3, can you find the file homeassistant/components/media_player/dlna_dmr.py, and edit the variable HOME_ASSISTANT_UPNP_CLASS_MAPPING, such that it becomes this:

HOME_ASSISTANT_UPNP_CLASS_MAPPING = {
    'music': 'object.item.audioItem',
    'tvshow': 'object.item.videoItem.movie',
    'video': 'object.item.videoItem.movie',
    'episode': 'object.item.videoItem.movie',
    'channel': 'object.item.videoItem.movie',
    'playlist': 'object.item.playlist',
}

Note that .movie is appended for several items.

For 4, can you find the file async_upnp_client/async_upnp_client/profiles/dlna.py, find the method DmrDevice._construct_play_media_metadata(), find this part:

        protocol_info = "http-get:*:{mime_type}:{dlna_features}".format(**media_info)
        resource = didl_lite.Resource(uri=media_url, protocol_info=protocol_info)
        item = didl_item_type(id="0", parent_id="-1", title=media_title,
                              restricted="false", resources=[resource])

And replace it with:

        protocol_info = "http-get:*:{mime_type}:{dlna_features}".format(**media_info)
        resource = didl_lite.Resource(uri=media_url, protocol_info=protocol_info)
        item = didl_item_type(id="0", parent_id="-1", title=media_title, creator='Test',
                              restricted="false", resources=[resource])

Note that creator='Test' has been added.

Please try every these changes individually and see which one helps. This allows us to pinpoint the problem, hopefully.

Tony763 commented 5 years ago

Case 2: Defined to use but not specified?

'sec'
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/websocket_api/commands.py", line 148, in handle_call_service
    connection.context(msg))
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/core.py", line 1133, in async_call
    self._execute_service(handler, service_call))
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/core.py", line 1155, in _execute_service
    await handler.func(service_call)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity_component.py", line 188, in handle_service
    self._platforms.values(), func, call, service_name
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/service.py", line 278, in entity_service_call
    future.result()  # pop exception if have
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/service.py", line 294, in _handle_service_platform_call
    await func(entity, data)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/media_player/dlna_dmr.py", line 315, in async_play_media
    media_id, title, mime_type, upnp_class)
  File "/srv/homeassistant/lib/python3.6/site-packages/async_upnp_client/profiles/dlna.py", line 621, in async_set_transport_uri
    override_dlna_features=override_dlna_features)
  File "/srv/homeassistant/lib/python3.6/site-packages/async_upnp_client/profiles/dlna.py", line 727, in _construct_play_media_metadata
    xml_string = didl_lite.to_xml_string(item)  # type: bytes
  File "/srv/homeassistant/lib/python3.6/site-packages/didl_lite/didl_lite.py", line 899, in to_xml_string
    root_el.attrib['xmlns:sec'] = NAMESPACES['sec']
KeyError: 'sec'

Sec occur only two times in didl_lite.py => 899: root_el.attrib['xmlns:sec'] = NAMESPACES['sec']

Case 1: Removed root_el.attrib['xmlns:sec'] = NAMESPACES['sec'] = > Illegal MIME-type

Case 3: = > Illegal MIME-type

:title&gt;Home Assistant&lt;/dc:title&gt;&lt;ns1:class&gt;object.item.videoItem.movie&lt;/ns1:class&gt;&lt;res protocolInfo="http-get:*:video/x-msvid

Case 4: = > Illegal MIME-type

gt;object.item.videoItem.movie&lt;/ns1:class&gt;&lt;dc:creator&gt;Test&lt;/dc:creator&gt;&lt;res protocolInfo="http
StevenLooman commented 5 years ago

My bad. For case 1 you also need to replace python-didl-lite/didl_lite/utils.py.

StevenLooman commented 5 years ago

In this comment you said:

Using &gt; &lt; and < >

What did you mean by this? Is it that Home Assistant is sending &gt; while node-upnp-mediarenderer-client is sending < etc?

Tony763 commented 5 years ago

Updated: Now sec is presented but = > Illegal MIME-type

<?xml version="1.0"?><s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body><u:SetAVTransportURI xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"><InstanceID>0</InstanceID>
<CurrentURI>http://10.0.1.1:8200/MediaItems/239.avi</CurrentURI>
<CurrentURIMetaData>&lt;DIDL-Lite xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:ns1="urn:schemas-upnp-org:metadata-1-0/upnp/"
 xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"
 xmlns:sec="http://www.sec.co.kr/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/"&gt;&lt;item id="0"
 parentID="-1" restricted="false"&gt;&lt;dc:title&gt;Home Assistant&lt;/dc:title&gt;&lt;ns1:class&gt;object.item.videoItem.movie&lt;
 /ns1:class&gt;&lt;dc:creator&gt;Test&lt;/dc:creator&gt;&lt;res 
 protocolInfo="http-get:*:video/x-msvideo:DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=01700000000000000000000000000000"&gt;
 http://10.0.1.1:8200/MediaItems/239.avi&lt;/res&gt;&lt;/item&gt;&lt;/DIDL-Lite&gt;</CurrentURIMetaData></u:SetAVTransportURI></s:Body></s:Envelope>
Tony763 commented 5 years ago

In this comment you said:

Using &gt; &lt; and < >

What did you mean by this? Is it that Home Assistant is sending &gt; while node-upnp-mediarenderer-client is sending < etc?

Yes. I know it is the same meaning, but still it is different in HA and Node.

You can see it in this comment . First code is from HA, other two are from Node.

StevenLooman commented 5 years ago

I went in and checked what node-upnp-mediarenderer-client actually sends:

<?xml version='1.0' encoding='utf-8'?>
<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><u:SetAVTransportURI xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"><InstanceID>0</InstanceID><CurrentURI>http://192.168.178.73:8200/MediaItems/25.mp4</CurrentURI><CurrentURIMetaData>&lt;DIDL-Lite xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sec="http://www.sec.co.kr/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/"&gt;&lt;item id="0" parentID="-1" restricted="false"&gt;&lt;upnp:class&gt;object.item.videoItem.movie&lt;/upnp:class&gt;&lt;dc:title&gt;Some Movie Title&lt;/dc:title&gt;&lt;dc:creator&gt;John Doe&lt;/dc:creator&gt;&lt;res protocolInfo="http-get:*:video/avi:*"&gt;http://192.168.178.73:8200/MediaItems/25.mp4&lt;/res&gt;&lt;/item&gt;&lt;/DIDL-Lite&gt;</CurrentURIMetaData></u:SetAVTransportURI></s:Body></s:Envelope>

It tries to help you by not escaping the XML thus making it more readable.

I see that the namespace urn:schemas-upnp-org:metadata-1-0/upnp/ has the aliases ns1 and upnp. This is not what was meant; I'll fix it, but I doubt this causes problem in this case.

With regard to the protocolInfo, can you test one more thing. Please edit the file homeassistant/components/media_player/dlna_dmr.py, find the method DlnaDmrDevice.async_play_media(), and change this part:

        # Queue media
        await self._device.async_set_transport_uri(
            media_id, title, mime_type, upnp_class)
        await self._device.async_wait_for_can_play()

To:

        # Queue media
        await self._device.async_set_transport_uri(
            media_id, title, mime_type, upnp_class, override_mime_type='video/avi')
        await self._device.async_wait_for_can_play()

The part override_mime_type='video/avi' has been added. If this works then I'll change the component to allow you to override this via the media_type-parameter in Home Assistant itself.

StevenLooman commented 5 years ago

Here is a new version of python-didl-lite/didl_lite/didl_lite.py, please replace the old file with this one as well.

Tony763 commented 5 years ago

Hooray, it's playing!

I skipped a override_mime_type and used a new didl_lite.py instead and it woks. So it was problem with namespace or did You changed something else?

Date: Tue, 19 Mar 2019 21:19:11 GMT
Server: Ubuntu DLNADOC/1.50 UPnP/1.0 MiniDLNA/1.2.1
EXT: 
realTimeInfo.dlna.org: DLNA.ORG_TLAG=*
transferMode.dlna.org: Streaming
Content-Type: video/x-msvideo
Content-Length: 730613760
Accept-Ranges: bytes
contentFeatures.dlna.org: DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=01700000000000000000000000000000

async_upnp_client: OMITTING BODY
2019-03-19 22:19:11 DEBUG (MainThread) [async_upnp_client.client.traffic] Sending request:
POST http://10.0.1.108:55000/dmr/control_2
SOAPAction: "urn:schemas-upnp-org:service:AVTransport:1#SetAVTransportURI"
Host: 10.0.1.108:55000
Content-Type: text/xml; charset="utf-8"
Content-Length: 1021
<?xml version="1.0"?><s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><u:SetAVTransportURI xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"><InstanceID>0</InstanceID>
<CurrentURI>http://10.0.1.1:8200/MediaItems/239.avi</CurrentURI>
<CurrentURIMetaData>&lt;DIDL-Lite xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sec="http://www.sec.co.kr/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/"&gt;&lt;item id="0" parentID="-1" restricted="false"&gt;&lt;dc:title&gt;Home Assistant&lt;/dc:title&gt;&lt;upnp:class&gt;object.item.videoItem.movie&lt;/upnp:class&gt;&lt;dc:creator&gt;Test&lt;/dc:creator&gt;&lt;res protocolInfo="http-get:*:video/x-msvideo:DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=01700000000000000000000000000000"&gt;http://10.0.1.1:8200/MediaItems/239.avi&lt;/res&gt;&lt;/item&gt;&lt;/DIDL-Lite&gt;</CurrentURIMetaData></u:SetAVTransportURI></s:Body></s:Envelope>

2019-03-19 22:19:11 DEBUG (MainThread) [async_upnp_client.client.traffic] Got response:
200
Content-Length: 314
Content-Type: text/xml; charset="utf-8"
EXT: 
Server: Panasonic-VIErA/1, UPnP/1.0, Panasonic MIL DLNA SERVER
Connection: close

<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
 <s:Body>
  <u:SetAVTransportURIResponse xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"></u:SetAVTransportURIResponse>
 </s:Body>
</s:Envelope>

2019-03-19 22:19:11 DEBUG (MainThread) [async_upnp_client.aiohttp] Received request: <BaseRequest NOTIFY /notify >
2019-03-19 22:19:13 DEBUG (MainThread) [async_upnp_client.traffic] Incoming request:
NOTIFY
Host: xx.xxx.xx.xx:8301
Content-Type: text/xml; charset="utf-8"
NT: upnp:event
NTS: upnp:propchange
SID: uuid:4D454931-0102-1005-8001-4A0117D6D5B8
SEQ: 1
Content-Length: 2571
Expect: 100-continue

<?xml version="1.0" encoding="utf-8"?>
<e:propertyset xmlns:e="urn:schemas-upnp-org:event-1-0">
 <e:property>
  <LastChange>&lt;Event xmlns=&quot;urn:schemas-upnp-org:metadata-1-0/AVT/&quot;&gt;
  &lt;InstanceID val=&quot;0&quot;&gt;
    &lt;TransportState val=&quot;STOPPED&quot;/&gt;
    &lt;AVTransportURI val=&quot;http://10.0.1.1:8200/MediaItems/239.avi&quot;/&gt;
    &lt;CurrentTrackURI val=&quot;http://10.0.1.1:8200/MediaItems/239.avi&quot;/&gt;
    &lt;CurrentTrackMetaData val=&quot;&amp;lt;DIDL-Lite xmlns=&amp;quot;urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/&amp;quot; xmlns:dc=&amp;quot;http://purl.org/dc/elements/1.1/&amp;quot; xmlns:sec=&amp;quot;http://www.sec.co.kr/&amp;quot; xmlns:upnp=&amp;quot;urn:schemas-upnp-org:metadata-1-0/upnp/&amp;quot;&amp;gt;&amp;lt;item id=&amp;quot;0&amp;quot; parentID=&amp;quot;-1&amp;quot; restricted=&amp;quot;false&amp;quot;&amp;gt;&amp;lt;dc:title&amp;gt;Home Assistant&amp;lt;/dc:title&amp;gt;&amp;lt;upnp:class&amp;gt;object.item.videoItem.movie&amp;lt;/upnp:class&amp;gt;&amp;lt;dc:creator&amp;gt;Test&amp;lt;/dc:creator&amp;gt;&amp;lt;res protocolInfo=&amp;quot;http-get:*:video/x-msvideo:DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=01700000000000000000000000000000&amp;quot;&amp;gt;http://10.0.1.1:8200/MediaItems/239.avi&amp;lt;/res&amp;gt;&amp;lt;/item&amp;gt;&amp;lt;/DIDL-Lite&amp;gt;&quot;/&gt;
    &lt;AVTransportURIMetaData val=&quot;&amp;lt;DIDL-Lite xmlns=&amp;quot;urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/&amp;quot; xmlns:dc=&amp;quot;http://purl.org/dc/elements/1.1/&amp;quot; xmlns:sec=&amp;quot;http://www.sec.co.kr/&amp;quot; xmlns:upnp=&amp;quot;urn:schemas-upnp-org:metadata-1-0/upnp/&amp;quot;&amp;gt;&amp;lt;item id=&amp;quot;0&amp;quot; parentID=&amp;quot;-1&amp;quot; restricted=&amp;quot;false&amp;quot;&amp;gt;&amp;lt;dc:title&amp;gt;Home Assistant&amp;lt;/dc:title&amp;gt;&amp;lt;upnp:class&amp;gt;object.item.videoItem.movie&amp;lt;/upnp:class&amp;gt;&amp;lt;dc:creator&amp;gt;Test&amp;lt;/dc:creator&amp;gt;&amp;lt;res protocolInfo=&amp;quot;http-get:*:video/x-msvideo:DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=01700000000000000000000000000000&amp;quot;&amp;gt;http://10.0.1.1:8200/MediaItems/239.avi&amp;lt;/res&amp;gt;&amp;lt;/item&amp;gt;&amp;lt;/DIDL-Lite&amp;gt;&quot;/&gt;
    &lt;CurrentTransportActions val=&quot;Stop,Play,X_DLNA_PS=-100\,-70\,-30\,-5\,-2\,-1/2\,1/2\,2\,5\,30\,70\,100&quot;/&gt;
    &lt;NumberOfTracks val=&quot;1&quot;/&gt;
    &lt;CurrentTrack val=&quot;1&quot;/&gt;
  &lt;/InstanceID&gt;
&lt;/Event&gt;</LastChange>
 </e:property>
</e:propertyset>

2019-03-19 22:19:13 DEBUG (MainThread) [async_upnp_client.traffic] Sending response: HTTPStatus.OK
2019-03-19 22:19:13 DEBUG (MainThread) [async_upnp_client.aiohttp] NOTIFY response status: HTTPStatus.OK
2019-03-19 22:19:13 DEBUG (MainThread) [async_upnp_client.client.traffic] Sending request:
POST http://10.0.1.108:55000/dmr/control_2
SOAPAction: "urn:schemas-upnp-org:service:AVTransport:1#Play"
Host: 10.0.1.108:55000
Content-Type: text/xml; charset="utf-8"
Content-Length: 288
<?xml version="1.0"?><s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><u:Play xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"><InstanceID>0</InstanceID>
<Speed>1</Speed></u:Play></s:Body></s:Envelope>

2019-03-19 22:19:14 DEBUG (MainThread) [async_upnp_client.client.traffic] Got response:
200
Content-Length: 288
Content-Type: text/xml; charset="utf-8"
EXT: 
Server: Panasonic-VIErA/1, UPnP/1.0, Panasonic MIL DLNA SERVER
Connection: close

<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
 <s:Body>
  <u:PlayResponse xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"></u:PlayResponse>
 </s:Body>
</s:Envelope>

2019-03-19 22:19:14 DEBUG (MainThread) [async_upnp_client.client.traffic] Sending request:
POST http://10.0.1.108:55000/dmr/control_2
SOAPAction: "urn:schemas-upnp-org:service:AVTransport:1#GetTransportInfo"
Host: 10.0.1.108:55000
Content-Type: text/xml; charset="utf-8"
Content-Length: 295
<?xml version="1.0"?><s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><u:GetTransportInfo xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"><InstanceID>0</InstanceID></u:GetTransportInfo></s:Body></s:Envelope>

2019-03-19 22:19:14 DEBUG (MainThread) [async_upnp_client.aiohttp] Received request: <BaseRequest NOTIFY /notify >
2019-03-19 22:19:14 DEBUG (MainThread) [async_upnp_client.traffic] Incoming request:
NOTIFY
Host: xx.xxx.xx.xx:8301
Content-Type: text/xml; charset="utf-8"
NT: upnp:event
NTS: upnp:propchange
SID: uuid:4D454931-0102-1005-8001-4A0117D6D5B8
SEQ: 2
Content-Length: 374

<?xml version="1.0" encoding="utf-8"?>
<e:propertyset xmlns:e="urn:schemas-upnp-org:event-1-0">
 <e:property>
  <LastChange>&lt;Event xmlns=&quot;urn:schemas-upnp-org:metadata-1-0/AVT/&quot;&gt;
  &lt;InstanceID val=&quot;0&quot;&gt;
    &lt;TransportState val=&quot;TRANSITIONING&quot;/&gt;
  &lt;/InstanceID&gt;
&lt;/Event&gt;</LastChange>
 </e:property>
</e:propertyset>

2019-03-19 22:19:14 DEBUG (MainThread) [async_upnp_client.traffic] Sending response: HTTPStatus.OK
2019-03-19 22:19:14 DEBUG (MainThread) [async_upnp_client.aiohttp] NOTIFY response status: HTTPStatus.OK
2019-03-19 22:19:14 DEBUG (MainThread) [async_upnp_client.client.traffic] Got response:
200
Content-Length: 468
Content-Type: text/xml; charset="utf-8"
EXT: 
Server: Panasonic-VIErA/1, UPnP/1.0, Panasonic MIL DLNA SERVER
Connection: close

<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
 <s:Body>
  <u:GetTransportInfoResponse xmlns:u="urn:schemas-upnp-org:service:AVTransport:1">
   <CurrentTransportState>TRANSITIONING</CurrentTransportState>
   <CurrentTransportStatus>OK</CurrentTransportStatus>
   <CurrentSpeed>1</CurrentSpeed>
  </u:GetTransportInfoResponse>
 </s:Body>
</s:Envelope>

2019-03-19 22:19:15 ERROR (MainThread) [homeassistant.components.automation] Error while executing automation automation.tv_light. Invalid data for call_service at pos 1: Service  does not match format <domain>.<name>
2019-03-19 22:19:15 DEBUG (MainThread) [async_upnp_client.aiohttp] Received request: <BaseRequest NOTIFY /notify >
2019-03-19 22:19:15 DEBUG (MainThread) [async_upnp_client.traffic] Incoming request:
NOTIFY
Host: xx.xxx.xx.xx:8301
Content-Type: text/xml; charset="utf-8"
NT: upnp:event
NTS: upnp:propchange
SID: uuid:4D454931-0102-1005-8001-4A0117D6D5B8
SEQ: 3
Content-Length: 637

<?xml version="1.0" encoding="utf-8"?>
<e:propertyset xmlns:e="urn:schemas-upnp-org:event-1-0">
 <e:property>
  <LastChange>&lt;Event xmlns=&quot;urn:schemas-upnp-org:metadata-1-0/AVT/&quot;&gt;
  &lt;InstanceID val=&quot;0&quot;&gt;
    &lt;TransportState val=&quot;PLAYING&quot;/&gt;
    &lt;CurrentTransportActions val=&quot;Stop,Play,Seek,X_DLNA_SeekTime,Pause,X_DLNA_PS=-100\,-70\,-30\,-5\,-2\,-1/2\,1/2\,2\,5\,30\,70\,100&quot;/&gt;
    &lt;CurrentTrackDuration val=&quot;1:30:34&quot;/&gt;
    &lt;CurrentMediaDuration val=&quot;1:30:34&quot;/&gt;
  &lt;/InstanceID&gt;
&lt;/Event&gt;</LastChange>
 </e:property>
</e:propertyset>
Tony763 commented 5 years ago

Tested few videos with video/x-matroska and video/x-msvideo and all works good.

StevenLooman commented 5 years ago

Finally! A possibility is that the urn:schemas-upnp-org:metadata-1-0/upnp/ namespace must explicitly be aliased to upnp, but I cannot find any statement claiming this. I think your device searches explicitly for 'upnp:res' and doesn't properly parse the XML with its namespaces.

Anyway, I have released a new version of python-didl-lite, and async_upnp_client and created a pull request for home assistant to use the new version of async_upnp_client.

Thank you for your time to test different things!

StevenLooman commented 5 years ago

This issue can be closed when the pull request has been accepted.

@Tony763 If you want and have the time, please remove any changes you have made to your local files and test version of the pull request.

Tony763 commented 5 years ago

I opened Your commit. there are 3 files changed (media_player.py, init.py, requirements_all.txt) but changed lines are only about version from 0.14.5 to 0.14.6. Am I doing something wrong?

StevenLooman commented 5 years ago

No this is right. Those lines tell home assistant to install async_upnp_client version 0.14.6, which installs python-didl-lite version 1.2.4. Version 1.2.4 of python-didl-lite contains the fix which you last tested: this commit for python-didl-lite

Please do note that async_upnp_client==0.14.6 contains more fixes. See the changes for that version

Tony763 commented 5 years ago

@StevenLooman Just installed and it is working. Thank You for Your patience with me and good work!

StevenLooman commented 5 years ago

Nice, thank you for testing.