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
. ThrowsHomeError.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
HomeError
s 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
andb
,a == b
implies thata != b
isfalse
.Declaration
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)
-
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 byoptionsOverride
.optionsOverride
If the corresponding bit in
optionsMask
is set to1
, the bit set here overrides the corresponding bit inoptions
attribute. -
The batchable version of moveToLevel command above.
See also
moveToLevelDeclaration
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
optionsMask
Determines which bits in the
options
attribute should be overridden byoptionsOverride
.optionsOverride
If the corresponding bit in
optionsMask
is set to1
, the bit set here overrides the corresponding bit inoptions
attribute. -
The batchable version of move command above.
See also
moveDeclaration
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 acurrentLevel
that is greater than themaxLevel
or less than theminLevel
, then the command stops when thecurrentLevel
reaches themaxLevel
orminLevel
, respectively. The command may complete in a shorter time than specified fortransitionTime
if themaxLevel
orminLevel
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 byoptionsOverride
.optionsOverride
If the corresponding bit in
optionsMask
is set to1
, the bit set here overrides the corresponding bit inoptions
attribute. -
The batchable version of step command above.
See also
stepDeclaration
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 to0
. This command andStopWithOnOff
are identical.Declaration
Swift
func stop(optionsMask: Matter.LevelControlTrait.OptionsBitmap, optionsOverride: Matter.LevelControlTrait.OptionsBitmap) async throws
-
The batchable version of stop command above.
See also
stopDeclaration
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 theOnOff
cluster depending on the end value ofcurrentLevel
. If this command sets thecurrentLevel
above theminLevel
, theonOff
attribute is set to true. If this command sets thecurrentLevel
to theminLevel
, theonOff
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 byoptionsOverride
.optionsOverride
If the corresponding bit in
optionsMask
is set to1
, the bit set here overrides the corresponding bit inoptions
attribute. -
The batchable version of moveToLevelWithOnOff command above.
See also
moveToLevelWithOnOffDeclaration
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 theOnOff
cluster depending on the end value ofcurrentLevel
. If this command sets thecurrentLevel
above theminLevel
, theonOff
attribute is set to true. If this command sets thecurrentLevel
to theminLevel
, theonOff
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
optionsMask
Determines which bits in the
options
attribute should be overridden byoptionsOverride
.optionsOverride
If the corresponding bit in
optionsMask
is set to1
, the bit set here overrides the corresponding bit inoptions
attribute. -
The batchable version of moveWithOnOff command above.
See also
moveWithOnOffDeclaration
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 theOnOff
cluster depending on the end value ofcurrentLevel
. If thestepSize
used results in acurrentLevel
that is greater than themaxLevel
or less than theminLevel
, then the command stops when thecurrentLevel
reaches themaxLevel
orminLevel
, respectively. The command may complete in a shorter time than specified fortransitionTime
if themaxLevel
orminLevel
is reached before the transition time is over. If this command sets thecurrentLevel
above theminLevel
, theonOff
attribute is set to true. If this command sets thecurrentLevel
to theminLevel
, theonOff
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 byoptionsOverride
.optionsOverride
If the corresponding bit in
optionsMask
is set to1
, the bit set here overrides the corresponding bit inoptions
attribute. -
The batchable version of stepWithOnOff command above.
See also
stepWithOnOffDeclaration
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 to0
. This command andStop
are identical.Declaration
Swift
func stopWithOnOff(optionsMask: Matter.LevelControlTrait.OptionsBitmap, optionsOverride: Matter.LevelControlTrait.OptionsBitmap) async throws
-
The batchable version of stopWithOnOff command above.
See also
stopWithOnOffDeclaration
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
moveToClosestFrequencyDeclaration
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