@@ -150,7 +150,7 @@ public class Device {
150150 // The first accessory must be aid 1
151151 accessories [ 0 ] . aid = 1
152152
153- addAccessories ( accessories)
153+ addToAccessoryList ( accessories)
154154 }
155155
156156 private func persistConfig( ) {
@@ -185,7 +185,7 @@ public class Device {
185185 /// It is an error to try and add accessories with duplicate serial numbers.
186186 /// It is an error to try and add accessories to a non-bridge device.
187187 /// 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 ] ) {
189189 let totalNumberOfAccessories = accessories. count + newAccessories. count
190190 precondition (
191191 ( isBridge && totalNumberOfAccessories <= 100 ) ||
@@ -228,6 +228,18 @@ public class Device {
228228 configuration. aidForAccessorySerialNumber [ serialNumber] = accessory. aid
229229 }
230230 }
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 ( )
231243
232244 // Write configuration data to persist updated aid's and notify listeners
233245 updatedConfiguration ( )
@@ -286,6 +298,8 @@ public class Device {
286298 let serialNumber = accessory. serialNumber
287299 configuration. aidForAccessorySerialNumber. removeValue ( forKey: serialNumber)
288300 }
301+ delegate? . didChangeAccessoryList ( )
302+
289303 // write configuration data to persist updated aid's
290304 updatedConfiguration ( )
291305 }
0 commit comments