Skip to content

Commit abb1e6b

Browse files
authored
Merge pull request #2180 from SmartThingsCommunity/fix/sonos-query-favorites-regression
2 parents 1a9fe00 + 1fb88dc commit abb1e6b

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ CapEventHandlers.PlaybackStatus = {
99
Buffering = "PLAYBACK_STATE_BUFFERING",
1010
Idle = "PLAYBACK_STATE_IDLE",
1111
Paused = "PLAYBACK_STATE_PAUSED",
12-
Playing = "PLAYBACK_STATE_PLAYING"
12+
Playing = "PLAYBACK_STATE_PLAYING",
1313
}
1414

1515
function CapEventHandlers.handle_player_volume(device, new_volume, is_muted)
@@ -84,7 +84,12 @@ function CapEventHandlers.handle_playback_metadata_update(device, metadata_statu
8484
local is_linein = string.find(metadata_status_body.container.type, "linein", 1, true) ~= nil
8585
local is_station = string.find(metadata_status_body.container.type, "station", 1, true) ~= nil
8686
local is_show = string.find(metadata_status_body.container.type, "show", 1, true) ~= nil
87-
local is_radio_tracklist = string.find(metadata_status_body.container.type, "trackList.program", 1, true) ~= nil
87+
local is_radio_tracklist = string.find(
88+
metadata_status_body.container.type,
89+
"trackList.program",
90+
1,
91+
true
92+
) ~= nil
8893

8994
if is_linein then
9095
audio_track_data.title = metadata_status_body.container.name
@@ -101,8 +106,7 @@ function CapEventHandlers.handle_playback_metadata_update(device, metadata_statu
101106
if metadata_status_body.track then
102107
track_info = metadata_status_body.track
103108
elseif metadata_status_body.currentItem and metadata_status_body.currentItem.track then
104-
track_info = metadata_status_body
105-
.currentItem.track
109+
track_info = metadata_status_body.currentItem.track
106110
end
107111

108112
if track_info ~= nil then

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,11 @@ function SonosConnection.new(driver, device)
466466
local base_url = lb_utils.force_url_table(
467467
string.format("https://%s:%s", url_ip, SonosApi.DEFAULT_SONOS_PORT)
468468
)
469+
local _, api_key = driver:check_auth(device)
470+
local maybe_token = driver:get_oauth_token()
471+
local headers = SonosApi.make_headers(api_key, maybe_token and maybe_token.accessToken)
469472
local favorites_response, err, _ =
470-
SonosRestApi.get_favorites(base_url, header.householdId)
473+
SonosRestApi.get_favorites(base_url, header.householdId, headers)
471474

472475
if err or not favorites_response then
473476
log.error("Error querying for favorites: " .. err)

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ local function make_persistent_task_impl(
9999
interval_timer:handled()
100100
ssdp_search_handle:multicast_m_search()
101101
elseif receiver == control_rx then
102-
---@type ControlMessage?,string?
103102
local recv, recv_err = receiver:receive()
104103
if not recv then
105104
log.warn(string.format("control channel receive error: %s", recv_err))

0 commit comments

Comments
 (0)