struct OnOffTraitThis trait provides an interface for turning devices on and off.
-
No supported events for
OnOffTrait.Declaration
Swift
static let supportedEventTypes: [any Event.Type] -
List of the commands that are supported by
OnOffTrait.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
OnOffTrait.Declaration
Swift
let attributes: Matter.OnOffTrait.Attributes -
Creates a new Trait instance using data read from the given
TraitDecoder.Throws
HomeError.parseErrorwhen parsing fails.Declaration
Swift
init(decoder: TraitDecoder, interactionProxy: (any InteractionProxy)?, metadata: TraitMetadata) throwsParameters
decoderThe raw data representing this Trait.
interactionProxyProxy to the Interaction Client.
metadataMetadata about this Trait.
-
Writes this object to the given
TraitEncoder. ThrowsHomeError.encodingFailedif 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
OnOffTrait.Declaration
Swift
struct Attributes -
Returns a Boolean value indicating whether two values are equal.
Equality is the inverse of inequality. For any values
aandb,a == bimplies thata != bisfalse.Parameters
lhsA value to compare.
rhsAnother value to compare.
-
Hashes the essential components of this value by feeding them into the given hasher.
Implement this method to conform to the
Hashableprotocol. 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 thehasherinstance 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
offcommand for this trait.Declaration
Swift
var supportsOffCommand: Bool { get } -
Turn off the device, and set the
onOffattribute to false.Declaration
Swift
func off() async throws -
The batchable version of off command above.
See also
offDeclaration
Swift
func offBatchable() throws -> BatchableCommand<Void> -
Whether the device supports the
oncommand for this trait.Declaration
Swift
var supportsOnCommand: Bool { get } -
Turn on the device, and set the
onOffattribute to true.Declaration
Swift
func on() async throws -
The batchable version of on command above.
See also
onDeclaration
Swift
func onBatchable() throws -> BatchableCommand<Void> -
Whether the device supports the
togglecommand for this trait.Declaration
Swift
var supportsToggleCommand: Bool { get } -
The batchable version of toggle command above.
See also
toggleDeclaration
Swift
func toggleBatchable() throws -> BatchableCommand<Void> -
Whether the device supports the
offWithEffectcommand for this trait.Declaration
Swift
var supportsOffWithEffectCommand: Bool { get } -
Allow devices to be turned off using enhanced ways of fading.
Declaration
Swift
func offWithEffect(effectIdentifier: Matter.OnOffTrait.EffectIdentifierEnum, effectVariant: UInt8) async throwsParameters
effectIdentifierThe fading effect to use when turning the device off. Must be a value from [OnOffTrait.EffectIdentifierEnum].
effectVariantVariant of the effect, indicated by the
effectIdentifierparameter, that is triggered. This must be one of the values in [OnOffTrait.DelayedAllOffEffectVariantEnum] or [OnOffTrait.DyingLightEffectVariantEnum] that correspond to the effect specified foreffectIdentifier. -
The batchable version of offWithEffect command above.
See also
offWithEffectDeclaration
Swift
func offWithEffectBatchable(effectIdentifier: Matter.OnOffTrait.EffectIdentifierEnum, effectVariant: UInt8) throws -> BatchableCommand<Void> -
Whether the device supports the
onWithRecallGlobalScenecommand for this trait.Declaration
Swift
var supportsOnWithRecallGlobalSceneCommand: Bool { get } -
Allow the recall of the settings (global scene) the device had when the device was turned off. This command is ignored if the
globalSceneControlattribute is true. If theglobalSceneControlattribute is false, the global scene is recalled, theonOffattribute is updated accordingly, and theglobalSceneControlattribute is set to true. When this command is called, if theonTimeattribute is 0, then theoffWaitTimeattribute is also set to 0.Declaration
Swift
func onWithRecallGlobalScene() async throws -
The batchable version of onWithRecallGlobalScene command above.
See also
onWithRecallGlobalSceneDeclaration
Swift
func onWithRecallGlobalSceneBatchable() throws -> BatchableCommand<Void> -
Whether the device supports the
onWithTimedOffcommand for this trait.Declaration
Swift
var supportsOnWithTimedOffCommand: Bool { get } -
Allow the device to be turned on for a specific duration with a guarded off duration so that, should the device be subsequently turned off, further
OnWithTimedOffcommands received during this time are prevented from turning the devices back on.Declaration
Swift
func onWithTimedOff(onOffControl: Matter.OnOffTrait.OnOffControlBitmap, onTime: UInt16, offWaitTime: UInt16) async throwsParameters
onOffControlWhen set to
1, theonWithTimedOffcommand will only be processed if theonOffattribute istrue. When set to0, theonWithTimedOffcommand is always processed.onTimeThe duration for which device is turned on. Sets the value of the
onTimeattribute.offWaitTimeThe guarded off duration to set for the device. Sets the value of the
offWaitTimeattribute. -
The batchable version of onWithTimedOff command above.
See also
onWithTimedOffDeclaration
Swift
func onWithTimedOffBatchable(onOffControl: Matter.OnOffTrait.OnOffControlBitmap, onTime: UInt16, offWaitTime: UInt16) throws -> BatchableCommand<Void> -
Delayed fading effects for lighting.
Declaration
Swift
enum DelayedAllOffEffectVariantEnum -
Dying effects for lighting.
Declaration
Swift
enum DyingLightEffectVariantEnum -
Fading effect types for use with lighting.
Declaration
Swift
enum EffectIdentifierEnum -
Startup behaviors for a device.
Declaration
Swift
enum StartUpOnOffEnum -
OnOff cluster FeatureMap.
Declaration
Swift
struct Feature -
Flags for cluster control.
Declaration
Swift
struct OnOffControlBitmap