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
74.1k stars 31.1k forks source link

Issues adding Bose Sountouch 10 and 20 #131537

Open override80 opened 6 days ago

override80 commented 6 days ago

The problem

When I try to add my Bose Soundtouch spakers via DLNA as a Digital Media Renderer, speakers stay unavailable and I cannot use them. They used to work until a few weeks ago. Attached the debug log.

What version of Home Assistant Core has the issue?

core-2024.11.3

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Supervised

Integration causing the issue

DLNA Digital Media Renderer

Link to integration documentation on our website

https://www.home-assistant.io/integrations/dlna_dmr

Diagnostics information

home-assistant_dlna_dmr_2024-11-25T12-03-05.708Z.log

Example YAML snippet

No response

Anything in the logs that might be useful for us?

<?xml version="1.0"?><e:propertyset xmlns:e="urn:schemas-upnp-org:event-1-0"><e:property><LastChange>&lt;/InstanceID&gt;&lt;/Event&gt;</LastChange></e:property></e:propertyset>
2024-11-25 13:03:01.942 DEBUG (MainThread) [async_upnp_client.profiles.dlna] Fatal error during parsing: <unknown>:1:1: not well-formed (invalid token)
2024-11-25 13:03:01.942 DEBUG (MainThread) [async_upnp_client.profiles.dlna] Fatal error during parsing: <unknown>:1:2: not well-formed (invalid token)

Additional information

No response

home-assistant[bot] commented 6 days 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)

chishm commented 5 days ago

I'm looking at that log snippet, in particular the XML in the NOTIFY:

<?xml version="1.0"?><e:propertyset xmlns:e="urn:schemas-upnp-org:event-1-0"><e:property><LastChange>&lt;/InstanceID&gt;&lt;/Event&gt;</LastChange></e:property></e:propertyset>

After one layer of XML decoding, the contents of the LastChange tag should be valid XML, but instead it's got:

</InstanceID></Event>

Is your speaker OK?

override80 commented 5 days ago

Hi @chishm , it is - I have 4 of them (3 Soundtouch 10 and 1 Soundtouch 20), they all work. I do already use them via SoundTouchPlus integration in home assistant. Sometimes they work as expected as DLNA rendered, sometimes thay just stick to "unknown".

image

here is the state of the corresponding entities provided by SoundTouchPlus vs DLNA:

Screenshot from 2024-11-26 16-37-22 Screenshot from 2024-11-26 16-38-23 Screenshot from 2024-11-26 16-38-37 Screenshot from 2024-11-26 16-39-10

Can I help somehow with some tests?

The real issue is that I used DLNA renderers in Music Assistant as Player Providers. Because if I add home assistant media players directly in Music assistant I need to make sure that the source on the player is properly set to "notification" source, otherwise they won't work... This I could avoid by using DLNA.

override80 commented 4 days ago

Hi @chishm , do you believe that these might be related? https://github.com/home-assistant/core/issues/57061 https://github.com/home-assistant/core/issues/85711?

