HasParts

protocol HasParts : Sendable
extension HasParts : SendableMetatype

An object in the smart home graph that contains functional parts.

  • part(_:)

    Default implementation

    Returns the first instance of the given type if 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
  • parts(_:)

    Default implementation

    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
  • part(_:)

    Extension method

    Returns the first instance of the given type if supported, otherwise returns nil.

    Declaration

    Swift

    func part<T>(_ part: T.Type = T.self) -> T? where T : DeviceType
  • parts(_:)

    Extension method

    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
  • part(_:)

    Extension method

    Returns the first instance of the given type if 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
  • parts(_:)

    Extension method

    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