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.07k stars 29.73k forks source link

Slow state update for yamaha_musiccast #118352

Open Kernald opened 3 months ago

Kernald commented 3 months ago

The problem

Very similar to what's been described in #79148: actions from Home Assistant to MusicCast devices are virtually instant, but getting the state changes (either from HA or from the MusicCast app) back to HA takes up to a minute. Unlike #79148 however, I do not have HA running in a container, there shouldn't be any network restrictions in place.

What version of Home Assistant Core has the issue?

core-2024.5.5

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Core

Integration causing the issue

yamaha_musiccast

Link to integration documentation on our website

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

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

May 29 16:42:18 galatea hass[1668276]: 2024-05-29 16:42:18.589 DEBUG (MainThread) [homeassistant.components.yamaha_musiccast] Finished fetching yamaha_musiccast data in 0.025 seconds (success: True)
May 29 16:42:18 galatea hass[1668276]: 2024-05-29 16:42:18.659 DEBUG (MainThread) [aiomusiccast.musiccast_device] Fetching netusb...
May 29 16:42:18 galatea hass[1668276]: 2024-05-29 16:42:18.695 DEBUG (MainThread) [aiomusiccast.musiccast_device] Fetching netusb...
May 29 16:42:18 galatea hass[1668276]: 2024-05-29 16:42:18.710 DEBUG (MainThread) [aiomusiccast.musiccast_device] Fetching tuner...
May 29 16:42:18 galatea hass[1668276]: 2024-05-29 16:42:18.715 DEBUG (MainThread) [aiomusiccast.musiccast_device] Fetching Distribution data...
May 29 16:42:18 galatea hass[1668276]: 2024-05-29 16:42:18.720 DEBUG (MainThread) [aiomusiccast.musiccast_device] Fetching zone main...
May 29 16:42:18 galatea hass[1668276]: 2024-05-29 16:42:18.726 DEBUG (MainThread) [aiomusiccast.musiccast_device] Fetching func status...
May 29 16:42:18 galatea hass[1668276]: 2024-05-29 16:42:18.732 DEBUG (MainThread) [homeassistant.components.yamaha_musiccast] Finished fetching yamaha_musiccast data in 0.048 seconds (success: True)

Additional information

Nothing in the logs (even in debug) when the integration is loading, as far as I can tell - just the above logs once every minute for all my MusicCast devices.

home-assistant[bot] commented 3 months ago

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

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


yamaha_musiccast documentation yamaha_musiccast source (message by IssueLinks)

micha91 commented 3 months ago

Which musiccast devices do you own? Did the device discovery work for you or did you add the devices manually using their IP?

Kernald commented 3 months ago

I have a few:

As far as I can remember, they all got auto-discovered, but it's been a while.

micha91 commented 2 months ago

Sorry for the late response - are you running the HA Container in Host mode? We use a UDP connection to send update from the MusicCast device to HA and therefore we open a dedicated port in HA per MusicCast device. This will most likely work in host mode only

Kernald commented 2 months ago

No worries - I appreciate the help. I'm not using HA in a container, but rather bare metal. I suspect this might then be a firewall issue - is there a specific port or range that this uses?

Kernald commented 1 month ago

For what it's worth, disabling the firewall entirely indeed fixes the issue - but that's obviously not a solution. Opening the different ports listed by Yamaha (UDP 1900, UDP 5353, UDP 51100, UDP 51200, UDP 61100, TCP 80, TCP 49154, TCP 51000) doesn't solve it either. It would be really helpful knowing what port(s)/range the component relies on.

Edit: it seems that asyncio.DatagramProtocol is used and just picks a random UDP port. It would be great to at least restrict it to a specific range.