Otomatisasi yang dikelola aplikasi adalah otomatisasi yang dibuat secara terprogram oleh aplikasi partner menggunakan Automation API.
Otomatisasi tersebut tidak akan muncul dalam daftar otomatisasi Google Home app (GHA).
Informasi yang ditulis ke feed aktivitas Home API saat otomatisasi yang dikelola aplikasi dipicu dapat disesuaikan. Misalnya, jika partner menawarkan layanan bermerek bernama "Arctic" yang diimplementasikan menggunakan otomatisasi yang dikelola aplikasi, partner dapat menentukan bahwa saat otomatisasi yang dikelola aplikasi mereka berjalan, layanan Arctic akan direferensikan di feed aktivitas, bukan nama otomatisasi yang sebenarnya.
Membuat otomatisasi yang dikelola aplikasi
Untuk membuat otomatisasi yang dikelola aplikasi, gunakan prosedur berikut.
Buat grafik logika otomatisasi.
Untuk menyesuaikan tampilan aktivitas otomatisasi Anda di feed aktivitas, isi instance
AppManagedAutomationConfigdengan pesan yang dilokalkan yang ingin Anda tampilkan di feed, bukan nama otomatisasi. Nama ini dapat berupa nama aplikasi atau layanan yang dilokalkan, atau pesan lain yang Anda inginkan. Jika Anda tidak memberikan string yang dilokalkan, eksekusi otomatisasi akan dicatat dalam log seperti otomatisasi lainnya. Google merekomendasikan agar Anda menetapkan string yang dilokalkan ini untuk memastikan pengalaman pengguna terbaik.let automationConfig = AppManagedAutomationConfig( managingAppDisplayNames: [ LocalizedText(text: "My Custom SmartApp", locale: "en-US"), LocalizedText(text: "Mi aplicación personalizada", locale: "es-MX") ] )Buat instance otomatisasi menggunakan
Automation.Builder.- Tetapkan
nameotomatisasi. - Tetapkan
client_feature_groupke"APP_MANAGED_EXECUTION_REPORTED"agar histori eksekusi otomatisasi muncul di tab Aktivitas di GHA. - Tetapkan
automationGraph. - Opsional Tetapkan
appManagedAutomationConfigotomatisasi (lihat Langkah 2).
- Tetapkan
Terakhir, panggil
build()untuk mem-build instanceAutomation.
Contoh ini menunjukkan seluruh prosedur:
import GoogleHomeSDK
import GoogleHomeTypes
let devices = try await home.devices().list()
let mySensor: HomeDevice = devices.first(where: {
$0.types.contains(OccupancySensorDeviceType.self) &&
$0.structureID == structure.id
})
let myLight: HomeDevice = devices.first(
where: {
$0.types.contains(OnOffLightDeviceType.self) &&
$0.structureID == structure.id
}
)
// 1. Create logic graph
let starterNode = StarterNode(
device: mySensor,
trait: Matter.OccupancySensingTrait.self
)
let actionNode = ActionNode(
device: myLight,
command: Matter.OnOffTrait.on()
)
// Bundle nodes into a sequential graph
let automationGraph = SequentialFlow(
nodes: [starterNode, actionNode]
)
// 2. Build the AppManagedAutomationConfig with the localized app names
let automationConfig = AppManagedAutomationConfig(
managingAppDisplayNames: [
LocalizedText(text: "My Custom SmartApp", locale: "en-US"),
LocalizedText(text: "Mi aplicación personalizada", locale: "es-MX")
]
)
// 3. Build the Automation with both configuration and the graph
let myFunctionalAutomation = try AutomationBuilder()
.setName("Motion Activated Light") // a. Set the name
.setClientFeatureGroup("APP_MANAGED_EXECUTION_REPORTED") // b. set the clientFeatureGroup
.setAutomationGraph(automationGraph) // c. Attach the logic graph
.setAppManagedAutomationConfig(automationConfig) // d. Set the automationConfig
.build() // 4. build the automation