Home

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.

  • 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.

    The API exposed by this class is experimental and is subject to change.

    Declaration

    Swift

    @_spi(Unknown)
    @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.

  • Enters a state ready to accept inbound requests to commission a Matter device from the iGHP Matter Commissioning SDK in an iOS Matter App Extension.

    This must be called prior to starting the MatterSupport.MatterAddDeviceRequest or the HomeMatterCommissioner will fail in the Matter Commissioning App Extension.

    Throws

    A HomeError if an existing commissioning session is currently in progress (after any previous commissioning attempt either completeMatterCommissioning or cancelMatterCommissioning must be called).

    Declaration

    Swift

    @MainActor
    func prepareForMatterCommissioning(structureID: String) async throws
  • Completes the active Matter Commissioning attempt and returns the IDs of the newly commissioned devices.

    Note

    The returned device IDs are not guaranteed to be accessible by the calling 3P app. If the user attempted to commission a device type that is not supported by the 3P app’s current set of permissions, the device will be commissioned into the user’s Google Home, but will not be visible or controllable by the 3P app.

    Currently, there will NOT be an error returned in this case. The only way to detect this condition is to check whether the returned list of device IDs are visible in the list of devices returned by the devices query.

    In this case, the 3P app may attempt recovery by calling presentPermissionsUpdate to allow the user to grant additional permissions – if the 3P app is indeed registered for the missing device type.

    Throws

    A HomeError if there is no ongoing commissioning session or if the commissioning session did not complete successfully this will throw the error that caused the Matter Commissioning session to fail.

    Declaration

    Swift

    func completeMatterCommissioning() throws -> Set<String>
  • Cancels any ongoing Matter Commissioning attempt.

    This should be called if MatterSupport’s MatterAddDeviceRequest throws an error.

    Declaration

    Swift

    func cancelMatterCommissioning(error: (any Error)? = nil) -> MatterUnsuccessfulCommissioningResult

    Parameters

    error

    The error that caused the Matter Commissioning session to fail.

    Return Value

    The summary of the unsuccessful commissioning attempt.

  • 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

    static var sdkVersion: String { get }
  • The unique identifier for this Home instance, stable across all sessions.

    Declaration

    Swift

    let identifier: String
  • 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>
    
  • Query all structures visible to this account.

    Declaration

    Swift

    func structures() -> some Query<Structure>
    
  • future state updates.

    Declaration

    Swift

    func structure(id: String) -> some Publisher<Structure, HomeError>
    
  • Query all rooms visible to this account.

    Declaration

    Swift

    func rooms() -> some Query<Room>
    
  • Returns a Publisher for a specified room that emits the current state and again on any future state updates.

    Declaration

    Swift

    func room(id: String) -> some Publisher<Room, HomeError>