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
73.83k stars 30.91k forks source link

Yahama integration broken after upgrade to 2024.8.0 #123517

Closed rbr101 closed 3 months ago

rbr101 commented 3 months ago

The problem

The yahama integration is broken after upgrade to 2024.8.0, it was working fine until I upgraded.

What version of Home Assistant Core has the issue?

core-2024.8.0

What was the last working version of Home Assistant Core?

core-2024.7.3

What type of installation are you running?

Home Assistant OS

Integration causing the issue

yamaha

Link to integration documentation on our website

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

Diagnostics information

No response

Example YAML snippet

- platform: yamaha
  name: yamaha
  host: x.x.x.x
  source_ignore:
    - "AV1"
    - "AV2"
    - "AV3"
    - "AV4"
    - "AV5"
    - "AV6"
    - "AUX"
    - "HDMI5"
    - "HDMI6"
  source_names:
    HDMI1: "FireTV"
    HDMI3: "Chromecast"
    HDMI2: "SteamDeck"
    HDMI4: "GamePC"

Anything in the logs that might be useful for us?

Logger: homeassistant.components.media_player
Source: helpers/entity_platform.py:364
integration: Media player ([documentation](https://www.home-assistant.io/integrations/media_player), [issues](https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+media_player%22))
First occurred: 10:02:17 AM (1 occurrences)
Last logged: 10:02:17 AM

Error while setting up yamaha platform for media_player
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 364, in _async_setup_platform
    await asyncio.shield(awaitable)
  File "/usr/src/homeassistant/homeassistant/components/yamaha/media_player.py", line 167, in async_setup_platform
    zone_ctrls = await hass.async_add_executor_job(_discovery, config_info)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/yamaha/media_player.py", line 136, in _discovery
    for recv in rxv.find():
                ^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/rxv/__init__.py", line 19, in find
    return [RXV(**ri._asdict()) for ri in ssdp.discover(timeout=timeout)]
                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/rxv/ssdp.py", line 68, in discover
    m = re.search(r"LOCATION:(.+)", res.decode('utf-8'), re.IGNORECASE)
                                    ^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc5 in position 1: invalid continuation byte

Additional information

No response

home-assistant[bot] commented 3 months ago

yamaha documentation yamaha source

home-assistant[bot] commented 3 months ago

Hey there @home-assistant/core, mind taking a look at this issue as it has been labeled with an integration (media_player) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `media_player` 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 media_player` 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)


media_player documentation media_player source (message by IssueLinks)

joostlek commented 3 months ago

@pssc Why did we use rxv.find() when the host is known? I see that we now also suppress an AttributeError, but is there a reason for that?

pssc commented 3 months ago

@pssc Why did we use rxv.find() when the host is known? I see that we now also suppress an AttributeError, but is there a reason for that?

@joostlek Serial number is only available from the discovery info from find and not from queuing the endpoint unfortunately, so to generate a good uid we use that in preference and then fall back as not all receivers will support discovery, I suspect that this catching of attr error is masking a bug in the underlying lib but it wast my patch and not enough detail was supplied in the pr to look into it further

joostlek commented 3 months ago

Okay but can we fix this bug? Otherwise I think reverting would be the best option for now. Ideally we'd use the built in SSDP discovery in HA with a config flow

Petro31 commented 3 months ago

I added the suppress attribute error to support my Yamaha receivers. I have 2 dev builds and 1 production system. The error only occurred on the production system, so I suppressed it to return the integration to its previous behavior on setup. It's a band aide because we can't really fix rxv without the repo owner responding and he usually doesn't respond to PRs for months/years.

pssc commented 3 months ago

@joostlek yes sure we can fix this sorry just got all the context that will teach me to look from a mobile device this is a different bug from @Petro31's probably in a similar manner

pssc commented 3 months ago

@joostlek I would embark on a rewrite but given most this HW is over a decade old now... this integration probably has a somewhat limited lifespan

joostlek commented 3 months ago

I mean, if we don't expect it to stop working anytime soon we can just make it feature complete with the newest features and just have it in a maintenance phase

pssc commented 3 months ago

so looking at this a bit more it looks like broken Unicode/Text supplied by the device and then the supporting lib then blows up.

quadflight commented 3 months ago

2024-08-10 12:27:52.047 ERROR (MainThread) [homeassistant.components.media_player] Error while setting up yamaha platform for media_player Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 364, in _async_setup_platform await asyncio.shield(awaitable) File "/config/custom_components/yamaha/media_player.py", line 167, in async_setup_platform zone_ctrls = await hass.async_add_executor_job(_discovery, config_info) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/yamaha/media_player.py", line 136, in _discovery for recv in rxv.find(): ^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/rxv/__init__.py", line 19, in find return [RXV(**ri._asdict()) for ri in ssdp.discover(timeout=timeout)] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/rxv/ssdp.py", line 72, in discover res = rxv_details(url) ^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/rxv/ssdp.py", line 83, in rxv_details res = cElementTree.XML(requests.get(location).content) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 1706, in feed self.parser.Parse(data, False) ValueError: multi-byte encodings are not supported

Still got issues

pssc commented 3 months ago

ValueError

Ok added value error @quadflight see how you go

quadflight commented 3 months ago

ValueError

Ok added value error @quadflight see how you go

Yep. That worked. Thank you for giving back my weekend !

pssc commented 3 months ago

@quadflight Sorry for borking it out of interest do you get a serial/unique_id or is it still unavailable?

quadflight commented 3 months ago

@quadflight Sorry for borking it out of interest do you get a serial/unique_id or is it still unavailable?

No UID

pssc commented 3 months ago

@quadflight :-( suspected that might be the case

avwuff commented 3 months ago

Heya,

I also recently upgraded to the latest version and my Yamaha integration died. I was only able to capture this error before I rolled back to the previous version (2024.1)

Logger: homeassistant.components.media_player
Source: helpers/entity_platform.py:408
integration: Media player (documentation, issues)
First occurred: 12:44:04 AM (1 occurrences)
Last logged: 12:44:04 AM
Setup of platform yamaha is taking longer than 60 seconds. Startup will proceed without waiting any longer.

Does this fix address this problem? Thanks!

pssc commented 3 months ago

@avwuff without seeing a debug log maybe...