アプリ管理の自動化は、パートナー アプリが Automation API を使用してプログラムで構築する自動化です。
このような自動化は、Google Home app (GHA) 自動化リストに表示されません。
アプリ管理の自動化がトリガーされたときに Google Home API のアクティビティ フィードに書き込まれる情報は、カスタマイズできます。たとえば、パートナーがアプリ管理の自動化を使用して実装された「Arctic」というブランド サービスを提供している場合、アプリ管理の自動化が実行されると、実際の自動化名の代わりに Arctic サービスがアクティビティ フィードで参照されるように指定できます。
アプリで管理される自動化を作成する
アプリ管理の自動化を作成する手順は次のとおりです。
自動化のロジックグラフを作成します。
アクティビティ フィードに表示される自動化のアクティビティをカスタマイズするには、自動化名の代わりにフィードに表示するローカライズされたメッセージを
AppManagedAutomationConfigインスタンスに入力します。これは、アプリやサービスのローカライズされた名前や、任意のメッセージにすることができます。ローカライズされた文字列を指定しない場合、自動化の実行は他の自動化と同様にログに記録されます。最適なユーザー エクスペリエンスを実現するために、これらのローカライズされた文字列を設定することをおすすめします。let automationConfig = AppManagedAutomationConfig( managingAppDisplayNames: [ LocalizedText(text: "My Custom SmartApp", locale: "en-US"), LocalizedText(text: "Mi aplicación personalizada", locale: "es-MX") ] )Automation.Builderを使用して自動化インスタンスを作成します。- 自動化の
nameを設定します。 client_feature_groupを"APP_MANAGED_EXECUTION_REPORTED"に設定して、自動化の実行履歴が GHA の [アクティビティ] タブに表示されるようにします。automationGraphを設定します。- 省略可: 自動化の
appManagedAutomationConfigを設定します(ステップ 2 を参照)。
- 自動化の
最後に、
build()を呼び出してAutomationインスタンスをビルドします。
この例では、手順全体を示します。
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