This is the default server implementation of OnOffBehavior.

This implementation includes all features of OnOff.Cluster and automatically enables the "Level Control for Lighting" Feature. You should use OnOffServer.with to specialize the class for the features your implementation supports. Alternatively you can extend this class and override the methods you need to change or add mandatory commands.

The "OffOnly" feature is automatically supported because the commands are disabled by conformance. The default implementation do not contain any logic for the DeadFrontBehavior feature because this is very use case specific, so this needs to be implemented by the device implementor as needed.

Hierarchy

  • Base
    • OnOffServer

Constructors

  • Parameters

    • agent: Agent
    • backing: BehaviorBacking

    Returns OnOffServer

Properties

[reference]: Datasource<StateType>
agent: Agent
cluster: never

The implemented cluster.

context: ActionContext
endpoint: Endpoint<Empty>
events: EventEmitter & Omit<ClusterEvents<OnOff.Cluster, Type<Of<{
    attributes: {};
    commands: {};
    events: {};
    id: 0;
    name: "Unknown";
    revision: 0;
}>, typeof ClusterBehavior, OnOffInterface>>, "onOff$Changing" | "onOff$Changed"> & {
    globalSceneControl$Changing: ClusterEvents.AttributeObservable<Attribute<boolean, any>>;
    offWaitTime$Changing: ClusterEvents.AttributeObservable<WritableAttribute<number, any>>;
    onOff$Changing: ClusterEvents.AttributeObservable<Attribute<boolean, any>>;
    onTime$Changing: ClusterEvents.AttributeObservable<WritableAttribute<number, any>>;
    startUpOnOff$Changing: ClusterEvents.AttributeObservable<WritableAttribute<null | OnOff.StartUpOnOff, any>>;
} & {} & {
    globalSceneControl$Changed: ClusterEvents.AttributeObservable<Attribute<boolean, any>>;
    offWaitTime$Changed: ClusterEvents.AttributeObservable<WritableAttribute<number, any>>;
    onOff$Changed: ClusterEvents.AttributeObservable<Attribute<boolean, any>>;
    onTime$Changed: ClusterEvents.AttributeObservable<WritableAttribute<number, any>>;
    startUpOnOff$Changed: ClusterEvents.AttributeObservable<WritableAttribute<null | OnOff.StartUpOnOff, any>>;
} & {} & {} & {}

Access the behavior's events.

features: TypeFromBitSchema<{}> & TypeFromBitSchema<{
    deadFrontBehavior: BitFlag;
    lighting: BitFlag;
    offOnly: BitFlag;
}> & TypeFromBitSchema<{
    deadFrontBehavior: BitFlag;
    lighting: BitFlag;
    offOnly: BitFlag;
}>

Supported features as a flag object.

internal: Internal
session: SecureSession
state: Omit<ClusterState.Type<OnOff.Cluster, Type<Of<{
    attributes: {};
    commands: {};
    events: {};
    id: 0;
    name: "Unknown";
    revision: 0;
}>, typeof ClusterBehavior, OnOffInterface>>, "onOff"> & {
    globalSceneControl: boolean;
    offWaitTime: number;
    onOff: boolean;
    onTime: number;
    startUpOnOff: null | OnOff.StartUpOnOff;
} & {} & {} & {}

Access the behavior's state.

Type declaration

  • ReadonlyglobalSceneControl: boolean

    In order to support the use case where the user gets back the last setting of a set of devices (e.g. level settings for lights), a global scene is introduced which is stored when the devices are turned off and recalled when the devices are turned on. The global scene is defined as the scene that is stored with group identifier 0 and scene identifier 0.

    This attribute is defined in order to prevent a second Off command storing the all-devices-off situation as a global scene, and to prevent a second On command destroying the current settings by going back to the global scene.

    This attribute shall be set to TRUE after the reception of a command which causes the OnOff attribute to be set to TRUE, such as a standard On command, a MoveToLevel(WithOnOff) command, a RecallScene command or a OnWithRecallGlobalScene command.

    This attribute is set to FALSE after reception of a OffWithEffect command.

    MatterSpecification.v13.Cluster § 1.5.6.3

  • ReadonlyoffWaitTime: number

    This attribute specifies the length of time (in 1/10ths second) that the Off state shall be guarded to prevent another OnWithTimedOff command turning the server back to its On state (e.g., when leaving a room, the lights are turned off but an occupancy sensor detects the leaving person and attempts to turn the lights back on). This attribute can be written at any time, but writing a value only has an effect when in the Timed On state followed by a transition to the Delayed Off state, or in the Delayed Off state. See OnWithTimedOff for more details.

    MatterSpecification.v13.Cluster § 1.5.6.5

  • ReadonlyonOff: boolean

    This attribute indicates whether the device type implemented on the endpoint is turned off or turned on, in these cases the value of the OnOff attribute equals FALSE, or TRUE respectively.

    MatterSpecification.v13.Cluster § 1.5.6.2

  • ReadonlyonTime: number

    This attribute specifies the length of time (in 1/10ths second) that the On state shall be maintained before automatically transitioning to the Off state when using the OnWithTimedOff command. This attribute can be written at any time, but writing a value only has effect when in the Timed On state. See OnWithTimedOff for more details.

    MatterSpecification.v13.Cluster § 1.5.6.4

  • ReadonlystartUpOnOff: null | OnOff.StartUpOnOff

    This attribute shall define the desired startup behavior of a device when it is supplied with power and this state shall be reflected in the OnOff attribute. If the value is null, the OnOff attribute is set to its previous value. Otherwise, the behavior is defined in the table defining StartUpOnOffEnum.

    This behavior does not apply to reboots associated with OTA. After an OTA restart, the OnOff attribute shall return to its value prior to the restart.

    MatterSpecification.v13.Cluster § 1.5.6.6