Something might have changed in 2024.7 (https://community.home-assistant.io/t/2024-7-time-to-resize-your-cards/745771/111).

Maybe this is more related to @StevenLooman UPNP integration? Sorry to ping you here Steven, I am a total noob on DLNA and UPnP. I will reopen the task tagging the proper integration if this is the case.

I tried to figure out how to monkey patch client.py in the async_upnp library, but unsuccessfully

override80 commented 3 days ago

Setting this:

image

will make the speaker work. Still a lot of errors in the log though, again xml parsing errors:

2024-11-28 11:35:36.720 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/xml/etree/ElementTree.py", line 1706, in feed
    self.parser.Parse(data, False)
xml.parsers.expat.ExpatError: not well-formed (invalid token): line 1, column 0

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 1046, in _async_update_entity_states
    await entity.async_update_ha_state(True)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 962, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1132, in _async_write_ha_state
    self.__async_calculate_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1091, in __async_calculate_state
    if (entity_picture := self.entity_picture) is not None:
                          ^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 1081, in entity_picture
    return self.media_image_local
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 1086, in media_image_local
    if (image_hash := self.media_image_hash) is None:
                      ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 652, in media_image_hash
    if (url := self.media_image_url) is not None:
               ^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/dlna_dmr/media_player.py", line 894, in media_image_url
    return self._device.media_image_url
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/async_upnp_client/profiles/dlna.py", line 1198, in media_image_url
    items = _cached_from_xml_string(xml)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/async_upnp_client/profiles/dlna.py", line 239, in _cached_from_xml_string
    return didl_lite.from_xml_string(xml, strict=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/didl_lite/didl_lite.py", line 1077, in from_xml_string
    xml_el = defusedxml.ElementTree.fromstring(xml_string)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/defusedxml/common.py", line 126, in fromstring
    parser.feed(text)
  File "/usr/local/lib/python3.12/xml/etree/ElementTree.py", line 1708, in feed
    self._raiseerror(v)
  File "/usr/local/lib/python3.12/xml/etree/ElementTree.py", line 1615, in _raiseerror
    raise err
xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 1, column 0
2024-11-28 11:35:37.168 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/xml/etree/ElementTree.py", line 1706, in feed
    self.parser.Parse(data, False)
xml.parsers.expat.ExpatError: not well-formed (invalid token): line 1, column 0

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 1046, in _async_update_entity_states
    await entity.async_update_ha_state(True)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 962, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1132, in _async_write_ha_state
    self.__async_calculate_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1091, in __async_calculate_state
    if (entity_picture := self.entity_picture) is not None:
                          ^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 1081, in entity_picture
    return self.media_image_local
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 1086, in media_image_local
    if (image_hash := self.media_image_hash) is None:
                      ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 652, in media_image_hash
    if (url := self.media_image_url) is not None:
               ^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/dlna_dmr/media_player.py", line 894, in media_image_url
    return self._device.media_image_url
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/async_upnp_client/profiles/dlna.py", line 1198, in media_image_url
    items = _cached_from_xml_string(xml)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/async_upnp_client/profiles/dlna.py", line 239, in _cached_from_xml_string
    return didl_lite.from_xml_string(xml, strict=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/didl_lite/didl_lite.py", line 1077, in from_xml_string
    xml_el = defusedxml.ElementTree.fromstring(xml_string)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/defusedxml/common.py", line 126, in fromstring
    parser.feed(text)
  File "/usr/local/lib/python3.12/xml/etree/ElementTree.py", line 1708, in feed
    self._raiseerror(v)
  File "/usr/local/lib/python3.12/xml/etree/ElementTree.py", line 1615, in _raiseerror
    raise err
xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 1, column 0
2024-11-28 11:35:46.719 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/xml/etree/ElementTree.py", line 1706, in feed
    self.parser.Parse(data, False)
xml.parsers.expat.ExpatError: not well-formed (invalid token): line 1, column 0

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 1046, in _async_update_entity_states
    await entity.async_update_ha_state(True)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 962, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1132, in _async_write_ha_state
    self.__async_calculate_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1091, in __async_calculate_state
    if (entity_picture := self.entity_picture) is not None:
                          ^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 1081, in entity_picture
    return self.media_image_local
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 1086, in media_image_local
    if (image_hash := self.media_image_hash) is None:
                      ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 652, in media_image_hash
    if (url := self.media_image_url) is not None:
               ^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/dlna_dmr/media_player.py", line 894, in media_image_url
    return self._device.media_image_url
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/async_upnp_client/profiles/dlna.py", line 1198, in media_image_url
    items = _cached_from_xml_string(xml)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/async_upnp_client/profiles/dlna.py", line 239, in _cached_from_xml_string
    return didl_lite.from_xml_string(xml, strict=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/didl_lite/didl_lite.py", line 1077, in from_xml_string
    xml_el = defusedxml.ElementTree.fromstring(xml_string)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/defusedxml/common.py", line 126, in fromstring
    parser.feed(text)
  File "/usr/local/lib/python3.12/xml/etree/ElementTree.py", line 1708, in feed
    self._raiseerror(v)
  File "/usr/local/lib/python3.12/xml/etree/ElementTree.py", line 1615, in _raiseerror
    raise err
xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 1, column 0
2024-11-28 11:35:48.226 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/xml/etree/ElementTree.py", line 1706, in feed
    self.parser.Parse(data, False)
xml.parsers.expat.ExpatError: not well-formed (invalid token): line 1, column 0

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 1046, in _async_update_entity_states
    await entity.async_update_ha_state(True)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 962, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1132, in _async_write_ha_state
    self.__async_calculate_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1091, in __async_calculate_state
    if (entity_picture := self.entity_picture) is not None:
                          ^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 1081, in entity_picture
    return self.media_image_local
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 1086, in media_image_local
    if (image_hash := self.media_image_hash) is None:
                      ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 652, in media_image_hash
    if (url := self.media_image_url) is not None:
               ^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/dlna_dmr/media_player.py", line 894, in media_image_url
    return self._device.media_image_url
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/async_upnp_client/profiles/dlna.py", line 1198, in media_image_url
    items = _cached_from_xml_string(xml)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/async_upnp_client/profiles/dlna.py", line 239, in _cached_from_xml_string
    return didl_lite.from_xml_string(xml, strict=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/didl_lite/didl_lite.py", line 1077, in from_xml_string
    xml_el = defusedxml.ElementTree.fromstring(xml_string)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/defusedxml/common.py", line 126, in fromstring
    parser.feed(text)
  File "/usr/local/lib/python3.12/xml/etree/ElementTree.py", line 1708, in feed
    self._raiseerror(v)
  File "/usr/local/lib/python3.12/xml/etree/ElementTree.py", line 1615, in _raiseerror
    raise err
xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 1, column 0
2024-11-28 11:35:56.723 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/xml/etree/ElementTree.py", line 1706, in feed
    self.parser.Parse(data, False)
xml.parsers.expat.ExpatError: not well-formed (invalid token): line 1, column 0

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 1046, in _async_update_entity_states
    await entity.async_update_ha_state(True)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 962, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1132, in _async_write_ha_state
    self.__async_calculate_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1091, in __async_calculate_state
    if (entity_picture := self.entity_picture) is not None:
                          ^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 1081, in entity_picture
    return self.media_image_local
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 1086, in media_image_local
    if (image_hash := self.media_image_hash) is None:
                      ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 652, in media_image_hash
    if (url := self.media_image_url) is not None:
               ^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/dlna_dmr/media_player.py", line 894, in media_image_url
    return self._device.media_image_url
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/async_upnp_client/profiles/dlna.py", line 1198, in media_image_url
    items = _cached_from_xml_string(xml)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/async_upnp_client/profiles/dlna.py", line 239, in _cached_from_xml_string
    return didl_lite.from_xml_string(xml, strict=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/didl_lite/didl_lite.py", line 1077, in from_xml_string
    xml_el = defusedxml.ElementTree.fromstring(xml_string)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/defusedxml/common.py", line 126, in fromstring
    parser.feed(text)
  File "/usr/local/lib/python3.12/xml/etree/ElementTree.py", line 1708, in feed
    self._raiseerror(v)
  File "/usr/local/lib/python3.12/xml/etree/ElementTree.py", line 1615, in _raiseerror
    raise err
xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 1, column 0
2024-11-28 11:35:56.844 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/xml/etree/ElementTree.py", line 1706, in feed
    self.parser.Parse(data, False)
xml.parsers.expat.ExpatError: not well-formed (invalid token): line 1, column 0

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 1046, in _async_update_entity_states
    await entity.async_update_ha_state(True)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 962, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1132, in _async_write_ha_state
    self.__async_calculate_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1091, in __async_calculate_state
    if (entity_picture := self.entity_picture) is not None:
                          ^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 1081, in entity_picture
    return self.media_image_local
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 1086, in media_image_local
    if (image_hash := self.media_image_hash) is None:
                      ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 652, in media_image_hash
    if (url := self.media_image_url) is not None:
               ^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/dlna_dmr/media_player.py", line 894, in media_image_url
    return self._device.media_image_url
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/async_upnp_client/profiles/dlna.py", line 1198, in media_image_url
    items = _cached_from_xml_string(xml)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/async_upnp_client/profiles/dlna.py", line 239, in _cached_from_xml_string
    return didl_lite.from_xml_string(xml, strict=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/didl_lite/didl_lite.py", line 1077, in from_xml_string
    xml_el = defusedxml.ElementTree.fromstring(xml_string)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/defusedxml/common.py", line 126, in fromstring
    parser.feed(text)
  File "/usr/local/lib/python3.12/xml/etree/ElementTree.py", line 1708, in feed
    self._raiseerror(v)
  File "/usr/local/lib/python3.12/xml/etree/ElementTree.py", line 1615, in _raiseerror
    raise err
xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 1, column 0