protocol HasParts : Sendableextension HasParts : SendableMetatypeAn object in the smart home graph that contains functional parts.
-
Default implementationpart(_:)
Returns the first instance of the given
typeif the entity supports it, otherwise returns nil.Throws
An error if retrieving or communicating with the underlying parts fails.Default Implementation
Default implementation for entities that do not support parts, returning nil.
Declaration
Swift
func part<T>(_ part: T.Type) async throws -> T? where T : DeviceType -
Default implementationparts(_:)
Returns an array of the top-level parts matching the given
type.Throws
An error if retrieving or communicating with the underlying parts fails.Default Implementation
Default implementation for entities that do not support parts, returning an empty array.
Declaration
Swift
func parts<T>(_ part: T.Type) async throws -> [T] where T : DeviceType -
Extension methodpart(_:)
Returns the first instance of the given
typeif supported, otherwise returns nil.Declaration
Swift
func part<T>(_ part: T.Type = T.self) -> T? where T : DeviceType -
Extension methodparts(_:)
Returns an array of the top-level parts matching the given
type.Declaration
Swift
func parts<T>(_ part: T.Type = T.self) -> [T] where T : DeviceType -
Extension methodpart(_:)
Returns the first instance of the given
typeif the entity supports it, otherwise returns nil.Throws
An error if retrieving or communicating with the underlying parts fails.Declaration
Swift
func part<T>(_ part: T.Type = T.self) async throws -> T? where T : DeviceType -
Extension methodparts(_:)
Returns an array of the top-level parts matching the given
type.Throws
An error if retrieving or communicating with the underlying parts fails.Declaration
Swift
func parts<T>(_ part: T.Type = T.self) async throws -> [T] where T : DeviceType