Structure

struct Structure
extension Structure : AutomationManager, Copyable, Copyable, Equatable, Escapable, Escapable, Hashable, HomeObject, HomeObjectImpl, Identifiable, ObjectDataRepresentable, Sendable, Sendable, Updatable

Represents a structure in the User’s home graph.

  • Undocumented

    Declaration

    Swift

    func atExecutionTime() -> TypedExpression<TypedEntityStructure>
  • Executes a create automation command, expecting a result.

    Declaration

    Swift

    @MainActor
    func createAutomation(_ automation: any DraftAutomation) async throws -> any Automation

    Parameters

    automation

    The DraftAutomation object.

    Return Value

    An Automation object.

  • List automation instances by id.

    Declaration

    Swift

    @MainActor
    func listAutomations() async throws -> [any Automation]

    Return Value

    If success, an array of Automation objects, else an empty array.

  • Undocumented

    Declaration

    Swift

    @MainActor
    func createAutomation(_ automation: any DraftAutomation, enableMultipartDevices: Bool) async throws -> any Automation
  • Undocumented

    Declaration

    Swift

    @MainActor
    func listAutomations(enableMultipartDevices: Bool) async throws -> [any Automation]
  • Delete an automation instance by its ID.

    Declaration

    Swift

    @MainActor
    func deleteAutomation(id: String) async throws
  • Delete an automation object.

    Declaration

    Swift

    @MainActor
    func deleteAutomation(_ automation: any Automation) async throws

    Parameters

    automation

    The Automation object to be deleted.

  • Returns a list of Automation Candidate Nodes in this structure for creating an automation.

    Attention

    Initially the Discovery API is non streaming. The expected usage is:

    let candidates = try await structure.candidates(includeDescendants: false).first()
    

    Declaration

    Swift

    @MainActor
    func candidates(includeDescendants: Bool = true) -> any Query<AnyNodeCandidate>

    Parameters

    includeDescendants

    Whether to include the full candidate tree for all members of this structure.

    Return Value

    A Publisher of the list of candidates.

  • Returns a list of Automation Candidate Nodes for the given device in this structure for creating an automation.

    Attention

    Initially the Discovery API is non streaming. The expected usage is:

    let candidates = try await structure.candidates(for: device).first()
    

    Declaration

    Swift

    @MainActor
    func candidates(for device: HomeDevice) throws -> any Query<AnyNodeCandidate>

    Return Value

    A Publisher of the list of candidates.

  • Likes an automation suggestion.

    Declaration

    Swift

    @MainActor
    func likeSuggestion(suggestionID: String) async throws

    Parameters

    suggestionID

    The ID of the AutomationSuggestion to like.

  • Dislikes an automation suggestion.

    Declaration

    Swift

    @MainActor
    func dislikeSuggestion(suggestionID: String) async throws

    Parameters

    suggestionID

    The ID of the AutomationSuggestion to dislike.

  • Clears the feedback for an automation suggestion.

    Declaration

    Swift

    @MainActor
    func clearSuggestionFeedback(suggestionID: String) async throws

    Parameters

    suggestionID

    The ID of the AutomationSuggestion to clear feedback for.

  • Returns a list of AutomationSuggestion for this structure.

    Suggestions that have been disliked by the user will not be included.

    Declaration

    Swift

    @MainActor
    func suggestions() async throws -> [AutomationSuggestion]
  • Creates a room in the structure with the given name.

    If a room with the same name already exists, the existing room will be returned.

    Declaration

    Swift

    func createRoom(name: String) async throws -> Room
  • Deletes the given room.

    Any devices assigned to the room will be unassigned but they will remain assigned to the structure. If the room does not exist, an error will be thrown.

    Declaration

    Swift

    func deleteRoom(_ room: Room) async throws
  • Deletes the room with the given ID.

    Any devices assigned to the room will be unassigned but they will remain assigned to the structure. If the room does not exist, an error will be thrown.

    Declaration

    Swift

    func deleteRoom(id: String) async throws
  • Moves the given device to the given room.

    Throws an error if the device is not found or if the room does not exist.

    Declaration

    Swift

    func move(device: HomeDevice, to room: Room) async throws
  • Moves the device with the given ID to the room with given ID.

    Throws an error if the device is not found or if the room does not exist.

    Declaration

    Swift

    func move(device deviceID: String, to roomID: String) async throws
  • Moves the given devices to the given room.

    Throws an error if none of the devices are found or if the room does not exist.

    Declaration

    Swift

    func move(devices: any Collection<HomeDevice>, to room: Room) async throws
  • Moves the devices with given IDs to the room with given ID.

    Throws an error if none of the devices are found or if the room does not exist.

    Declaration

    Swift

    func move(devices deviceIDs: any Collection<String>, to roomID: String) async throws
  • Prepares the SDK to accept inbound commissioning requests from the Matter App Extension.

    Note

    This method requires location permissions to be granted. The first time that this is called, the user will be prompted to grant location permissions. On subsequent calls, if location permissions have not been granted, the method will throw a HomeError.failedPrecondition error with a subtype of .permissions(.locationPermissionsRequired). Clients should handle this error by showing the user a message explaining that location permissions are required and how to grant them (e.g. by going to the iOS Settings app and enabling location permissions for the app).

    Throws

    A HomeError if setup fails. Check for the PermissionError.locationPermissionsRequired subtype to handle the case where the user has not granted location permissions.

    Declaration

    Swift

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

    Declaration

    Swift

    func completeMatterCommissioning() async throws -> Set<String>
  • Cancels any ongoing Matter Commissioning attempt before it has been completed.

    Declaration

    Swift

    func cancelMatterCommissioning()
  • Marks the commissioning attempt as failed.

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

    Declaration

    Swift

    func markMatterCommissioningFailed(error: any Error) -> MatterUnsuccessfulCommissioningResult

    Parameters

    error

    The error that caused the Matter Commissioning session to fail if any.

    Return Value

    The summary of the unsuccessful commissioning attempt.

  • Returns the entry point for the Structure History API for this Structure.

    Declaration

    Swift

    var history: HistoryController { get async throws }
  • Instance-level accessor for an object’s HomeObjectType.

    Declaration

    Swift

    let objectType: HomeObjectType
  • id

    Per-Home-unique identifier for this object.

    Declaration

    Swift

    let id: String
  • Undocumented

    Declaration

    Swift

    var name: String { get }
  • The controller object for managing structure scoped permissions.

    Declaration

    Swift

    var permissions: StructureScopedPermissionsController { get }
  • Returns a Boolean value indicating whether two values are equal.

    Equality is the inverse of inequality. For any values a and b, a == b implies that a != b is false.

    Declaration

    Swift

    static func == (lhs: Structure, rhs: Structure) -> Bool

    Parameters

    lhs

    A value to compare.

    rhs

    Another value to compare.

  • Hashes the essential components of this value by feeding them into the given hasher.

    Implement this method to conform to the Hashable protocol. The components used for hashing must be the same as the components compared in your type’s == operator implementation. Call hasher.combine(_:) with each of these components.

    Important

    In your implementation of hash(into:), don’t call finalize() on the hasher instance provided, or replace it with a different instance. Doing so may become a compile-time error in the future.

    Declaration

    Swift

    func hash(into hasher: inout Hasher)
  • Performs an update on this object.

    Declaration

    Swift

    func update(_ block: (any MutableStructureData) -> Void) async throws -> Structure

    Parameters

    block

    - A closure that receives an instance to receive the desired updates.