cluster: WithFeatures<OnOff.Cluster, readonly [Lighting]>

Base cluster state include all attribute values but may be extended by subclasses.

defaults: ClusterState.Type<WithFeatures<OnOff.Cluster, readonly [Lighting]>, Type<OnOff.Cluster, Type<Of<{
    attributes: {};
    commands: {};
    events: {};
    id: 0;
    name: "Unknown";
    revision: 0;
}>, typeof ClusterBehavior, OnOffInterface>, OnOffInterface>>
dependencies?: Iterable<Type, any, any>
early: boolean
Events: ClusterEvents.Type<WithFeatures<OnOff.Cluster, readonly [Lighting]>, Type<OnOff.Cluster, Type<Of<{
    attributes: {};
    commands: {};
    events: {};
    id: 0;
    name: "Unknown";
    revision: 0;
}>, typeof ClusterBehavior, OnOffInterface>, OnOffInterface>>
ExtensionInterface: {}
id

The behavior ID for ClusterBehaviors is the name of the cluster.

Interface: OnOffInterface
name: string
schema?: Schema
State: (new () => ClusterState.Type<WithFeatures<OnOff.Cluster, readonly [Lighting]>, Type<OnOff.Cluster, Type<Of<{
    attributes: {};
    commands: {};
    events: {};
    id: 0;
    name: "Unknown";
    revision: 0;
}>, typeof ClusterBehavior, OnOffInterface>, OnOffInterface>>)
supervisor: RootSupervisor
supports: ((other: Type) => boolean)

Type declaration

    • (other): boolean
    • Does this behavior support functionality of a specific implementation?

      Parameters

      Returns boolean

Accessors

  • get delayedOffTimer(): Timer
  • Returns Timer

  • get timedOnTimer(): Timer
  • Returns Timer

Methods

  • Returns Promise<void>

  • Execute logic with elevated privileges.

    The provided function executes with privileges escalated to offline mode. This is not commonly necessary.

    Elevated logic effectively ignores ACLs so should be used with care.

    Note that interactions with the behavior will remain elevated until the synchronous completion of this call. You should only elevate privileges for synchronous logic.

    Parameters

    • fn: (() => void)

      the elevated logic

        • (): void
        • Returns void

    Returns void

  • Type Parameters

    • This extends Behavior
    • K extends string | number | symbol

    Parameters

    • this: This
    • attributeName: K

    Returns void

  • Create a generic callback function that has the same properties as a Reactor.

    Like a reactor, the callback's "this" will be bound to an active Behavior instance. Because of this: The reactor MUST be a real JS function - arrow functions will not work!

    Type Parameters

    • A extends any[]
    • R

    Parameters

    Returns ((...args: A) => undefined | R)

      • (...args): undefined | R
      • Parameters

        • Rest...args: A

        Returns undefined | R

  • Behaviors are ephemeral and should not perform initialization in their constructor. They can override this method instead.

    This method may be synchronous or asyncronous. If asynchronous, the behavior will not be available for external use until initialization completes.

    Returns void

  • Returns MaybePromise<void>

    MatterSpecification.v13.Cluster § 1.5.7.1

  • Default implementation notes:

    • This implementation ignores the effect and just calls off().
    • Global Scene Control is not supported yet.

    Returns MaybePromise<void>

  • Returns MaybePromise<void>

    MatterSpecification.v13.Cluster § 1.5.7.2

  • Default implementation notes:

    • Global Scene Control is not supported yet, so the device is just turned on.

    Returns MaybePromise<void>

  • Default implementation notes:

    • This method uses the on/off methods when timed actions should occur. This means that it is enough to override on() and off() with custom control logic.

    Parameters

    Returns MaybePromise<void>

  • Install a Reactor.

    Important: The reactor MUST be a real JS function - arrow functions will not work!

    Type Parameters

    Parameters

    Returns void

  • Type Parameters

    • This extends Behavior
    • K extends string | number | symbol

    Parameters

    • this: This
    • attributeName: K

    Returns Exclude<This["state"][K], undefined>

  • Default implementation notes: This method uses the on/off methods when timed actions should occur. This means that it is enough to override on() and off() with custom control logic.

    Returns MaybePromise<void>

  • Description used in diagnostic messages.

    Returns string

  • Type Parameters

    Parameters

    Returns This