Thiết bị chiếu sáng sử dụng các đặc điểm Matter tiêu chuẩn để xác định thiết bị cố định, bật/tắt trạng thái nguồn và điều chỉnh mức độ sáng.
Loại thiết bị đèn cơ bản nhất là
OnOffLightDeviceType
được triển khai bằng các đặc điểm
OnOffTrait và
IdentifyTrait
và có thể hỗ trợ đặc điểm
LevelControlTrait
và đặc điểm
LightEffectsTrait.
Các loại đèn khác cung cấp thêm chức năng và được triển khai bằng các đặc điểm khác:
| Loại thiết bị Home API | Đặc điểm | Ứng dụng mẫu Swift | Trường hợp sử dụng |
|---|---|---|---|
|
Đèn nhiệt độ màu
Thiết bị chiếu sáng có thể bật hoặc tắt, điều chỉnh cường độ ánh sáng và điều chỉnh nhiệt độ màu. |
Đặc điểm bắt buộc matter IdentifyTrait matter OnOffTrait matter LevelControlTrait matter ColorControlTrait |
Sáng | |
|
Đèn có thể điều chỉnh độ sáng
Thiết bị chiếu sáng có thể bật hoặc tắt, điều chỉnh cường độ ánh sáng và chuyển đổi bằng cảm biến phát hiện người trong nhà được liên kết. |
Đặc điểm bắt buộc matter IdentifyTrait matter OnOffTrait matter LevelControlTrait |
Sáng | |
|
Đèn màu mở rộng
Thiết bị chiếu sáng có thể bật hoặc tắt, điều chỉnh cường độ ánh sáng, điều chỉnh nhiệt độ màu và chuyển đổi bằng cảm biến phát hiện người trong nhà được liên kết. |
Đặc điểm bắt buộc matter IdentifyTrait matter OnOffTrait matter LevelControlTrait matter ColorControlTrait |
Sáng | |
|
Bật/tắt đèn
Thiết bị chiếu sáng có thể bật hoặc tắt. |
Đặc điểm bắt buộc matter IdentifyTrait matter OnOffTrait |
Sáng |
Luôn kiểm tra khả năng hỗ trợ thuộc tính và lệnh cho một thiết bị trước khi sử dụng bất kỳ tính năng nào hoặc cố gắng cập nhật thuộc tính. Hãy xem bài viết Điều khiển thiết bị trên iOS để biết thêm thông tin.
Điều kiện tiên quyết
Trước khi làm việc với thiết bị chiếu sáng và đường cong chiếu sáng, hãy đảm bảo ứng dụng của bạn khởi chạy Home SDK và bao gồm các lệnh nhập bắt buộc:
import Foundation import GoogleHomeSDK import GoogleHomeTypes import Network
Tìm thiết bị chiếu sáng
Để tìm thiết bị chiếu sáng trong một công trình, hãy lọc danh sách thiết bị theo loại thiết bị, chẳng hạn như OnOffLightDeviceType và DimmableLightDeviceType.
let allDevices = try await home.devices().list() // Get all On/Off Light devices in the structure let onOffLights = allDevices.filter { $0.types.contains(OnOffLightDeviceType.self) } // Get all Dimmable Light devices in the structure let dimmableLights = allDevices.filter { $0.types.contains(DimmableLightDeviceType.self) } // Retrieve a specific device type instance to access its traits let onOffLightDeviceType = await onOffLights.first?.types.get(OnOffLightDeviceType.self) let dimmableLightDeviceType = await dimmableLights.first?.types.get(DimmableLightDeviceType.self)
Bạn cũng có thể truy xuất tất cả thiết bị chiếu sáng trên nhiều loại thiết bị chiếu sáng trong một bộ lọc:
// Get a list of devices with similar device types (lights) let lightDevices = try await self.home.devices().list().compactMap { $0.types.contains(DimmableLightDeviceType.self) || $0.types.contains(OnOffLightDeviceType.self) || $0.types.contains(ColorTemperatureLightDeviceType.self) || $0.types.contains(ExtendedColorLightDeviceType.self) }
Xem thông tin cơ bản về thiết bị
Được triển khai trong Ứng dụng mẫu cho iOS
Đặc điểm BasicInformation bao gồm các thông tin như tên nhà cung cấp, mã nhà cung cấp, mã sản phẩm, tên sản phẩm (bao gồm cả thông tin về kiểu máy) và phiên bản phần mềm của thiết bị:
let vendorName = basicInfoTrait.attributes.vendorName! let vendorID = basicInfoTrait.attributes.vendorID! let productID = basicInfoTrait.attributes.productID! let productName = basicInfoTrait.attributes.productName! let softwareVersion = basicInfoTrait.attributes.softwareVersion!
Xác định thiết bị chiếu sáng
Khi một phòng có nhiều đèn, bạn có thể giúp người dùng xác định vị trí của một thiết bị cố định cụ thể bằng cách kích hoạt trạng thái nhận dạng hình ảnh, chẳng hạn như nhấp nháy đèn trong vài giây. Cả 4 loại thiết bị đèn đều yêu cầu đặc điểm Matter.IdentifyTrait.
Gọi lệnh identify với thời lượng identifyTime tính bằng giây để bắt đầu trạng thái nhận dạng. Việc truyền 0 sẽ dừng trạng thái nhận dạng ngay lập tức. Bạn cũng có thể gọi triggerEffect để chạy một hiệu ứng hình ảnh cụ thể, chẳng hạn như Blink hoặc Breathe.
func identifyLight(lightDeviceType: DimmableLightDeviceType) async throws {
guard let identifyTrait = lightDeviceType.matterTraits.identifyTrait else {
return
}
// Blink the light for 10 seconds so the user can locate it
if identifyTrait.supportsIdentifyCommand {
try await identifyTrait.identify(identifyTime: 10)
}
// Or trigger a specific visual identification effect
if identifyTrait.supportsTriggerEffectCommand {
try await identifyTrait.triggerEffect(
effectIdentifier: .blink,
effectVariant: .default
)
}
}
Kiểm tra khả năng kết nối của thiết bị chiếu sáng
Khả năng kết nối của một thiết bị thực sự được kiểm tra ở cấp loại thiết bị vì một số thiết bị hỗ trợ nhiều loại thiết bị. Trạng thái được trả về là sự kết hợp của các trạng thái kết nối cho tất cả các đặc điểm trên thiết bị đó.
let lightConnectivity = dimmableLightDeviceType.metadata.sourceConnectivity .connectivityState
Bạn có thể thấy trạng thái partiallyOnline trong trường hợp có nhiều loại thiết bị
khi không có kết nối Internet. Các đặc điểm tiêu chuẩn của Matter vẫn có thể hoạt động trực tuyến nhờ tính năng định tuyến cục bộ, nhưng các đặc điểm dựa trên đám mây sẽ không hoạt động.
Lấy địa chỉ IP của thiết bị
Để tìm địa chỉ IP của thiết bị, hãy sử dụng thuộc tính networkInterfaces của GeneralDiagnosticsTrait.
Địa chỉ được trả về dưới dạng đối tượng Data. Bạn có thể định dạng các đối tượng này thành chuỗi IPv4 hoặc IPv6 chuẩn bằng khung Network:
func getIpAddresses(trait: Matter.GeneralDiagnosticsTrait) -> [String] {
let interfaces = trait.attributes.networkInterfaces ?? []
var ipAddresses: [String] = []
for interface in interfaces {
for data in interface.iPv4Addresses {
if let ipv4 = IPv4Address(data) {
ipAddresses.append(String(describing: ipv4))
}
}
for data in interface.iPv6Addresses {
if let ipv6 = IPv6Address(data) {
ipAddresses.append(String(describing: ipv6))
}
}
}
return ipAddresses
}
Điều khiển thiết bị chiếu sáng
Các loại thiết bị OnOffLight và DimmableLight sử dụng các đặc điểm Matter tiêu chuẩn để xác định thiết bị cố định, bật/tắt trạng thái nguồn và điều chỉnh mức độ sáng.
Bật hoặc tắt đèn
Sử dụng đặc điểm OnOffTrait để đọc trạng thái nguồn hiện tại của OnOffLight hoặc DimmableLight và để bật hoặc tắt đèn.
Trước khi đọc thuộc tính onOff, hãy xác minh rằng thiết bị có hỗ trợ thuộc tính này. Một số thiết bị hoạt động dưới dạng điểm cuối chỉ có lệnh và không báo cáo trạng thái.
// Check if the OnOff trait supports the onOff attribute. if onOffTrait.attributes.$onOff.isSupported { print("onOffTrait supports onOff state") } else { print("onOffTrait is for a command only device!") }
Khi onOff là true, đèn sẽ bật. Khi onOff là false, đèn sẽ tắt.
Để thay đổi trạng thái nguồn của đèn, hãy xác minh rằng đặc điểm đó hỗ trợ lệnh dự kiến, sau đó gọi on(), off() hoặc toggle().
// Check if the OnOff trait supports the toggle command. if onOffTraitTest.supportsToggleCommand { print("onOffTrait supports toggle command") } else { print("onOffTrait does not support stateful toggle command") }
// Calling a command on a trait. do { try await onOffTraitTest.toggle() } catch let _ as HomeError { // Code for handling the exception }
Bạn cũng có thể gọi trực tiếp on() và off() để đặt trạng thái rõ ràng:
do { try await onOffTraitTest.off() try await onOffTraitTest.on() } catch let _ as HomeError { // Code for handling the exception }
Để tắt đèn bằng hiệu ứng chuyển đổi hình ảnh dần dần, hãy gọi offWithEffect() và chỉ định giá trị EffectIdentifierEnum:
// Turn off the light using the DyingLight effect. do { try await onOffTraitTest.offWithEffect( effectIdentifier: Matter.OnOffTrait.EffectIdentifierEnum.dyingLight, effectVariant: 0 ) } catch let _ as HomeError { // Code for handling the exception }
Điều chỉnh độ sáng
DimmableLight yêu cầu đặc điểm LevelControlTrait và OnOffLight có thể tuỳ ý hỗ trợ đặc điểm này. Sử dụng đặc điểm này để đọc và kiểm soát mức độ sáng của đèn.
Thuộc tính currentLevel báo cáo mức độ sáng hiện tại theo thang điểm từ 0 đến 254. Bạn cũng có thể kiểm tra minLevel và maxLevel để xác định
phạm vi độ sáng hợp lệ mà phần cứng hỗ trợ.
Để đặt độ sáng thành một giá trị cụ thể, hãy gọi moveToLevel(). Xin lưu ý rằng moveToLevel() chỉ thay đổi mức hiện tại khi đèn đã bật, trừ phi bạn định cấu hình optionsOverride bằng executeIfOff. Để tự động bật đèn khi đặt mức độ sáng khác 0 (hoặc tắt đèn khi đặt mức độ sáng ở mức tối thiểu), hãy sử dụng moveToLevelWithOnOff().
// Change the brightness of the light to 50% do { try await levelControlTraitTest.moveToLevel( level: UInt8(127), transitionTime: 0, optionsMask: Matter.LevelControlTrait.OptionsBitmap(), optionsOverride: Matter.LevelControlTrait.OptionsBitmap() ) } catch let _ as HomeError { // Code for handling the exception }
Ví dụ sau đây đọc mức độ sáng hiện tại và sử dụng moveToLevelWithOnOff() để đặt đèn có thể điều chỉnh độ sáng thành 75% độ sáng (190) trong quá trình chuyển đổi 1 giây (10 phần mười giây):
func setLightBrightness(lightDeviceType: DimmableLightDeviceType) async throws { guard let levelControl = lightDeviceType.matterTraits.levelControlTrait else { return } // Read the current brightness level (0 to 254) let currentLevel: UInt8? = levelControl.attributes.currentLevel print("Current brightness level: \(String(describing: currentLevel))") // Move to ~75% brightness (190 out of 254) and turn on the light if it is off if levelControl.supportsMoveToLevelWithOnOffCommand { try await levelControl.moveToLevelWithOnOff( level: UInt8(190), transitionTime: 10, optionsMask: Matter.LevelControlTrait.OptionsBitmap(), optionsOverride: Matter.LevelControlTrait.OptionsBitmap() ) } }
Bạn cũng có thể tăng hoặc giảm độ sáng so với mức hiện tại bằng cách gọi stepWithOnOff() bằng .up hoặc .down và stepSize.
Màu của thành phần điều khiển
Đặc điểmColorControlTrait có trên cả ColorTemperatureLightDeviceType và ExtendedColorLightDeviceType.
Đặc điểm này cho phép bạn điều chỉnh nhiệt độ màu theo độ nghịch đảo vi mô hoặc mired.
guard let colorControlTrait = colorTempLightDeviceType.matterTraits.colorControlTrait else { return } // Read the current color temperature and hardware limits in mireds // (Mireds = 1,000,000 / Kelvin; e.g., 370 mireds ≈ 2700K warm white, 250 mireds = 4000K cool white) let currentMireds = colorControlTrait.attributes.colorTemperatureMireds let minMireds = colorControlTrait.attributes.colorTempPhysicalMinMireds ?? 153 let maxMireds = colorControlTrait.attributes.colorTempPhysicalMaxMireds ?? 500 // Clamp target (370 mireds ≈ 2700K) to the device's physical bounds let targetMireds = min(max(UInt16(370), minMireds), maxMireds) if colorControlTrait.supportsMoveToColorTemperatureCommand { try await colorControlTrait.moveToColorTemperature( colorTemperatureMireds: targetMireds, transitionTime: 20, // 2.0 seconds (in 0.1s units) optionsMask: Matter.ColorControlTrait.OptionsBitmap(), optionsOverride: Matter.ColorControlTrait.OptionsBitmap() ) }
Bạn cũng có thể đặt màu bằng cách sử dụng toạ độ sắc độ CIE 1931 và giá trị sắc độ cũng như độ bão hoà 16 bit.
guard let colorControlTrait = extendedColorLightDeviceType.matterTraits.colorControlTrait else { return } // 1. Move to CIE 1931 xy chromaticity coordinates (scaled 0..65279) // Example: x = 0.3127 (20493), y = 0.3290 (21561) for D65 white point if colorControlTrait.supportsMoveToColorCommand { try await colorControlTrait.moveToColor( colorX: 20493, colorY: 21561, transitionTime: 10, // 1.0 second (in 0.1s units) optionsMask: Matter.ColorControlTrait.OptionsBitmap(), optionsOverride: Matter.ColorControlTrait.OptionsBitmap() ) } let currentX = colorControlTrait.attributes.currentX let currentY = colorControlTrait.attributes.currentY // 2. Move to 16-bit Enhanced Hue (0..65534) and 8-bit Saturation (0..254) if colorControlTrait.supportsEnhancedMoveToHueAndSaturationCommand { try await colorControlTrait.enhancedMoveToHueAndSaturation( enhancedHue: 43690, // ~240° (Blue) on the 0..65534 scale saturation: 254, // Full saturation transitionTime: 15, // 1.5 seconds (in 0.1s units) optionsMask: Matter.ColorControlTrait.OptionsBitmap(), optionsOverride: Matter.ColorControlTrait.OptionsBitmap() ) } // 3. Start a hardware color loop across the device's hue range if colorControlTrait.supportsColorLoopSetCommand { try await colorControlTrait.colorLoopSet( updateFlags: [ .updateAction, .updateDirection, .updateTime, .updateStartHue ], action: .activateFromColorLoopStartEnhancedHue, direction: .increment, time: 30, // 30 seconds per full cycle startHue: 0, optionsMask: Matter.ColorControlTrait.OptionsBitmap(), optionsOverride: Matter.ColorControlTrait.OptionsBitmap() ) }
Google.ExtendedColorControlTrait là một đặc điểm không bắt buộc của Google trên ExtendedColorLightDevice giúp đơn giản hoá việc kiểm soát màu bằng cách chấp nhận tên màu, giá trị RGB hoặc giá trị HSV dấu phẩy động hợp nhất kết hợp màu và độ sáng trong một đơn vị.
guard let extendedColorControlTrait = extendedColorLightDeviceType.googleTraits.extendedColorControlTrait else { return } // 1. Set color by name if extendedColorControlTrait.supportsMoveToColorNameCommand { try await extendedColorControlTrait.moveToColorName(colorName: "Lavender") } let currentColorName = extendedColorControlTrait.attributes.currentName // 2. Set color using 8-bit RGB values (0..255 per channel) // Automatically coordinates brightness (LevelControl) and color (ColorControl) if extendedColorControlTrait.supportsMoveToColorRGBCommand { try await extendedColorControlTrait.moveToColorRGB( red: 255, green: 128, blue: 0 ) } let currentRed = extendedColorControlTrait.attributes.currentRed let currentGreen = extendedColorControlTrait.attributes.currentGreen let currentBlue = extendedColorControlTrait.attributes.currentBlue // 3. Set color and brightness together using floating-point HSV // hue: 0.0...360.0, saturation: 0.0...1.0, value (brightness): 0.0...1.0 if extendedColorControlTrait.supportsMoveToColorHSVCommand { try await extendedColorControlTrait.moveToColorHSV( hue: 210.0, saturation: 0.85, value: 0.75 ) } let currentHue = extendedColorControlTrait.attributes.currentHue let currentSaturation = extendedColorControlTrait.attributes.currentSaturation let currentValue = extendedColorControlTrait.attributes.currentValue
Quản lý đường cong ánh sáng
Đường cong chiếu sáng xác định một lịch biểu tự động giúp chuyển đổi mượt mà độ sáng và nhiệt độ màu (không bắt buộc) của đèn mục tiêu trong suốt cả ngày. Ví dụ: đường cong chiếu sáng có thể tăng dần độ sáng của đèn vào buổi sáng và giảm độ sáng xuống tông màu ấm hơn vào buổi tối. Các loại thiết bị chiếu sáng chỉ hỗ trợ độ sáng, chẳng hạn như Đèn có thể điều chỉnh độ sáng, sẽ tuân theo đường cong độ sáng và bỏ qua nhiệt độ màu.
Đặc điểm Google.LightingCurveTrait là một đặc điểm Google Home platform (GHP) cấp cấu trúc. Bạn truy cập vào lớp này từ một thực thể Structure thay vì từ một thiết bị chiếu sáng riêng lẻ.
Mỗi lịch biểu trên đặc điểm được biểu thị bằng một LightingCurveSetting, ghép nối một settingId duy nhất với một LightingCurveConfig. Bảng sau đây mô tả các trường cấu hình của LightingCurveConfig:
| Trường | Mô tả |
|---|---|
curvePointsArray |
Một trình tự gồm ít nhất hai mục CurvePoint có thời gian riêng biệt. Mỗi điểm chỉ định một time (CurveTimeOfDay có hours từ 0 đến 23 và minutes từ 0 đến 59), một brightnessPercent (0 đến 100) và một colorTemperature không bắt buộc tính theo Kelvin. Nếu bạn chỉ định colorTemperature cho bất kỳ điểm nào, thì giá trị này phải là giá trị dương cho tất cả các điểm. |
roomId |
Mã nhận dạng của phòng mục tiêu (ví dụ: room@{uuid}). Áp dụng đường cong chiếu sáng cho đèn có thể điều chỉnh độ sáng và nhiệt độ màu tương thích trong phòng đó. Chỉ định roomId hoặc devices. |
devices |
Đối tượng TargetDevices chứa danh sách các mục nhập TargetDevice, mỗi mục nhập có một id thiết bị và mã nhận dạng type thiết bị (chẳng hạn như home.matter.0000.types.0101 cho DimmableLight hoặc home.matter.0000.types.010c cho ColorTemperatureLight). Hãy chỉ định devices hoặc roomId. |
daysOfWeekArray |
Các ngày trong tuần mà đường cong chiếu sáng chạy (Locale.Weekday). Nếu danh sách trống, đường cong chiếu sáng sẽ chạy hằng ngày. |
adaptive |
Giá trị boolean không bắt buộc cho biết liệu đường cong chiếu sáng có thích ứng hay không, tức là đèn mục tiêu sẽ tiếp tục mức đường cong hoạt động khi được bật trong phạm vi thời gian đặt lịch. Khi false, việc thay đổi đèn theo cách thủ công sẽ tách đèn khỏi đường cong chiếu sáng trong thời gian còn lại của ngày. Khi true, đèn đã tắt rồi bật lại trong phạm vi thời gian đặt lịch sẽ kết nối lại với đường cong chiếu sáng, khiến đèn tuân theo độ sáng và nhiệt độ màu hiện tại của đường cong, đồng thời tuân theo đường cong từ thời điểm đó. |
enabled |
Giá trị boolean không bắt buộc cho biết chế độ cài đặt đường cong ánh sáng có đang hoạt động hay không. Mặc định là true khi tạo chế độ cài đặt mới. Khi enabled bị bỏ qua trong lệnh cập nhật, trạng thái của enabled sẽ không thay đổi. |
Đọc chế độ cài đặt đường cong ánh sáng
Để kiểm tra các đường cong chiếu sáng được định cấu hình cho một cấu trúc, hãy truy xuất đặc điểm Google.LightingCurveTrait từ Structure và đọc thuộc tính lightingCurveSettingsArray của đặc điểm đó.
func readLightingCurves(structure: Structure) async {
guard let lightingCurve = await structure.traits.get(
Google.LightingCurveTrait.self
) else {
return
}
for setting in lightingCurve.attributes.lightingCurveSettingsArray {
let settingId = setting.settingId
let config = setting.config
print(
"Setting ID: \(String(describing: settingId)), " +
"enabled: \(String(describing: config?.enabled))"
)
for point in config?.curvePointsArray ?? [] {
print(
" Time: \(point.time?.hours ?? 0):\(point.time?.minutes ?? 0), " +
"Brightness: \(point.brightnessPercent ?? 0)%, " +
"ColorTemp: \(point.colorTemperature ?? 0)K"
)
}
}
}
Tạo chế độ cài đặt đường cong chiếu sáng
Để tạo lịch biểu đường cong chiếu sáng mới trên một cấu trúc, hãy tạo một LightingCurveConfig có ít nhất hai mục CurvePoint, đèn mục tiêu (được chỉ định bằng roomId hoặc devices) và các ngày hoạt động trong tuần. Sau đó, hãy chuyển cấu hình đến createLightingCurveSetting(). Lệnh này trả về settingId duy nhất được chỉ định cho chế độ cài đặt đường cong ánh sáng mới.
Ví dụ sau đây tạo một đường cong chiếu sáng vào ngày trong tuần cho một phòng, tăng độ sáng từ 30% lúc 7:00 sáng lên 80% lúc 9:00 sáng và giảm độ sáng xuống 20% lúc 9:00 tối:
func createRoomLightingCurve(
structure: Structure,
targetRoomId: String
) async throws -> String? {
guard let lightingCurve = await structure.traits.get(
Google.LightingCurveTrait.self
) else {
return nil
}
let curvePoints = [
Google.LightingCurveTrait.CurvePoint(
time: Google.LightingCurveTrait.CurveTimeOfDay(hours: 7, minutes: 0),
brightnessPercent: 30,
colorTemperature: 2700
),
Google.LightingCurveTrait.CurvePoint(
time: Google.LightingCurveTrait.CurveTimeOfDay(hours: 9, minutes: 0),
brightnessPercent: 80,
colorTemperature: 4000
),
Google.LightingCurveTrait.CurvePoint(
time: Google.LightingCurveTrait.CurveTimeOfDay(hours: 21, minutes: 0),
brightnessPercent: 20,
colorTemperature: 2200
),
]
let config = Google.LightingCurveTrait.LightingCurveConfig(
curvePointsArray: curvePoints,
roomId: targetRoomId,
daysOfWeekArray: [
.monday,
.tuesday,
.wednesday,
.thursday,
.friday,
],
adaptive: true,
enabled: true
)
let response = try await lightingCurve.createLightingCurveSetting(
config: config
)
return response.settingId
}
Để nhắm đến các thiết bị chiếu sáng cụ thể thay vì toàn bộ phòng, hãy cung cấp tham số devices bằng Google.LightingCurveTrait.TargetDevices:
let targetDevices = Google.LightingCurveTrait.TargetDevices(
devicesArray: [
Google.LightingCurveTrait.TargetDevice(
id: dimmableLight.id,
type: DimmableLightDeviceType.identifier
)
]
)
let deviceCurveConfig = Google.LightingCurveTrait.LightingCurveConfig(
curvePointsArray: curvePoints,
devices: targetDevices,
daysOfWeekArray: [.saturday, .sunday],
adaptive: true,
enabled: true
)
let response = try await lightingCurve.createLightingCurveSetting(
config: deviceCurveConfig
)
let settingId = response.settingId
Cập nhật chế độ cài đặt đường cong chiếu sáng
Để sửa đổi đường cong chiếu sáng hiện có (chẳng hạn như thay đổi các điểm trên đường cong, cập nhật các ngày hoạt động trong tuần hoặc bật và tắt lịch biểu), hãy gọi updateLightingCurveSetting() bằng settingId mục tiêu và LightingCurveConfig đã cập nhật.
func updateLightingCurve(
structure: Structure,
settingId: String,
updatedConfig: Google.LightingCurveTrait.LightingCurveConfig
) async throws {
guard let lightingCurve = await structure.traits.get(
Google.LightingCurveTrait.self
) else {
return
}
_ = try await lightingCurve.updateLightingCurveSetting(
settingId: settingId,
config: updatedConfig
)
}
Xoá chế độ cài đặt đường cong ánh sáng
Để xoá chế độ cài đặt đường cong ánh sáng khỏi một cấu trúc, hãy gọi deleteLightingCurveSetting() bằng settingId của chế độ cài đặt mà bạn muốn xoá.
func deleteLightingCurve(
structure: Structure,
settingId: String
) async throws {
guard let lightingCurve = await structure.traits.get(
Google.LightingCurveTrait.self
) else {
return
}
_ = try await lightingCurve.deleteLightingCurveSetting(settingId: settingId)
}