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.03k stars 29.69k forks source link

Home Assistant DLNA DMR XML Parsing Issue #122281

Closed jhujube closed 1 month ago

jhujube commented 1 month ago

The problem

Hello,

I am experiencing an issue with Home Assistant when trying to connect a Digital Media Renderer (DMR) via DLNA on my network. Home Assistant fails to correctly recognize the DMR (a Philips NP3700) as it appears as "Unavailable" and I am unable to control it. When I look at the DLNA logs while trying to integrate the DMR, I see these warnings:

2024-07-20 13:47:43.647 WARNING (MainThread) [homeassistant.components.dlna_dmr] Failed connecting to recently alive device at http://192.168.0.2:7123/DeviceDescription.xml: UpnpXmlContentError('Could not find device element', None) 2024-07-20 13:47:43.663 DEBUG (MainThread) [homeassistant.components.dlna_dmr] Couldn't connect immediately: UpnpXmlContentError('Could not find device element', None) 2024-07-20 13:47:45.792 DEBUG (MainThread) [async_upnp_client.traffic.upnp] fe80::253a:8b4:fcd5:6e0e [20/Jul/2024:12:47:45 +0100] "GET /device.xml HTTP/1.1" 200 1591 "-" "DAFUPnP"

To diagnose the problem, I created a modified DeviceDescription.xml file and hosted it on a local web server. I changed the first line from:

\

to:

\

When I point Home Assistant to this modified XML file, the error no longer appears but the installation immediately stops because this is not a real DMR. I have attached the original complete XML file from the Philips DMR.

Do you have any suggestions to resolve this issue? Is this a known problem, or are there any additional steps I should take to solve it? Is it a problem of my dnr? if yes i have no way to correct it on the dmr side as it is directly coded in its firmware.

Thank you very much for your help!

Best regards, Jhujube

What version of Home Assistant Core has the issue?

core-2024.7.2

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

dlna

Link to integration documentation on our website

No response

Diagnostics information

\ \ \1 \0 \ \ \DMP-1.00</dlna:X_DLNADOC> \urn:schemas-upnp-org:device:MediaRenderer:1 \PhilipsNP3700 \Royal Philips Electronics \http://www.philips.com \Philips Streamium HiFi Player \NP \3700 \ \00903efc206b \uuid:00000081-0000-5000-0000-00903efc206b \NP \ \ \image/jpeg \48 \48 \24 \FS/res/device_discovery.jpg \ \ \ \ \urn:schemas-upnp-org:service:RenderingControl:1 \urn:upnp-org:serviceId:RenderingControl \/RenderCtl.xml \/UD/action?0 \/sub?0 \ \ \urn:schemas-upnp-org:service:ConnectionManager:1 \urn:upnp-org:serviceId:ConnectionManager \/MrConnMgr.xml \/UD/action?1 \/sub?1 \ \ \urn:schemas-upnp-org:service:AVTransport:1 \urn:upnp-org:serviceId:AVTransport \/MrAvTransport.xml \/UD/action?2 \/sub?2 \ \ \http://192.168.0.2:8889/index.htm \ \#Mobile</pns:X_screen> \#PhotoFrame</pns:X_screen> \#TV</pns:X_screen> \</pns:X_presentationProperties> \ \

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 1 month ago

Hey there @chishm, mind taking a look at this issue as it has been labeled with an integration (dlna_dmr) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `dlna_dmr` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign dlna_dmr` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


dlna_dmr documentation dlna_dmr source (message by IssueLinks)

elupus commented 1 month ago

This is a bug in the dmr. It should set a default namespace for the xml keys.

It should be reported to the firmware developers. It will break many other tools as well.

I doubt we want to work around this.

jhujube commented 1 month ago

Well, thanks for your reply. If the problem is just with my dmr, I understand perfectly that you can't fix my specific problem. As far as Philips is concerned, they haven't been updating this device for a long time. So it's pointless asking them to fix this bug! On the other hand, I think I've managed to find a solution: I've cloned DNLA_DMR in customs_components, as well as the async_upnp_client library and I've modified the aiohttp.py file so that it modifies the xml received specifically from this dmr on the fly in order to correct the bug. Apparently, the Philips NP3700 DMR is now recognised and working. Have a nice day! Jhujube