struct Structure
extension Structure : AutomationManager, Copyable, Copyable, Equatable, Escapable, Escapable, Hashable, HomeObject, HomeObjectImpl, Identifiable, ObjectDataRepresentable, Sendable, Updatable
Represents a structure in the User’s home graph.
-
Executes a create Automation command, expecting a result.
Declaration
Swift
@MainActor func createAutomation(_ automation: any DraftAutomation) async throws -> any Automation
Parameters
automation
The Automation 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.
-
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
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
func candidates(for device: HomeDevice) throws -> any Query<AnyNodeCandidate>
Return Value
A Publisher of the list of candidates.
-
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.
Declaration
Swift
@MainActor func prepareForMatterCommissioning() async throws
-
Completes the Matter Commissioning attempt and returns the IDs of the commissioned devices.
Declaration
Swift
func completeMatterCommissioning() throws -> Set<String>
-
Ends any ongoing Matter Commissioning attempt before it has been completed.
Declaration
Swift
func cancelMatterCommissioning(error: (any Error)? = nil) -> MatterUnsuccessfulCommissioningResult
Parameters
error
The error that caused the Matter Commissioning session to fail if any.
Return Value
The summary of the unsuccessful commissioning attempt.
-
Instance-level accessor for an object’s HomeObjectType.
Declaration
Swift
let objectType: HomeObjectType
-
Per-Home-unique identifier for this object.
Declaration
Swift
let id: String
-
Undocumented
Declaration
Swift
var name: String { get }
-
Returns a Boolean value indicating whether two values are equal.
Equality is the inverse of inequality. For any values
a
andb
,a == b
implies thata != b
isfalse
.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. Callhasher.combine(_:)
with each of these components.Important
In your implementation of
hash(into:)
, don’t callfinalize()
on thehasher
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.