From 5e1f30f1be9664ca397d93de82bbed3f8e863e5a Mon Sep 17 00:00:00 2001 From: Harrison Carter Date: Mon, 26 Jan 2026 12:55:50 -0600 Subject: [PATCH 1/2] remove hardcoded ports --- drivers/SmartThings/sonos/src/api/sonos_connection.lua | 3 ++- .../SmartThings/sonos/src/api/sonos_ssdp_discovery.lua | 9 ++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/SmartThings/sonos/src/api/sonos_connection.lua b/drivers/SmartThings/sonos/src/api/sonos_connection.lua index 471c3a04fb..cb02e26dfe 100644 --- a/drivers/SmartThings/sonos/src/api/sonos_connection.lua +++ b/drivers/SmartThings/sonos/src/api/sonos_connection.lua @@ -488,8 +488,9 @@ function SonosConnection.new(driver, device) end local url_ip = lb_utils.force_url_table(coordinator_player.player.websocket_url).host + local url_port = lb_utils.force_url_table(coordinator_player.player.websocket_url).port or SonosApi.DEFAULT_SONOS_PORT local base_url = lb_utils.force_url_table( - string.format("https://%s:%s", url_ip, SonosApi.DEFAULT_SONOS_PORT) + string.format("https://%s:%s", url_ip, url_port) ) local _, api_key = driver:check_auth(device) local maybe_token = driver:get_oauth_token() diff --git a/drivers/SmartThings/sonos/src/api/sonos_ssdp_discovery.lua b/drivers/SmartThings/sonos/src/api/sonos_ssdp_discovery.lua index ddc1d0842d..21cbdcd62c 100644 --- a/drivers/SmartThings/sonos/src/api/sonos_ssdp_discovery.lua +++ b/drivers/SmartThings/sonos/src/api/sonos_ssdp_discovery.lua @@ -421,12 +421,11 @@ function sonos_ssdp.spawn_persistent_ssdp_task() if is_new_information then local headers = SonosApi.make_headers() - local discovery_info, err = SonosApi.RestApi.get_player_info( - net_url.parse( - string.format("https://%s:%s", sonos_ssdp_info.ip, SonosApi.DEFAULT_SONOS_PORT) - ), - 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) ) + local discovery_info, err = SonosApi.RestApi.get_player_info(base_url, headers) if not discovery_info then log.error(string.format("Error getting discovery info from SSDP response: %s", err)) elseif discovery_info._objectType == "globalError" then From b95daf3876f434083077bb6576dd0e349c836e38 Mon Sep 17 00:00:00 2001 From: Harrison Carter Date: Wed, 1 Apr 2026 16:29:58 -0500 Subject: [PATCH 2/2] cleanup! don't force_url_table twice --- drivers/SmartThings/sonos/src/api/sonos_connection.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/SmartThings/sonos/src/api/sonos_connection.lua b/drivers/SmartThings/sonos/src/api/sonos_connection.lua index cb02e26dfe..6a131c3b0c 100644 --- a/drivers/SmartThings/sonos/src/api/sonos_connection.lua +++ b/drivers/SmartThings/sonos/src/api/sonos_connection.lua @@ -487,8 +487,9 @@ function SonosConnection.new(driver, device) return end - local url_ip = lb_utils.force_url_table(coordinator_player.player.websocket_url).host - local url_port = lb_utils.force_url_table(coordinator_player.player.websocket_url).port or SonosApi.DEFAULT_SONOS_PORT + local url_table = lb_utils.force_url_table(coordinator_player.player.websocket_url) + local url_ip = url_table.host + local url_port = url_table.port or SonosApi.DEFAULT_SONOS_PORT local base_url = lb_utils.force_url_table( string.format("https://%s:%s", url_ip, url_port) )