File tree Expand file tree Collapse file tree
drivers/SmartThings/sonos/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change 183183function SonosState :update_device_record_group_info (household , group , device )
184184 local player_id = device :get_field (PlayerFields .PLAYER_ID )
185185 local group_role
186- if player_id == group .coordinatorId then
187- if # household .groups [group .id ].playerIds > 1 then
186+ if (player_id and group and group .id and group .coordinatorId ) and player_id == group .coordinatorId then
187+ local player_ids_list = household .groups [group .id ].playerIds or {}
188+ if # player_ids_list > 1 then
188189 group_role = " primary"
189190 else
190191 group_role = " ungrouped"
248249--- @param household_id HouseholdId
249250--- @param device SonosDevice
250251function SonosState :update_device_record_from_state (household_id , device )
251- local current_mapping = _STATE .device_record_map [device .id ]
252+ local current_mapping = _STATE .device_record_map [device .id ] or {}
252253 local household = _STATE .households :get_or_init (household_id )
253254 self :update_device_record_group_info (household , current_mapping .group , device )
254255end
You can’t perform that action at this time.
0 commit comments