LevelControlTrait

struct LevelControlTrait

This trait provides an interface for controlling a characteristic of a device that can be set to a level.

  • No supported events for LevelControlTrait.

    Declaration

    Swift

    static let supportedEventTypes: [any Event.Type]
  • List of the commands that are supported by LevelControlTrait.

    Declaration

    Swift

    static let supportedCommandTypes: [any Command.Type]
  • The trait identifier.

    Declaration

    Swift

    static let identifier: String
  • Metadata about this Trait.

    Declaration

    Swift

    let metadata: TraitMetadata
  • List of attributes for the LevelControlTrait.

    Declaration

    Swift

    let attributes: Matter.LevelControlTrait.Attributes
  • 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.

  • Writes this object to the given TraitEncoder. Throws HomeError.encodingFailed if the data could not be encoded.

    Declaration

    Swift

    func encode(with encoder: TraitEncoder) throws
  • This API provides the ability to invalidate state retrieved through subscriptions to the target device in the cases where state is not being reported correctly, either intentionally (e.g attributes in Matter traits with the “C” quality) or unintentionally due to poor implementations.

    When successful, this API will result in a forced read of the convening scope as specified by the sub-class and return the result through existing Trait subscriptions if present and active.

    This API is to be used sparingly as it can impact the performance and battery life of the target device. As such, this API may be throttled by the platform. Callers SHALL be prepared to deal with HomeErrors thrown by this call.

    Declaration

    Swift

    func forceRead() async throws
  • Attributes for the LevelControlTrait.

    Declaration

    Swift

    struct Attributes
  • 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: Matter.LevelControlTrait, rhs: Matter.LevelControlTrait) -> 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)
  • Whether the device supports the moveToLevel command for this trait.

    Declaration

    Swift

    var supportsMoveToLevelCommand: Bool { get }
  • Move a device from its current level to the provided level.

    Declaration

    Swift

    func moveToLevel(level: UInt8, transitionTime: UInt16?, optionsMask: Matter.LevelControlTrait.OptionsBitmap, optionsOverride: Matter.LevelControlTrait.OptionsBitmap) async throws

    Parameters

    level

    The level to move the device to.

    transitionTime

    The time (in 0.1 seconds) taken to move the device to the new level.

    optionsMask

    Determines which bits in the options attribute should be overridden by optionsOverride.

    optionsOverride

    If the corresponding bit in optionsMask is set to 1, the bit set here overrides the corresponding bit in options attribute.

  • The batchable version of moveToLevel command above.

    See also

    moveToLevel

    Declaration

    Swift

    func moveToLevelBatchable(level: UInt8, transitionTime: UInt16?, optionsMask: Matter.LevelControlTrait.OptionsBitmap, optionsOverride: Matter.LevelControlTrait.OptionsBitmap) throws -> BatchableCommand<Void>
  • Whether the device supports the move command for this trait.

    Declaration

    Swift

    var supportsMoveCommand: Bool { get }
  • Change a device’s level based on a rate of movement.

    Declaration

    Swift

    func move(moveMode: Matter.LevelControlTrait.MoveModeEnum, rate: UInt8?, optionsMask: Matter.LevelControlTrait.OptionsBitmap, optionsOverride: Matter.LevelControlTrait.OptionsBitmap) async throws

    Parameters

    moveMode

    The direction in which to move the level. This must be one of the values in [LevelControlTrait.MoveModeEnum].

    rate

    The rate (in units per seconds) used to move the device’s currentLevel to the minLevel or maxLevel.

    optionsMask

    Determines which bits in the options attribute should be overridden by optionsOverride.

    optionsOverride

    If the corresponding bit in optionsMask is set to 1, the bit set here overrides the corresponding bit in options attribute.

  • The batchable version of move command above.

    See also

    move

    Declaration

    Swift

    func moveBatchable(moveMode: Matter.LevelControlTrait.MoveModeEnum, rate: UInt8?, optionsMask: Matter.LevelControlTrait.OptionsBitmap, optionsOverride: Matter.LevelControlTrait.OptionsBitmap) throws -> BatchableCommand<Void>
  • Whether the device supports the step command for this trait.

    Declaration

    Swift

    var supportsStepCommand: Bool { get }
  • Move a device’s level a specific amount over a period of time. If the stepSize used results in a currentLevel that is greater than the maxLevel or less than the minLevel, then the command stops when the currentLevel reaches the maxLevel or minLevel, respectively. The command may complete in a shorter time than specified for transitionTime if the maxLevel or minLevel is reached before the transition time is over.

    Declaration

    Swift

    func step(stepMode: Matter.LevelControlTrait.StepModeEnum, stepSize: UInt8, transitionTime: UInt16?, optionsMask: Matter.LevelControlTrait.OptionsBitmap, optionsOverride: Matter.LevelControlTrait.OptionsBitmap) async throws

    Parameters

    stepMode

    The direction in which to move the level. This must be one of the values in [LevelControlTrait.StepModeEnum].

    stepSize

    The amount of units to move the device’s currentLevel to.

    transitionTime

    The time (in 0.1 seconds) taken to move the device to the new level.

    optionsMask

    Determines which bits in the options attribute should be overridden by optionsOverride.

    optionsOverride

    If the corresponding bit in optionsMask is set to 1, the bit set here overrides the corresponding bit in options attribute.

  • The batchable version of step command above.

    See also

    step

    Declaration

    Swift

    func stepBatchable(stepMode: Matter.LevelControlTrait.StepModeEnum, stepSize: UInt8, transitionTime: UInt16?, optionsMask: Matter.LevelControlTrait.OptionsBitmap, optionsOverride: Matter.LevelControlTrait.OptionsBitmap) throws -> BatchableCommand<Void>
  • Whether the device supports the stop command for this trait.

    Declaration

    Swift

    var supportsStopCommand: Bool { get }
  • Terminate a Move, MoveToLevel, or Step command (including their OnOff variants) currently in progress, and sets the remainingTime attribute to 0. This command and StopWithOnOff are identical.

    Declaration

    Swift

    func stop(optionsMask: Matter.LevelControlTrait.OptionsBitmap, optionsOverride: Matter.LevelControlTrait.OptionsBitmap) async throws

    Parameters

    optionsMask

    Determines which bits in the options attribute should be overridden by optionsOverride.

    optionsOverride

    If the corresponding bit in optionsMask is set to 1, the bit set here overrides the corresponding bit in options attribute.

  • The batchable version of stop command above.

    See also

    stop

    Declaration

    Swift

    func stopBatchable(optionsMask: Matter.LevelControlTrait.OptionsBitmap, optionsOverride: Matter.LevelControlTrait.OptionsBitmap) throws -> BatchableCommand<Void>
  • Whether the device supports the moveToLevelWithOnOff command for this trait.

    Declaration

    Swift

    var supportsMoveToLevelWithOnOffCommand: Bool { get }
  • Move a device from its current level to the provided level and toggle the onOff attribute of the OnOff cluster depending on the end value of currentLevel. If this command sets the currentLevel above the minLevel, the onOff attribute is set to true. If this command sets the currentLevel to the minLevel, the onOff attribute is set to false.

    Declaration

    Swift

    func moveToLevelWithOnOff(level: UInt8, transitionTime: UInt16?, optionsMask: Matter.LevelControlTrait.OptionsBitmap, optionsOverride: Matter.LevelControlTrait.OptionsBitmap) async throws

    Parameters

    level

    The level to move the device to.

    transitionTime

    The time (in 0.1 seconds) taken to move the device to the new level.

    optionsMask

    Determines which bits in the options attribute should be overridden by optionsOverride.

    optionsOverride

    If the corresponding bit in optionsMask is set to 1, the bit set here overrides the corresponding bit in options attribute.

  • The batchable version of moveToLevelWithOnOff command above.

    See also

    moveToLevelWithOnOff

    Declaration

    Swift

    func moveToLevelWithOnOffBatchable(level: UInt8, transitionTime: UInt16?, optionsMask: Matter.LevelControlTrait.OptionsBitmap, optionsOverride: Matter.LevelControlTrait.OptionsBitmap) throws -> BatchableCommand<Void>
  • Whether the device supports the moveWithOnOff command for this trait.

    Declaration

    Swift

    var supportsMoveWithOnOffCommand: Bool { get }
  • Move a device’s level based on a rate of movement and toggle the onOff attribute of the OnOff cluster depending on the end value of currentLevel. If this command sets the currentLevel above the minLevel, the onOff attribute is set to true. If this command sets the currentLevel to the minLevel, the onOff attribute is set to false.

    Declaration

    Swift

    func moveWithOnOff(moveMode: Matter.LevelControlTrait.MoveModeEnum, rate: UInt8?, optionsMask: Matter.LevelControlTrait.OptionsBitmap, optionsOverride: Matter.LevelControlTrait.OptionsBitmap) async throws

    Parameters

    moveMode

    The direction in which to move the level. This must be one of the values in [LevelControlTrait.MoveModeEnum].

    rate

    The rate (in units per seconds) used to move the device’s currentLevel to the minLevel or maxLevel.

    optionsMask

    Determines which bits in the options attribute should be overridden by optionsOverride.

    optionsOverride

    If the corresponding bit in optionsMask is set to 1, the bit set here overrides the corresponding bit in options attribute.

  • The batchable version of moveWithOnOff command above.

    See also

    moveWithOnOff

    Declaration

    Swift

    func moveWithOnOffBatchable(moveMode: Matter.LevelControlTrait.MoveModeEnum, rate: UInt8?, optionsMask: Matter.LevelControlTrait.OptionsBitmap, optionsOverride: Matter.LevelControlTrait.OptionsBitmap) throws -> BatchableCommand<Void>
  • Whether the device supports the stepWithOnOff command for this trait.

    Declaration

    Swift

    var supportsStepWithOnOffCommand: Bool { get }
  • Move a device’s level a specific amount over a period of time and toggle the onOff attribute of the OnOff cluster depending on the end value of currentLevel. If the stepSize used results in a currentLevel that is greater than the maxLevel or less than the minLevel, then the command stops when the currentLevel reaches the maxLevel or minLevel, respectively. The command may complete in a shorter time than specified for transitionTime if the maxLevel or minLevel is reached before the transition time is over. If this command sets the currentLevel above the minLevel, the onOff attribute is set to true. If this command sets the currentLevel to the minLevel, the onOff attribute is set to false.

    Declaration

    Swift

    func stepWithOnOff(stepMode: Matter.LevelControlTrait.StepModeEnum, stepSize: UInt8, transitionTime: UInt16?, optionsMask: Matter.LevelControlTrait.OptionsBitmap, optionsOverride: Matter.LevelControlTrait.OptionsBitmap) async throws

    Parameters

    stepMode

    The direction in which to move the level. This must be one of the values in [LevelControlTrait.StepModeEnum].

    stepSize

    The amount of units to move the device’s currentLevel to.

    transitionTime

    The time (in 0.1 seconds) taken to move the device to the new level.

    optionsMask

    Determines which bits in the options attribute should be overridden by optionsOverride.

    optionsOverride

    If the corresponding bit in optionsMask is set to 1, the bit set here overrides the corresponding bit in options attribute.

  • The batchable version of stepWithOnOff command above.

    See also

    stepWithOnOff

    Declaration

    Swift

    func stepWithOnOffBatchable(stepMode: Matter.LevelControlTrait.StepModeEnum, stepSize: UInt8, transitionTime: UInt16?, optionsMask: Matter.LevelControlTrait.OptionsBitmap, optionsOverride: Matter.LevelControlTrait.OptionsBitmap) throws -> BatchableCommand<Void>
  • Whether the device supports the stopWithOnOff command for this trait.

    Declaration

    Swift

    var supportsStopWithOnOffCommand: Bool { get }
  • Terminate a Move, MoveToLevel, or Step command (including their OnOff variants) currently in progress, and sets the remainingTime attribute to 0. This command and Stop are identical.

    Declaration

    Swift

    func stopWithOnOff(optionsMask: Matter.LevelControlTrait.OptionsBitmap, optionsOverride: Matter.LevelControlTrait.OptionsBitmap) async throws

    Parameters

    optionsMask

    Determines which bits in the options attribute should be overridden by optionsOverride.

    optionsOverride

    If the corresponding bit in optionsMask is set to 1, the bit set here overrides the corresponding bit in options attribute.

  • The batchable version of stopWithOnOff command above.

    See also

    stopWithOnOff

    Declaration

    Swift

    func stopWithOnOffBatchable(optionsMask: Matter.LevelControlTrait.OptionsBitmap, optionsOverride: Matter.LevelControlTrait.OptionsBitmap) throws -> BatchableCommand<Void>
  • Whether the device supports the moveToClosestFrequency command for this trait.

    Declaration

    Swift

    var supportsMoveToClosestFrequencyCommand: Bool { get }
  • Change a device’s current frequency.

    Declaration

    Swift

    func moveToClosestFrequency(frequency: UInt16) async throws

    Parameters

    frequency

    The frequency to change the currentFrequency to.

  • The batchable version of moveToClosestFrequency command above.

    See also

    moveToClosestFrequency

    Declaration

    Swift

    func moveToClosestFrequencyBatchable(frequency: UInt16) throws -> BatchableCommand<Void>
  • The direction in which to move a device’s level.

    Declaration

    Swift

    enum MoveModeEnum
  • The direction in which to step a device’s level.

    Declaration

    Swift

    enum StepModeEnum
  • LevelControl cluster FeatureMap. Some behaviors of these features are described in the cluster attributes and commands. For complete details of these features, see the Matter Specification.

    Declaration

    Swift

    struct Feature
  • Flags for LevelControl options.

    Declaration

    Swift

    struct OptionsBitmap