This is the default server implementation of ColorControlBehavior.

This implementation includes all features of ColorControl.Cluster and implements all mandatory commands. You should use ColorControlServer.with to specialize the class for the features your implementation supports.

This default implementation also handles together with the LevelControl cluster the currentLevel dependency as defined by the Matter specification automatically.

This implementation ignores by default all transition times and sets the new color 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 ColorControlServer 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:

All overridable methods can be implemented sync or async by returning a Promise.

For own implementations you can use:

  • ColorControlServerLogic#setColorMode to set the color mode
  • ColorControlServerLogic#setEnhancedColorMode to set the enhanced color mode

The default implementation of ColorControlServerLogic.switchColorMode tries to convert the color values between the different modi. When switching from color temperature mode to any other mode the value can be converted when the color temperature was between 1000K and 20.000K. For other values no conversion takes place.

The method ColorControlServerLogic.syncColorTemperatureWithLevelLogic is handling the sync between the LevelControl and ColorControl cluster when the color temperature is used.

Additionally there are some convenience properties to access the current attribute values for all relevant color attributes (x,y, hue, saturation, mireds/kelvin, colorTemperatur, ...) in their CIE value format instead the matter data ranges.

Hierarchy

  • ColorControlServerBase
    • ColorControlServerLogic

Constructors

Properties

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

The implemented cluster.

