final class Home
extension Home : Sendable
Top-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
block
The configuration block.
-
Creates a new
Home
` instance connected to the user’s account.Declaration
Swift
@MainActor static func connect() async throws -> Home
Return Value
A
Home
instance. -
Restores a previous session and returns a
Home
instance 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
Home
instance. -
Disconnects the
Home
instance 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 -> T
Parameters
block
A closure that can add commands to the batch and return a result.
Return Value
The result of the batch command execution.
-
Alias for
openWebView
handler onstartHubActivation()
.Declaration
Swift
typealias OpenWebViewHandler = @MainActor (URL, String) async throws -> Void
-
Discovers available hubs and returns latest result after a given duration.
Declaration
Parameters
duration
Continues to discover until this duration has passed as long as
shouldContinue
returnstrue
. Default is 3 seconds.shouldContinue
A 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 throws
Parameters
hub
The hub to be used for commissioning.
structureID
The ID of the structure to add the hub to. Default is
nil
and if it’s nil web page will show the structure list to let user choose a structure.additionalQueryItems
All parameters will be added to the URL to be opened by web view. Default is an empty.
openWebView
A 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
. ThecallbackURLScheme
parameter 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 Version
extension Home.Version : CustomDebugStringConvertible, CustomStringConvertible, Sendable
-
The unique identifier for this
Home
instance, 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>