final class Homeextension Home : SendableTop-level entry to the GoogleHomeSDK.
-
Configure App-specific parameters of the GoogleHomeSDK.
This method should be called before any other Home API method. By default, the configuration is read from the Info.plist.
Declaration
Swift
@MainActor static func configure(_ block: (inout HomeClientConfiguration) -> Void)Parameters
blockThe configuration block.
-
Creates a new
Home` instance connected to the user’s account.Declaration
Swift
@MainActor static func connect() async throws -> HomeReturn Value
A
Homeinstance. -
Restores a previous session and returns a
Homeinstance connected to the user’s account.If a session is not found, this method will return nil.
Declaration
Swift
@MainActor static func restoreSession() async -> Home?Return Value
A
Homeinstance. -
Disconnects the
Homeinstance from the user’s account.Declaration
Swift
func disconnect() async -
Starts a new commands batch, sends it and asynchronously waits for the response.
Declaration
Swift
@MainActor func sendBatchedCommands<T>(_ block: (CommandBatcher) throws -> T) async throws -> TParameters
blockA closure that can add commands to the batch and return a result.
Return Value
The result of the batch command execution.
-
Alias for
openWebViewhandler onstartHubActivation().Declaration
Swift
typealias OpenWebViewHandler = @MainActor (URL, String) async throws -> Void -
Discovers available hubs and returns latest result after a given duration.
Declaration
Parameters
durationContinues to discover until this duration has passed as long as
shouldContinuereturnstrue. Default is 3 seconds.shouldContinueA handler will be called every time mDNS discovery receives updates. Default is a handler that always returns
true. if the handler returnsfalse, the discovery will be stopped and returns latest discovered hubs immediately.Return Value
A set of hubs that are available.
-
Starts hub activation with the given hub.
Declaration
Swift
func startHubActivation(_ hub: Hub, structureID: String? = nil, additionalQueryItems items: [URLQueryItem] = [], openWebView: Home.OpenWebViewHandler? = nil) async throwsParameters
hubThe hub to be used for commissioning.
structureIDThe ID of the structure to add the hub to. Default is
niland if it’s nil web page will show the structure list to let user choose a structure.additionalQueryItemsAll parameters will be added to the URL to be opened by web view. Default is an empty.
openWebViewA handler that opens a web view with the given URL and returns after the web view is closed. Default is
nil. If this handler isnil, the web page will be opened usingASWebAuthenticationSession. ThecallbackURLSchemeparameter will be redirected by the web page, allowing the caller to close the web view. -
Presents a view for users to update the permissions granted to the Home SDK.
If the active user is signed into Safari, the permissions view will be presented for that user. Otherwise, the user will be prompted to select an account or sign in.
Declaration
Swift
@MainActor func presentPermissionsUpdate() -
The version of the SDK; follows the Semantic Versioning 2.0 standard.
Declaration
Swift
@available(*, deprecated, message: "Use 'Home.version' instead for clarity.") static var sdkVersion: String { get } -
Version information about the SDK.
Declaration
Swift
static let version: Home.Version -
Version information about the SDK.
Declaration
Swift
struct Versionextension Home.Version : CustomDebugStringConvertible, CustomStringConvertible, Sendable -
The unique identifier for this
Homeinstance, stable across all sessions.Declaration
Swift
var identifier: String { get } -
Query all devices visible to this account.
Declaration
Swift
func devices() -> some Query<HomeDevice> -
Returns a Publisher for a specified device that emits the current state and again on any future state updates.
Declaration
Swift
func device(id: String) -> some Publisher<HomeDevice, HomeError>