update(_:)
Updates the accessory’s configuration.
Declaration
final nonisolated(nonsending) func update(_ configuration: AccessoryControlDevice.Configuration) async throwsParameters
- configuration:
The new configuration to apply.
Discussion
For example, the following code updates device placement:
// Get the current state.
let accessoryDevice = try AccessoryControlDevice.current(for: myAccessory)
// Modify the configuration with new values.
var configuration = accessoryDevice.configuration
configuration.devicePlacement = .onHead
// Apply the updated configuration.
try await accessoryDevice.update(configuration)
print("Successfully updated device configuration")Always register a capability before trying to update it. For example, the code above is valid only if you included the placement capability when registering the accessory.
This method throws an error if the update fails.