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
72.14k stars 30.18k forks source link

Cambridge Audio Integration: Device State Not Updating and Controls Unresponsive #127485

Open dheckl opened 1 day ago

dheckl commented 1 day ago

The problem

I attempted to use the new Cambridge Audio Integration with my Evo 150, but after a short period, the device state is no longer updated. For example, it continues to show as 'on' even though I turned it off using the physical buttons on the device. Additionally, attempting to send commands to the device through Home Assistant or the HomeKit Bridge has no effect. The attached debug log contains the corresponding error messages. Previously, I was using custom component cambridge_cxn without any issues.

What version of Home Assistant Core has the issue?

2024.10.0

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

Cambridge Audio

Link to integration documentation on our website

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

Diagnostics information

config_entry-cambridge_audio-01J986B79X8504V0YZAPAM9BTN.json

Example YAML snippet

No response

Anything in the logs that might be useful for us?

home-assistant_cambridge_audio_2024-10-03T18-50-36.402Z.log

Additional information

No response

home-assistant[bot] commented 1 day ago

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

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


cambridge_audio documentation cambridge_audio source (message by IssueLinks)

noahhusby commented 1 day ago

Do you have standby mode in the unit's settings set to Network standby?

dheckl commented 1 day ago

Yes and the device responds to ping.

noahhusby commented 1 day ago

Can you please add the following to your configuration.yml, and restart HA?

logger:
  default: info
  logs:
    aiostreammagic: debug

It looks like the StreamMagic library's task is getting cancelled which indicates an error was thrown.

dheckl commented 1 day ago

I added the logger configuration and was able to reproduce the issue. However, the logs still only show "websockets.exceptions.ConnectionClosedError: sent 1011 (internal error) keepalive ping timeout; no close frame received.". Please see the logs: home-assistant_2024-10-04T05-50-36.742Z.log

I reproduced the issue by switching channels via HomeKit. After some switching, the Evo 150 displayed the "Network initialization" screen, which suggests that something crashed and restarted on the device due to the external commands. This issue does not occur when performing the same actions using the StreamMagic app.

The Evo 150 remained unresponsive to commands sent via Home Assistant. I reloaded the integration, but it didn’t help. I had to restart Home Assistant to make it work again, though restarting the Evo 150 was not necessary.

noahhusby commented 1 day ago

Okay, so just to confirm. The issue begins only when certain commands are issued through the HomeKit bridge and not directly from HA?

At the end of the day, looks like the websocket connection is closed when the unit resets, and the reconnect handler in the integration isn't functioning properly. I'll get the reconnect handler fixed.

dheckl commented 1 day ago

The issue occurs when sending commands directly through Home Assistant as well. My earlier tests were only conducted using the HomeKit Bridge.

Your proposed fix makes sense, and I believe it should resolve the issue.

noahhusby commented 18 hours ago

Few clarifications: 1) Do all commands crash the unit, or just specific ones? 2) What mode (source) are you in while testing? Does this occur in other sources as well? 3) Do you get Network initialization screen every time it looses connection? 4) Does the Evo 150 have the latest firmware? (What version is it currently on?)

There are two issues to this issue. The first is the reconnect handler which will I'm currently fixing. The other is tracking down why the unit is crashing in the first place.

dheckl commented 16 hours ago

While testing to identify a pattern, I was able to reproduce the "network initialization" screen appearing with the StreamMagic app. I could consistently reproduce the issue by waking the device from network standby and immediately switching from Aux to AirPlay, then back to Aux. This suggests the issue is related to the Evo 150's firmware and not related to HA integration. It only seems to occur when the device is freshly woken from network standby, as I was unable to replicate the issue during regular use. The Evo 150 is running the latest firmware (v134-b-008).

noahhusby commented 16 hours ago

The Home Assistant integration hooks into the same API as the StreamMagic app, so that result makes sense. The linked pull request above is to fix the reconnect handler which will allow the integration to silently reconnect without the need to do a manual reload / restart.