context: ActionContext
endpoint: Endpoint<Empty>
events: EventEmitter & Omit<ClusterEvents<ColorControl.Cluster, Type<Of<{
    attributes: {};
    commands: {};
    events: {};
    id: 0;
    name: "Unknown";
    revision: 0;
}>, typeof ClusterBehavior, ColorControlInterface>>,
    | "options$Changing"
    | "options$Changed"
    | "colorMode$Changing"
    | "numberOfPrimaries$Changing"
    | "enhancedColorMode$Changing"
    | "colorCapabilities$Changing"
    | "remainingTime$Changing"
    | "driftCompensation$Changing"
    | "compensationText$Changing"
    | "primary1X$Changing"
    | "primary1Y$Changing"
    | "primary1Intensity$Changing"
    | "primary2X$Changing"
    | "primary2Y$Changing"
    | "primary2Intensity$Changing"
    | "primary3X$Changing"
    | "primary3Y$Changing"
    | "primary3Intensity$Changing"
    | "primary4X$Changing"
    | "primary4Y$Changing"
    | "primary4Intensity$Changing"
    | "primary5X$Changing"
    | "primary5Y$Changing"
    | "primary5Intensity$Changing"
    | "primary6X$Changing"
    | "primary6Y$Changing"
    | "primary6Intensity$Changing"
    | "whitePointX$Changing"
    | "whitePointY$Changing"
    | "colorPointRx$Changing"
    | "colorPointRy$Changing"
    | "colorPointRIntensity$Changing"
    | "colorPointGx$Changing"
    | "colorPointGy$Changing"
    | "colorPointGIntensity$Changing"
    | "colorPointBx$Changing"
    | "colorPointBy$Changing"
    | "colorPointBIntensity$Changing"
    | "colorMode$Changed"
    | "numberOfPrimaries$Changed"
    | "enhancedColorMode$Changed"
    | "colorCapabilities$Changed"
    | "remainingTime$Changed"
    | "driftCompensation$Changed"
    | "compensationText$Changed"
    | "primary1X$Changed"
    | "primary1Y$Changed"
    | "primary1Intensity$Changed"
    | "primary2X$Changed"
    | "primary2Y$Changed"
    | "primary2Intensity$Changed"
    | "primary3X$Changed"
    | "primary3Y$Changed"
    | "primary3Intensity$Changed"
    | "primary4X$Changed"
    | "primary4Y$Changed"
    | "primary4Intensity$Changed"
    | "primary5X$Changed"
    | "primary5Y$Changed"
    | "primary5Intensity$Changed"
    | "primary6X$Changed"
    | "primary6Y$Changed"
    | "primary6Intensity$Changed"
    | "whitePointX$Changed"
    | "whitePointY$Changed"
    | "colorPointRx$Changed"
    | "colorPointRy$Changed"
    | "colorPointRIntensity$Changed"
    | "colorPointGx$Changed"
    | "colorPointGy$Changed"
    | "colorPointGIntensity$Changed"
    | "colorPointBx$Changed"
    | "colorPointBy$Changed"
    | "colorPointBIntensity$Changed"> & {
    colorCapabilities$Changing: ClusterEvents.AttributeObservable<Attribute<TypeFromPartialBitSchema<{
        colorLoop: BitFlag;
        colorTemperature: BitFlag;
        enhancedHue: BitFlag;
        hueSaturation: BitFlag;
        xy: BitFlag;
    }>, any>>;
    colorLoopActive$Changing: ClusterEvents.AttributeObservable<Attribute<ColorControl.ColorLoopActive, any>>;
    colorLoopDirection$Changing: ClusterEvents.AttributeObservable<Attribute<ColorControl.ColorLoopDirection, any>>;
    colorLoopStartEnhancedHue$Changing: ClusterEvents.AttributeObservable<Attribute<number, any>>;
    colorLoopStoredEnhancedHue$Changing: ClusterEvents.AttributeObservable<Attribute<number, any>>;
    colorLoopTime$Changing: ClusterEvents.AttributeObservable<Attribute<number, any>>;
    colorMode$Changing: ClusterEvents.AttributeObservable<Attribute<ColorControl.ColorMode, any>>;
    colorTemperatureMireds$Changing: ClusterEvents.AttributeObservable<Attribute<number, any>>;
    colorTempPhysicalMaxMireds$Changing: ClusterEvents.AttributeObservable<Attribute<number, any>>;
    colorTempPhysicalMinMireds$Changing: ClusterEvents.AttributeObservable<Attribute<number, any>>;
    currentHue$Changing: ClusterEvents.AttributeObservable<Attribute<number, any>>;
    currentSaturation$Changing: ClusterEvents.AttributeObservable<Attribute<number, any>>;
    currentX$Changing: ClusterEvents.AttributeObservable<Attribute<number, any>>;
    currentY$Changing: ClusterEvents.AttributeObservable<Attribute<number, any>>;
    enhancedColorMode$Changing: ClusterEvents.AttributeObservable<Attribute<ColorControl.EnhancedColorMode, any>>;
    enhancedCurrentHue$Changing: ClusterEvents.AttributeObservable<Attribute<number, any>>;
    numberOfPrimaries$Changing: ClusterEvents.AttributeObservable<FixedAttribute<null | number, any>>;
    options$Changing: ClusterEvents.AttributeObservable<WritableAttribute<TypeFromPartialBitSchema<{
        executeIfOff: BitFlag;
    }>, any>>;
} & {
    colorPointBIntensity$Changing: undefined | ClusterEvents.AttributeObservable<OptionalWritableAttribute<null | number, any>>;
    colorPointBx$Changing: undefined | ClusterEvents.AttributeObservable<OptionalWritableAttribute<number, any>>;
    colorPointBy$Changing: undefined | ClusterEvents.AttributeObservable<OptionalWritableAttribute<number, any>>;
    colorPointGIntensity$Changing: undefined | ClusterEvents.AttributeObservable<OptionalWritableAttribute<null | number, any>>;
    colorPointGx$Changing: undefined | ClusterEvents.AttributeObservable<OptionalWritableAttribute<number, any>>;
    colorPointGy$Changing: undefined | ClusterEvents.AttributeObservable<OptionalWritableAttribute<number, any>>;
    colorPointRIntensity$Changing: undefined | ClusterEvents.AttributeObservable<OptionalWritableAttribute<null | number, any>>;
    colorPointRx$Changing: undefined | ClusterEvents.AttributeObservable<OptionalWritableAttribute<number, any>>;
    colorPointRy$Changing: undefined | ClusterEvents.AttributeObservable<OptionalWritableAttribute<number, any>>;
    compensationText$Changing: undefined | ClusterEvents.AttributeObservable<OptionalAttribute<string, any>>;
    coupleColorTempToLevelMinMireds$Changing: undefined | ClusterEvents.AttributeObservable<OptionalAttribute<number, any>>;
    driftCompensation$Changing: undefined | ClusterEvents.AttributeObservable<OptionalAttribute<ColorControl.DriftCompensation, any>>;
    primary1Intensity$Changing: undefined | ClusterEvents.AttributeObservable<OptionalFixedAttribute<null | number, any>>;
    primary1X$Changing: undefined | ClusterEvents.AttributeObservable<OptionalFixedAttribute<number, any>>;
    primary1Y$Changing: undefined | ClusterEvents.AttributeObservable<OptionalFixedAttribute<number, any>>;
    primary2Intensity$Changing: undefined | ClusterEvents.AttributeObservable<OptionalFixedAttribute<null | number, any>>;
    primary2X$Changing: undefined | ClusterEvents.AttributeObservable<OptionalFixedAttribute<number, any>>;
    primary2Y$Changing: undefined | ClusterEvents.AttributeObservable<OptionalFixedAttribute<number, any>>;
    primary3Intensity$Changing: undefined | ClusterEvents.AttributeObservable<OptionalFixedAttribute<null | number, any>>;
    primary3X$Changing: undefined | ClusterEvents.AttributeObservable<OptionalFixedAttribute<number, any>>;
    primary3Y$Changing: undefined | ClusterEvents.AttributeObservable<OptionalFixedAttribute<number, any>>;
    primary4Intensity$Changing: undefined | ClusterEvents.AttributeObservable<OptionalFixedAttribute<null | number, any>>;
    primary4X$Changing: undefined | ClusterEvents.AttributeObservable<OptionalFixedAttribute<number, any>>;
    primary4Y$Changing: undefined | ClusterEvents.AttributeObservable<OptionalFixedAttribute<number, any>>;
    primary5Intensity$Changing: undefined | ClusterEvents.AttributeObservable<OptionalFixedAttribute<null | number, any>>;
    primary5X$Changing: undefined | ClusterEvents.AttributeObservable<OptionalFixedAttribute<number, any>>;
    primary5Y$Changing: undefined | ClusterEvents.AttributeObservable<OptionalFixedAttribute<number, any>>;
    primary6Intensity$Changing: undefined | ClusterEvents.AttributeObservable<OptionalFixedAttribute<null | number, any>>;
    primary6X$Changing: undefined | ClusterEvents.AttributeObservable<OptionalFixedAttribute<number, any>>;
    primary6Y$Changing: undefined | ClusterEvents.AttributeObservable<OptionalFixedAttribute<number, any>>;
    remainingTime$Changing: undefined | ClusterEvents.AttributeObservable<OptionalAttribute<number, any>>;
    startUpColorTemperatureMireds$Changing: undefined | ClusterEvents.AttributeObservable<OptionalWritableAttribute<null | number, any>>;
    whitePointX$Changing: undefined | ClusterEvents.AttributeObservable<OptionalWritableAttribute<number, any>>;
    whitePointY$Changing: undefined | ClusterEvents.AttributeObservable<OptionalWritableAttribute<number, any>>;
} & {
    colorCapabilities$Changed: ClusterEvents.AttributeObservable<Attribute<TypeFromPartialBitSchema<{
        colorLoop: BitFlag;
        colorTemperature: BitFlag;
        enhancedHue: BitFlag;
        hueSaturation: BitFlag;
        xy: BitFlag;
    }>, any>>;
    colorLoopActive$Changed: ClusterEvents.AttributeObservable<Attribute<ColorControl.ColorLoopActive, any>>;
    colorLoopDirection$Changed: ClusterEvents.AttributeObservable<Attribute<ColorControl.ColorLoopDirection, any>>;
    colorLoopStartEnhancedHue$Changed: ClusterEvents.AttributeObservable<Attribute<number, any>>;
    colorLoopStoredEnhancedHue$Changed: ClusterEvents.AttributeObservable<Attribute<number, any>>;
    colorLoopTime$Changed: ClusterEvents.AttributeObservable<Attribute<number, any>>;
    colorMode$Changed: ClusterEvents.AttributeObservable<Attribute<ColorControl.ColorMode, any>>;
    colorTemperatureMireds$Changed: ClusterEvents.AttributeObservable<Attribute<number, any>>;
    colorTempPhysicalMaxMireds$Changed: ClusterEvents.AttributeObservable<Attribute<number, any>>;
    colorTempPhysicalMinMireds$Changed: ClusterEvents.AttributeObservable<Attribute<number, any>>;
    currentHue$Changed: ClusterEvents.AttributeObservable<Attribute<number, any>>;
    currentSaturation$Changed: ClusterEvents.AttributeObservable<Attribute<number, any>>;
    currentX$Changed: ClusterEvents.AttributeObservable<Attribute<number, any>>;
    currentY$Changed: ClusterEvents.AttributeObservable<Attribute<number, any>>;
    enhancedColorMode$Changed: ClusterEvents.AttributeObservable<Attribute<ColorControl.EnhancedColorMode, any>>;
    enhancedCurrentHue$Changed: ClusterEvents.AttributeObservable<Attribute<number, any>>;
    numberOfPrimaries$Changed: ClusterEvents.AttributeObservable<FixedAttribute<null | number, any>>;
    options$Changed: ClusterEvents.AttributeObservable<WritableAttribute<TypeFromPartialBitSchema<{
        executeIfOff: BitFlag;
    }>, any>>;
} & {
    colorPointBIntensity$Changed: undefined | ClusterEvents.AttributeObservable<OptionalWritableAttribute<null | number, any>>;
    colorPointBx$Changed: undefined | ClusterEvents.AttributeObservable<OptionalWritableAttribute<number, any>>;
    colorPointBy$Changed: undefined | ClusterEvents.AttributeObservable<OptionalWritableAttribute<number, any>>;
    colorPointGIntensity$Changed: undefined | ClusterEvents.AttributeObservable<OptionalWritableAttribute<null | number, any>>;
    colorPointGx$Changed: undefined | ClusterEvents.AttributeObservable<OptionalWritableAttribute<number, any>>;
    colorPointGy$Changed: undefined | ClusterEvents.AttributeObservable<OptionalWritableAttribute<number, any>>;
    colorPointRIntensity$Changed: undefined | ClusterEvents.AttributeObservable<OptionalWritableAttribute<null | number, any>>;
    colorPointRx$Changed: undefined | ClusterEvents.AttributeObservable<OptionalWritableAttribute<number, any>>;
    colorPointRy$Changed: undefined | ClusterEvents.AttributeObservable<OptionalWritableAttribute<number, any>>;
    compensationText$Changed: undefined | ClusterEvents.AttributeObservable<OptionalAttribute<string, any>>;
    coupleColorTempToLevelMinMireds$Changed: undefined | ClusterEvents.AttributeObservable<OptionalAttribute<number, any>>;
    driftCompensation$Changed: undefined | ClusterEvents.AttributeObservable<OptionalAttribute<ColorControl.DriftCompensation, any>>;
    primary1Intensity$Changed: undefined | ClusterEvents.AttributeObservable<OptionalFixedAttribute<null | number, any>>;
    primary1X$Changed: undefined | ClusterEvents.AttributeObservable<OptionalFixedAttribute<number, any>>;
    primary1Y$Changed: undefined | ClusterEvents.AttributeObservable<OptionalFixedAttribute<number, any>>;
    primary2Intensity$Changed: undefined | ClusterEvents.AttributeObservable<OptionalFixedAttribute<null | number, any>>;
    primary2X$Changed: undefined | ClusterEvents.AttributeObservable<OptionalFixedAttribute<number, any>>;
    primary2Y$Changed: undefined | ClusterEvents.AttributeObservable<OptionalFixedAttribute<number, any>>;
    primary3Intensity$Changed: undefined | ClusterEvents.AttributeObservable<OptionalFixedAttribute<null | number, any>>;
    primary3X$Changed: undefined | ClusterEvents.AttributeObservable<OptionalFixedAttribute<number, any>>;
    primary3Y$Changed: undefined | ClusterEvents.AttributeObservable<OptionalFixedAttribute<number, any>>;
    primary4Intensity$Changed: undefined | ClusterEvents.AttributeObservable<OptionalFixedAttribute<null | number, any>>;
    primary4X$Changed: undefined | ClusterEvents.AttributeObservable<OptionalFixedAttribute<number, any>>;
    primary4Y$Changed: undefined | ClusterEvents.AttributeObservable<OptionalFixedAttribute<number, any>>;
    primary5Intensity$Changed: undefined | ClusterEvents.AttributeObservable<OptionalFixedAttribute<null | number, any>>;
    primary5X$Changed: undefined | ClusterEvents.AttributeObservable<OptionalFixedAttribute<number, any>>;
    primary5Y$Changed: undefined | ClusterEvents.AttributeObservable<OptionalFixedAttribute<number, any>>;
    primary6Intensity$Changed: undefined | ClusterEvents.AttributeObservable<OptionalFixedAttribute<null | number, any>>;
    primary6X$Changed: undefined | ClusterEvents.AttributeObservable<OptionalFixedAttribute<number, any>>;
    primary6Y$Changed: undefined | ClusterEvents.AttributeObservable<OptionalFixedAttribute<number, any>>;
    remainingTime$Changed: undefined | ClusterEvents.AttributeObservable<OptionalAttribute<number, any>>;
    startUpColorTemperatureMireds$Changed: undefined | ClusterEvents.AttributeObservable<OptionalWritableAttribute<null | number, any>>;
    whitePointX$Changed: undefined | ClusterEvents.AttributeObservable<OptionalWritableAttribute<number, any>>;
    whitePointY$Changed: undefined | ClusterEvents.AttributeObservable<OptionalWritableAttribute<number, any>>;
} & {} & {}

