Trait

protocol Trait : TraitEncodable, CustomStringConvertible, Hashable, Sendable
extension Trait : Equatable

Basic interface for object Traits.

  • List of all event types on the given Trait.

    Currently, only MatterTrait traits support any events, but this will likely expand to other traits in the future.

    Declaration

    Swift

    static var supportedEventTypes: [any Event.Type] { get }
  • List of all commands supported by the Trait’s definition. The commands supported by a specific Trait instance may vary.

    Declaration

    Swift

    static var supportedCommandTypes: [any Command.Type] { get }
  • Metadata about this Trait.

    Declaration

    Swift

    var metadata: TraitMetadata { get }
  • Creates a new Trait instance using data read from the given TraitDecoder.

    Throws

    HomeError.parseError when parsing fails.

    Declaration

    Swift

    init(decoder: TraitDecoder, interactionProxy: (any InteractionProxy)?, metadata: TraitMetadata) throws

    Parameters

    decoder

    The raw data representing this Trait.

    interactionProxy

    Proxy to the Interaction Client.

    metadata

    Metadata about this Trait.

  • attribute(id:)

    Default implementation

    Undocumented

    Default Implementation

    Returns the field corresponding to the given field ID.

    Declaration

    Swift

    static func attribute(id: UInt32) -> (any Field)?
  • description

    Extension method

    Returns a string representation of the Trait as {namespace}.{traitName}.

    Declaration

    Swift

    var description: String { get }