The implemented cluster.
Readonly
eventsAccess the behavior's events.
Supported features as a flag object.
Protected
internalAccess the behavior's state.
Static
Readonly
clusterBase cluster state include all attribute values but may be extended by subclasses.
Static
Readonly
defaultsStatic
Optional
Readonly
dependenciesStatic
Readonly
earlyStatic
Readonly
EventsStatic
Readonly
idThe behavior ID for ClusterBehaviors is the name of the cluster.
Static
Readonly
InterfaceStatic
Readonly
nameStatic
Optional
Readonly
schemaStatic
Readonly
supervisorStatic
supportsDoes this behavior support functionality of a specific implementation?
The current level value as number. Throws an StatusResponse Error when null!
Returns the maximum level, including feature specific fallback value handling.
Returns the minimum level, including feature specific fallback value handling.
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.
the elevated logic
Protected
callbackCreate 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!
Protected
handleProtected
This is the default implementation of the required interaction with the OnOff cluster on the same endpoint when the onOff feature is used. This implementation just sets the current level to the onLevel value when the device is turned on. Other fading up/down logic required by the MatterSpecification.v12.Cluster §1.6.4.1.1 needs to be implemented in a specialized class if needed.
The new onOff state
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.
Default implementation notes: After the options checks it uses the moveLogic method to set the level. If you want to implement own logic just override moveLogic with is also used for moveWithOnOff. The logic is implemented as follows: When no move rate is provided and also no default move rate is set, the server will move as fast as possible, so we set to min/max directly. Else the step logic is applied and the level is increased or decreased by the step size every second.
Protected
moveProtected
Default implementation of the move logic. When no move rate is provided and also no default move rate is set, the server will move as fast as possible, so it is set to min/max directly. Else the step logic is applied and the level is increased or decreased by the step size every second. The method uses setLevel to set the level and handle the on/off state if the method is called by a *WithOnOff command.
Mode (Up/Down) of the move action
Rate of the move action, null if no rate is provided and the default should be used
true if the method is called by a *WithOnOff command
Optional
options: TypeFromPartialBitSchema<{ Options for the command
Default implementation notes: This method ignores the transition time provided by the command or settings and just sets the level to the requested value. After the options and value checks it uses the moveToLevelLogic method to set the level. If you want to implement own logic just override moveToLevelLogic with is also used for moveToLevelWithOnOff.
Protected
moveProtected
Default implementation of the moveToLevel logic. When a transition time is specified the implementation uses a step based logic to manage the move. It also checks if the level is within the min and max level range and sets the level accordingly. The method uses setLevel to set the level and handle the on/off state if the method is called by a *WithOnOff command.
Level to set
Transition time, ignored in this default implementation
true if the method is called by a *WithOnOff command
Optional
options: TypeFromPartialBitSchema<{ Options for the command
Default implementation notes: This method ignores the transition time provided by the command or settings and just sets the level to the requested value. After the options and value checks it uses the moveToLevelLogic method to set the level. If you want to implement own logic just override moveToLevelLogic with is also used for moveToLevel.
Default implementation notes: This implementation uses the moveLogic method to set the level. If you want to implement own logic just override moveLogic with is also used for move. The logic is implemented as follows: When no move rate is provided and also no default move rate is set, the server will move as fast as possible, so we set to min/max directly. Else the step logic is applied and the level is increased or decreased by the step size every second.
Protected
reactInstall a Reactor.
Important: The reactor MUST be a real JS function - arrow functions will not work!
Protected
setProtected
Default implementation of the logic to set the level including the handing of the on/off state when one of the *WithOnOff commands is called. This implementation checks if the level is at the minLevel and the device is on, it will turn off the device. If the level is above the minLevel and the device is off, it will turn on the device.
Level which is set by the command
true if the method is called by a *WithOnOff command
Optional
options: TypeFromPartialBitSchema<{ Options for the command
Protected
setDefault implementation notes: After the options checks it uses the stepLogic method to set the level. If you want to implement own logic just override stepLogic with is also used for stepWithOnOff. The logic is implemented as follows: When no transition time is provided, the server will move as fast as possible, so we set to currentlevel +/- stepSize directly. Else the step logic is applied and the level is increased or decreased by the step size every transition time interval.
Protected
stepProtected
Default implementation of the step logic. When no transition time is provided, the server will move as fast as possible, so it is set to min/max directly. Else the level is increased or decreased by the step size every second. The method uses setLevel to set the level and handle the on/off state if the method is called by a *WithOnOff command. The remaining time is updated with every step.
Mode (Up/Down) of the step action
Size of the step action
Time of the step action in 10th of a second
true if the method is called by a *WithOnOff command
Optional
options: TypeFromPartialBitSchema<{ Options for the command
Default implementation notes: This implementation uses the stepLogic method to set the level. If you want to implement own logic just override stepLogic with is also used for step. The logic is implemented as follows: When no transition time is provided, the server will move as fast as possible, so we set to min/max directly. Else the step logic is applied and the level is increased or decreased by the step size every transition time interval.
Protected
stopProtected
Default implementation of the stop logic. This stops any level transitions currently appening and sets the remaining time to 0.
Optional
_options: TypeFromPartialBitSchema<{ Static
alterStatic
enableStatic
forStatic
setStatic
with
This is the default server implementation of LevelControlBehavior.
This implementation includes all features of LevelControl.Cluster and implements all mandatory commands. The On-Off Feature is automatically turned on as defined by the matter specification. You should use LevelControlServer.with to specialize the class for the features your implementation supports.
This default implementation also handles the OnOff cluster dependency and the ColorControl dependency as defined by the Matter specification automatically.
This implementation ignores by default all transition times and sets the level immediately. Alternatively, you can set the
managedTransitionTimeHandling
state attribute to true to have matter.js manage transition times by changing the level value step-wise every second. This might be an intermediate solution if you develop independently of defined hardware.If you develop for a specific hardware you should extend the LevelControlServer class and implement the following methods to natively use device features to correctly support the transition times. For this the default implementation uses special protected methods which are used by the real commands and are only responsible for the actual value change logic. The benefit of this structure is that basic data validations and options checks are already done, and you can focus on the actual hardware interaction:
If you add own implementation you can use:
All overridable methods except setRemainingTime can be implemented sync or async by returning a Promise.