Access the behavior's events.

features: TypeFromBitSchema<{}> & TypeFromBitSchema<{
    colorLoop: BitFlag;
    colorTemperature: BitFlag;
    enhancedHue: BitFlag;
    hueSaturation: BitFlag;
    xy: BitFlag;
}>

Supported features as a flag object.

internal: Internal
session: SecureSession
state: State

Access the behavior's state.

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

defaults: ClusterState.Type<WithFeatures<ColorControl.Cluster, readonly [HueSaturation, EnhancedHue, ColorLoop, Xy, ColorTemperature]>, Type<ColorControl.Cluster, Type<Of<{
    attributes: {};
    commands: {};
    events: {};
    id: 0;
    name: "Unknown";
    revision: 0;
}>, typeof ClusterBehavior, ColorControlInterface>, ColorControlInterface>>
dependencies?: Iterable<Type, any, any>
early: boolean
Events: ClusterEvents.Type<WithFeatures<ColorControl.Cluster, readonly [HueSaturation, EnhancedHue, ColorLoop, Xy, ColorTemperature]>, Type<ColorControl.Cluster, Type<Of<{
    attributes: {};
    commands: {};
    events: {};
    id: 0;
    name: "Unknown";
    revision: 0;
}>, typeof ClusterBehavior, ColorControlInterface>, ColorControlInterface>>
id

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

