Skip to content

Commit c9436f8

Browse files
committed
remove hardcoded ports
1 parent 8b56e69 commit c9436f8

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

drivers/SmartThings/sonos/src/api/sonos_connection.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,8 +488,9 @@ function SonosConnection.new(driver, device)
488488
end
489489

490490
local url_ip = lb_utils.force_url_table(coordinator_player.player.websocket_url).host
491+
local url_port = lb_utils.force_url_table(coordinator_player.player.websocket_url).port or SonosApi.DEFAULT_SONOS_PORT
491492
local base_url = lb_utils.force_url_table(
492-
string.format("https://%s:%s", url_ip, SonosApi.DEFAULT_SONOS_PORT)
493+
string.format("https://%s:%s", url_ip, url_port)
493494
)
494495
local _, api_key = driver:check_auth(device)
495496
local maybe_token = driver:get_oauth_token()

drivers/SmartThings/sonos/src/api/sonos_ssdp_discovery.lua

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -421,12 +421,11 @@ function sonos_ssdp.spawn_persistent_ssdp_task()
421421

422422
if is_new_information then
423423
local headers = SonosApi.make_headers()
424-
local discovery_info, err = SonosApi.RestApi.get_player_info(
425-
net_url.parse(
426-
string.format("https://%s:%s", sonos_ssdp_info.ip, SonosApi.DEFAULT_SONOS_PORT)
427-
),
428-
headers
424+
local parsed_wss_url = net_url.parse(sonos_ssdp_info.wss_url) or {}
425+
local base_url = net_url.parse(
426+
string.format("https://%s:%s", parsed_wss_url.host, parsed_wss_url.port or SonosApi.DEFAULT_SONOS_PORT)
429427
)
428+
local discovery_info, err = SonosApi.RestApi.get_player_info(base_url, headers)
430429
if not discovery_info then
431430
log.error(string.format("Error getting discovery info from SSDP response: %s", err))
432431
elseif discovery_info._objectType == "globalError" then

0 commit comments

Comments
 (0)