Skip to content

Commit e6a97d2

Browse files
committed
fixup! fix(sonos): Improved handling of bonded set membership changes.
1 parent d5ed860 commit e6a97d2

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

drivers/SmartThings/sonos/src/sonos_driver.lua

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -504,14 +504,8 @@ function SonosDriver:handle_player_discovery_info(api_key, info, device)
504504
-- If the SSDP Group Info is an empty string, then that means it's the non-primary
505505
-- speaker in a bonded set (e.g. a home theater system, a stereo pair, etc).
506506
-- These aren't the same as speaker groups, and bonded speakers can't be controlled
507-
-- via websocket at all. So we ignore all bonded non-primary speakers
508-
-- if then
509-
-- return nil,
510-
-- string.format(
511-
-- "Player %s is a non-primary bonded Sonos device, ignoring",
512-
-- info.discovery_info.device.name
513-
-- )
514-
-- end
507+
-- via websocket at all. So we ignore all bonded non-primary speakers if they are not
508+
-- already onboarded.
515509

516510
local discovery_info_mac_addr = utils.extract_mac_addr(info.discovery_info.device)
517511
local bonded = (#info.ssdp_info.group_id == 0)

drivers/SmartThings/sonos/src/sonos_state.lua

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ function _household_mt:reset()
2222
self.groups = utils.new_case_insensitive_table()
2323
self.players = utils.new_case_insensitive_table()
2424
self.player_to_group = utils.new_case_insensitive_table()
25+
-- previously bonded devices should not be un-bonded after a reset since these should
26+
-- not be treated as distinct devices
2527
if not self.bonded_players then
2628
self.bonded_players = utils.new_case_insensitive_table()
2729
end
@@ -117,9 +119,8 @@ function SonosState:associate_device_record(device, info)
117119
return
118120
end
119121

120-
local player_tbl = household.players[player_id]
121-
local player = (player_tbl or {}).player
122-
local sonos_device = (player_tbl or {}).device
122+
local player = (household.players[player_id] or {}).player
123+
local sonos_device = (household.players[player_id] or {}).device
123124

124125
if not (player and sonos_device) then
125126
log.error(
@@ -330,7 +331,7 @@ function SonosState:update_household_info(id, groups_event, driver)
330331
local group_id
331332
-- non-primary bonded players are excluded from a group's list of PlayerID's so we use the group membership
332333
-- of the primary device
333-
if type(device.primaryDeviceId) == "string" and #device.primaryDeviceId > 0 then
334+
if type(device.primaryDeviceId) == "string" and device.primaryDeviceId ~= "" then
334335
currently_bonded = true
335336
group_id = household.player_to_group[device.primaryDeviceId]
336337
else

0 commit comments

Comments
 (0)