name: string
schema?: Schema
supervisor: RootSupervisor
supports: ((other: Type) => boolean)

Type declaration

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

      Parameters

      Returns boolean

Accessors

Methods

  • 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

  • Default implementation notes: After the options checks and potentially switching the color mode it uses the stopColorLoopLogic method to stop color loops or startColorLoopLogic to start a color loop at a defined enhanced hue value. If you want to implement own logic just override these methods. The logic is implemented as follows: When no transition time is provided, the server will move as fast as possible, so we set the target value directly. Else the step logic is applied and the color temperature is increased or decreased by the step size every transition time interval.

    Parameters

    Returns MaybePromise<void>

  • 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

  • Protected

    Default implementation of the moveColor logic. If the managed transition time handling is disabled the method directly sets the new x and y values. Otherwise the method initiates a transition with the given rate.

    Parameters

    • rateX: number

      The rate to move the x value up or down (positive values mean up, negative down)

    • rateY: number

      The rate to move the y value up or down (positive values mean up, negative down)

    Returns MaybePromise

  • Protected

    Default implementation of the moveColorTemperature logic. If the managed transition time handling is disabled the method directly sets the min or max color temperature value. Otherwise the method initiates a transition with the given rate.

    Parameters

    • moveMode: ColorControl.MoveMode
    • rate: number
    • colorTemperatureMinimumMireds: number
    • colorTemperatureMaximumMireds: number

    Returns MaybePromise

  • Protected

    Default implementation of the moveHue logic. The method handled hue and enhanced-Hue changes depending on the last parameter. If the managed transition time handling is disabled the method directly increases the hue value by one rate step. So without managed transition not too much happens. Otherwise the method initiates a transition with the given rate.

    Parameters

    • moveMode: ColorControl.MoveMode

      Move Mode to move the hue up or down (Stop should not be provided in here because already handled)

    • rate: number

      The rate to move the hue up or down. 0 should never be provided her because handled here.

    • isEnhancedHue: boolean = false

      If true the enhanced hue is handled, otherwise the normal hue

    Returns MaybePromise

  • Protected

    Default implementation of the moveToColor logic. If the managed transition time handling is disabled the method directly sets the new x and y values. Otherwise the method initiates a transition with the given rate. This method internally uses moveToColorLogic to handle the x and y changes, so if you have implemented it already you might not need to override this method.

    Parameters

    • targetX: number

      The target x value to move to

    • targetY: number

      The target y value to move to

    • transitionTime: number

      The time in seconds to move to the target x and y. 0 means "as fast as possible"

    Returns MaybePromise

  • Protected

    Default implementation of the moveToColorTemperature logic. If the managed transition time handling is disabled the method directly sets the new color temperature value. Otherwise the method initiates a transition with the given rate.

    Parameters

    • targetMireds: number

      The target color temperature value to move to

    • transitionTime: number

      The time in seconds to move to the target color temperature. 0 means "as fast as possible"

    Returns MaybePromise

  • Default implementation notes: After the options checks it uses the moveToHueLogic and moveToSaturationLogic methods to set the hue and saturation. Both methods are also used for other commands, so it maybe is not needed to override this method. The logic is implemented as follows: Depending on the provided rate the server will move as fast as possible, so we set to min/max directly if the managed transition is not used. Else the step logic is applied and the level is increased or decreased by the step size every second.

    Parameters

    • targetEnhancedHue: number
    • targetSaturation: number
    • transitionTime: number

    Returns MaybePromise

  • Protected

    Default implementation of the moveToHueAndSaturation logic. If the managed transition time handling is disabled the method directly sets the new hue and saturation values. Otherwise the method initiates a transition with the given rate. This method internally uses moveToHueLogic and moveToSaturationLogic to handle the hue and saturation changes, so if you have implemented them already you might not need to override this method.

    Parameters

    • targetHue: number

      The target hue value to move to

    • targetSaturation: number

      The target saturation value to move to

    • transitionTime: number

      The time in seconds to move to the target hue and saturation. 0 means "as fast as possible"

    Returns MaybePromise

  • Protected

    Default implementation of the moveToHue logic. When a transition time is specified the implementation uses a step based to manage the move. The method handled hue and enhanced-Hue changes depending on the last parameter.

    Parameters

    • targetHue: number

      The target hue value to move to (in range of the matter hue or enhanced hue ranges)

    • direction: ColorControl.Direction

      The direction to move to the target hue

    • transitionTime: number

      The time in seconds to move to the target hue. 0 means "as fast as possible"

    • isEnhancedHue: boolean = false

      If true the enhanced hue is handled, otherwise the normal hue

    Returns MaybePromise

  • Protected

    Default implementation of the moveToSaturation logic. If the managed transition time handling is disabled the method directly sets the new saturation value. Otherwise the method initiates a transition with the given rate.

    Parameters

    • targetSaturation: number

      The target saturation value to move to

    • transitionTime: number

      The time in seconds to move to the target saturation. 0 means "as fast as possible"

    Returns MaybePromise

  • Install a Reactor.

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

    Type Parameters

    Parameters

    Returns void

  • Protected

    Default implementation of the stepColor logic. If the managed transition time handling is disabled the method directly sets the new x and y values. Otherwise the method initiates a transition with the given rate.

    Parameters

    • stepX: number

      The step size to move the x value up or down

    • stepY: number

      The step size to move the y value up or down

    • transitionTime: number

      The time in seconds to move the x and y. 0 means "as fast as possible"

    Returns MaybePromise

  • Protected

    Default implementation of the stepColorTemperature logic. If the managed transition time handling is disabled the method directly sets the new color temperature value. Otherwise the method initiates a transition with the given rate.

    Parameters

    • stepMode: ColorControl.StepMode

      Step Mode to move the color temperature up or down

    • stepSize: number

      Step size to move the color temperature up or down

    • transitionTime: number

      Time in seconds to move the color temperature. 0 means "as fast as possible"

    • colorTemperatureMinimumMireds: number

      Minimum allowed color temperature value

    • colorTemperatureMaximumMireds: number

      Maximum allowed color temperature value

    Returns MaybePromise

  • Protected

    Default implementation of the stepHue logic. The method handled hue and enhanced-Hue changes depending on the last parameter. The logic is implemented as follows: When no transition time is provided, the server will move as fast as possible, so we set to current Hue +/- stepSize directly. Else the step logic is applied and the hue is increased or decreased by the step size every transition time interval.

    Parameters

    • stepMode: ColorControl.StepMode

      The step mode to move the hue up or down

    • stepSize: number

      The step size to move the hue up or down

    • transitionTime: number

      The time in seconds to move the hue. 0 means "as fast as possible"

    • isEnhancedHue: boolean = false

      If true the enhanced hue is handled, otherwise the normal hue

    Returns MaybePromise

  • Protected

    Default implementation of the stepSaturation logic. If the managed transition time handling is disabled the method directly sets the new saturation value. Otherwise the method initiates a transition with the given rate.

    Parameters

    • stepMode: ColorControl.StepMode

      The step mode to move the saturation up or down

    • stepSize: number

      The step size to move the saturation up or down

    • transitionTime: number

      The time in seconds to move the saturation. 0 means "as fast as possible"

    Returns MaybePromise

  • Protected

    Default implementation notes: This method is used to switch the device color mode. It converts the current color attributes to the new mode on a best effort "as close as possible" basis. If the device hardware can do this better this method should be overridden to implement this switch logic and to update all state attributes for the new mode. The color mode attribute update itself is handled by the calling method, so is not needed to be done here.

    Parameters

    Returns MaybePromise

  • Protected

    This method is used internally to potentially handle the dependency between the ColorControl and LevelControl clusters as defined by the Matter specification. It uses moveToColorTemperatureLogic with a transition time of 0 (as fast as possible) to set the determined color temperature. Unless you have special requirements you do not need to override it.

    Parameters

    • level: number

      The current level value from the LevelControl cluster

    Returns MaybePromise