@@ -150,7 +150,7 @@ public class Device {
150
150
// The first accessory must be aid 1
151
151
accessories [ 0 ] . aid = 1
152
152
153
- addAccessories ( accessories)
153
+ addToAccessoryList ( accessories)
154
154
}
155
155
156
156
private func persistConfig( ) {
@@ -185,7 +185,7 @@ public class Device {
185
185
/// It is an error to try and add accessories with duplicate serial numbers.
186
186
/// It is an error to try and add accessories to a non-bridge device.
187
187
/// It is an error to try and increase the number of accessories above 99.
188
- public func addAccessories ( _ newAccessories: [ Accessory ] ) {
188
+ private func addToAccessoryList ( _ newAccessories: [ Accessory ] ) {
189
189
let totalNumberOfAccessories = accessories. count + newAccessories. count
190
190
precondition (
191
191
( isBridge && totalNumberOfAccessories <= 100 ) ||
@@ -228,6 +228,18 @@ public class Device {
228
228
configuration. aidForAccessorySerialNumber [ serialNumber] = accessory. aid
229
229
}
230
230
}
231
+ }
232
+
233
+ /// Add an array of accessories to this bridge device, and notify changes
234
+ ///
235
+ /// It is an error to try and add accessories with duplicate serial numbers.
236
+ /// It is an error to try and add accessories to a non-bridge device.
237
+ /// It is an error to try and increase the number of accessories above 99.
238
+ public func addAccessories( _ newAccessories: [ Accessory ] ) {
239
+
240
+ addToAccessoryList ( newAccessories)
241
+
242
+ delegate? . didChangeAccessoryList ( )
231
243
232
244
// Write configuration data to persist updated aid's and notify listeners
233
245
updatedConfiguration ( )
@@ -286,6 +298,8 @@ public class Device {
286
298
let serialNumber = accessory. serialNumber
287
299
configuration. aidForAccessorySerialNumber. removeValue ( forKey: serialNumber)
288
300
}
301
+ delegate? . didChangeAccessoryList ( )
302
+
289
303
// write configuration data to persist updated aid's
290
304
updatedConfiguration ( )
291
305
}
0 commit comments