Skip to content

Sonos: Remove Hardcoded Ports#2855

Open
hcarter-775 wants to merge 2 commits intomainfrom
sonos/remove-harcoded-ports
Open

Sonos: Remove Hardcoded Ports#2855
hcarter-775 wants to merge 2 commits intomainfrom
sonos/remove-harcoded-ports

Conversation

@hcarter-775
Copy link
Copy Markdown
Contributor

@hcarter-775 hcarter-775 commented Mar 26, 2026

Description of Change

Let the port being used be defined by the websocket in all cases rather than being hardcoded.

Summary of Completed Tests

Onboarding and using of favorites was tested on-device.

@hcarter-775 hcarter-775 force-pushed the sonos/remove-harcoded-ports branch from c9436f8 to 5e1f30f Compare March 26, 2026 15:14
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 26, 2026

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against b95daf3

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 26, 2026

Test Results

   72 files    494 suites   0s ⏱️
2 703 tests 2 703 ✅ 0 💤 0 ❌
4 575 runs  4 575 ✅ 0 💤 0 ❌

Results for commit b95daf3.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Copy Markdown

headers
local parsed_wss_url = net_url.parse(sonos_ssdp_info.wss_url) or {}
local base_url = net_url.parse(
string.format("https://%s:%s", parsed_wss_url.host, parsed_wss_url.port or SonosApi.DEFAULT_SONOS_PORT)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the switch from sonos_ssdp_info.ip to parsed_wss_url.host? Is sonos_ssdp_info.wss_url guaranteed to be present with at least a hostname?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be the same. ip is parsed from the LOCATION header of the response:

A URL for more information about the device from the
group_description.xml file.

wss_url is parsed from the WEBSOCK.SMARTSPEAKER.AUD IO header:

The WebSocket URL.

Using the websocket url ip is consistent with the other rest call in the PR, but I don't know if one is better to use than the other.

After we get the discovery info here, we combine it with the ssdp info and generate the rest url from ip in the ssdp info. Eventually, the rest url gets set as a device field and is used for the other rest calls not in this PR (as they already use the provided port over the default).

For consistency, I wonder if we should be using ip here and then change the other call in the PR to use device:get_field(PlayerFields.REST_URL) example where we get it from device field

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since I agree, these should be the same thing (I'd have been able to explain it less eloquently) and since we've shown with an on-device test that ssdp discovery works as expected, I am going to leave this as-is.

headers
local parsed_wss_url = net_url.parse(sonos_ssdp_info.wss_url) or {}
local base_url = net_url.parse(
string.format("https://%s:%s", parsed_wss_url.host, parsed_wss_url.port or SonosApi.DEFAULT_SONOS_PORT)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be the same. ip is parsed from the LOCATION header of the response:

A URL for more information about the device from the
group_description.xml file.

wss_url is parsed from the WEBSOCK.SMARTSPEAKER.AUD IO header:

The WebSocket URL.

Using the websocket url ip is consistent with the other rest call in the PR, but I don't know if one is better to use than the other.

After we get the discovery info here, we combine it with the ssdp info and generate the rest url from ip in the ssdp info. Eventually, the rest url gets set as a device field and is used for the other rest calls not in this PR (as they already use the provided port over the default).

For consistency, I wonder if we should be using ip here and then change the other call in the PR to use device:get_field(PlayerFields.REST_URL) example where we get it from device field

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants