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

Can't join Audio Pro devices in a LinkPlay group #130172

Open ccristal opened 3 weeks ago

ccristal commented 3 weeks ago

The problem

I have an Audio Pro C3. Its API can be invoked via http (not https). The Linkplay integration is able to discover and configure it, but it can't join it to a group with a master device with an API accessible via https (like a Wiim Pro). This is the error message I get when I try to add my Audio Pro C3 as a satellite speaker to a Wiim Pro master:

File "/usr/local/lib/python3.12/site-packages/linkplay/utils.py", line 49, in session_call_api
    raise LinkPlayRequestException(
linkplay.exceptions.LinkPlayRequestException: Cannot connect to host 192.168.1.47:443 ssl:default [Connect call failed ('192.168.1.47', 443)] error requesting data from 'https://192.168.1.47/httpapi.asp?command=ConnectMasterAp:JoinGroupMaster:eth0.0.0.0:wifi0.0.0.0'

The device on 192.168.1.47 is the Audio Pro device, so the protocol should be http.

What version of Home Assistant Core has the issue?

core-2024.11.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

Linkplay

Link to integration documentation on our website

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

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

File "/usr/local/lib/python3.12/site-packages/linkplay/utils.py", line 49, in session_call_api
    raise LinkPlayRequestException(
linkplay.exceptions.LinkPlayRequestException: Cannot connect to host 192.168.1.47:443 ssl:default [Connect call failed ('192.168.1.47', 443)] error requesting data from 'https://192.168.1.47/httpapi.asp?command=ConnectMasterAp:JoinGroupMaster:eth0.0.0.0:wifi0.0.0.0'
2024-11-17 10:34:36.884 DEBUG (MainThread) [linkplay] Request command at https://192.168.1.47: ConnectMasterAp:JoinGroupMaster:eth0.0.0.0:wifi0.0.0.0
2024-11-17 10:34:37.385 DEBUG (MainThread) [linkplay] Request command at https://192.168.1.173: ConnectMasterAp:JoinGroupMaster:eth0.0.0.0:wifi0.0.0.0
2024-11-17 10:34:37.679 DEBUG (MainThread) [linkplay] Request multiroom:getSlaveList at https://192.168.1.177
2024-11-17 10:34:37.804 DEBUG (MainThread) [linkplay] Response multiroom:getSlaveList: {'slaves': 0, 'wmrm_version': '4.2'}
Logger: homeassistant.components.linkplay.config_flow
Source: components/linkplay/config_flow.py:38
integration: LinkPlay (documentation, issues)
First occurred: 00:00:58 (2 occurrences)
Last logged: 00:01:18

Failed to connect to LinkPlay device at fd00::1:222:6cff:fe2a:7ec7
Failed to connect to LinkPlay device at fd00::1:222:6cff:feb8:e7b2
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/yarl/_parse.py", line 134, in split_netloc
    port = int(port_str)
           ^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: ':1:222:6cff:fe2a:7ec7'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 516, in _request
    url = self._build_url(str_or_url)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 444, in _build_url
    url = URL(str_or_url)
          ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/yarl/_url.py", line 307, in __new__
    return pre_encoded_url(val) if encoded else encode_url(val)
                                                ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/yarl/_url.py", line 154, in encode_url
    username, password, host, port = split_netloc(netloc)
                                     ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/yarl/_parse.py", line 136, in split_netloc
    raise ValueError("Invalid URL: port can't be converted to integer")
ValueError: Invalid URL: port can't be converted to integer

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/linkplay/utils.py", line 46, in session_call_api
    response = await session.get(url)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 518, in _request
    raise InvalidUrlClientError(str_or_url) from e
aiohttp.client_exceptions.InvalidUrlClientError: https://fd00::1:222:6cff:fe2a:7ec7/httpapi.asp?command=getStatusEx

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/linkplay/discovery.py", line 55, in linkplay_factory_httpapi_bridge
    return await linkplay_factory_bridge_endpoint(https_endpoint)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/linkplay/discovery.py", line 39, in linkplay_factory_bridge_endpoint
    await bridge.device.update_status()
  File "/usr/local/lib/python3.12/site-packages/linkplay/bridge.py", line 44, in update_status
    self.properties = await self.bridge.json_request(LinkPlayCommand.DEVICE_STATUS)  # type: ignore[assignment]
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/linkplay/bridge.py", line 329, in json_request
    response = await self.endpoint.json_request(command)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/linkplay/endpoint.py", line 51, in json_request
    return await session_call_api_json(self._endpoint, self._session, command)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/linkplay/utils.py", line 79, in session_call_api_json
    result = await session_call_api(endpoint, session, command)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/linkplay/utils.py", line 49, in session_call_api
    raise LinkPlayRequestException(
linkplay.exceptions.LinkPlayRequestException: https://fd00::1:222:6cff:fe2a:7ec7/httpapi.asp?command=getStatusEx error requesting data from 'https://fd00::1:222:6cff:fe2a:7ec7/httpapi.asp?command=getStatusEx'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/yarl/_parse.py", line 134, in split_netloc
    port = int(port_str)
           ^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: ':1:222:6cff:fe2a:7ec7'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 516, in _request
    url = self._build_url(str_or_url)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 444, in _build_url
    url = URL(str_or_url)
          ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/yarl/_url.py", line 307, in __new__
    return pre_encoded_url(val) if encoded else encode_url(val)
                                                ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/yarl/_url.py", line 154, in encode_url
    username, password, host, port = split_netloc(netloc)
                                     ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/yarl/_parse.py", line 136, in split_netloc
    raise ValueError("Invalid URL: port can't be converted to integer")
ValueError: Invalid URL: port can't be converted to integer

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/linkplay/utils.py", line 46, in session_call_api
    response = await session.get(url)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 518, in _request
    raise InvalidUrlClientError(str_or_url) from e
aiohttp.client_exceptions.InvalidUrlClientError: http://fd00::1:222:6cff:fe2a:7ec7/httpapi.asp?command=getStatusEx

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/linkplay/config_flow.py", line 38, in async_step_zeroconf
    bridge = await linkplay_factory_httpapi_bridge(discovery_info.host, session)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/linkplay/discovery.py", line 60, in linkplay_factory_httpapi_bridge
    return await linkplay_factory_bridge_endpoint(http_endpoint)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/linkplay/discovery.py", line 39, in linkplay_factory_bridge_endpoint
    await bridge.device.update_status()
  File "/usr/local/lib/python3.12/site-packages/linkplay/bridge.py", line 44, in update_status
    self.properties = await self.bridge.json_request(LinkPlayCommand.DEVICE_STATUS)  # type: ignore[assignment]
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/linkplay/bridge.py", line 329, in json_request
    response = await self.endpoint.json_request(command)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/linkplay/endpoint.py", line 51, in json_request
    return await session_call_api_json(self._endpoint, self._session, command)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/linkplay/utils.py", line 79, in session_call_api_json
    result = await session_call_api(endpoint, session, command)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/linkplay/utils.py", line 49, in session_call_api
    raise LinkPlayRequestException(
linkplay.exceptions.LinkPlayRequestException: http://fd00::1:222:6cff:fe2a:7ec7/httpapi.asp?command=getStatusEx error requesting data from 'http://fd00::1:222:6cff:fe2a:7ec7/httpapi.asp?command=getStatusEx'
Logger: homeassistant.components.media_player
Source: components/media_player/__init__.py:1371
integration: Media Player (documentation, issues)
First occurred: 17 November 2024 at 23:42:34 (2 occurrences)
Last logged: 17 November 2024 at 23:42:46

Error retrieving proxied image from http://192.168.1.47:49152/un_known
Error retrieving proxied image from http://192.168.1.173:49152/un_known

Additional information

No response

home-assistant[bot] commented 3 weeks ago

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

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


linkplay documentation linkplay source (message by IssueLinks)

ccristal commented 3 weeks ago

I have already rolled back to nagyrobi's custom integration because of this issue, but I can restore the configuration with the new integration if it helps reproducing the problem and getting it fixed more quickly.

silamon commented 2 weeks ago

I've tested this case specifically when adding multiroom, but it appears that there are still some bugs here in gathering the leader of the multiroom. I haven't seen this bug specifically in the same way you mentioned, but I'll fix the other bugs and try to add it the next release and see if it fixes it along the way.

ccristal commented 2 weeks ago

I've tested this case specifically when adding multiroom, but it appears that there are still some bugs here in gathering the leader of the multiroom. I haven't seen this bug specifically in the same way you mentioned, but I'll fix the other bugs and try to add it the next release and see if it fixes it along the way.

Again, happy to do some testing for you if it helps...

silamon commented 2 weeks ago

If you don't mind, I would appreciate it if you could test since I don't think I have found the issue thus far. You can wait if you want until 2024.11.2 is released, since some multiroom fixes are planned to be fixed there.

The command "ConnectMasterAp:JoinGroupMaster:eth0.0.0.0:wifi0.0.0.0" should list the real ethernet address in there, that's also not happening and should be fixed in 2024.11.2.

Just like in the other issue: The integration is capable of detecting the correct protocol (either 80 and 443) and will even attempt to accept the LinkPlay certificate. On the latest home assistant version (2024.11.0+ or 2024.11.2), you can enable debug logging to get more information.

ccristal commented 1 week ago

Hi! I have now installed 2024.11.2, and the issue still exists. I have added the relevant log messages (or at least what I think is relevant) to the main issue description.

177 is my main device (Wiim Pro), 47 and 173 are the satellites (Audio Pro Addon C3) (we don't use "master" and "slave" anymore here... ;-) ).

So, the action completes but nothing is actually linked.

Hope this helps. Thanks for looking into this...