This is the default server implementation of SwitchBehavior.

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

To support all features and events the implementation adds some custom state attributes that can - or are required to - be used. These are:

  • rawPosition - The raw position of the switch. This is the position as reported by the device and is not yet debounced. If the position is already debounced, just set the currentPosition attribute. The debouncing uses the debounceDelay attribute value as timeframe in milliseconds and sets the currentPosition attribute when the value is stable for this timeframe.
  • debounceDelay - The timeframe in milliseconds to wait until a newly reported position is considered stable.
  • longPressDelay - The timeframe in milliseconds to wait until a position is considered "long" pressed. This attribute is REQUIRED if the device supports the Momentary Switch LongPress (MSL) feature.
  • multiPressDelay - The timeframe in milliseconds starting with a stable release to detect multi-presses. This attribute is REQUIRED if the device supports the Momentary Switch MultiPress (MSM) feature.
  • momentaryNeutralPosition - The number of the position considered as the neutral position for the momentary switch. This defaults to position 0 but can be changed by settings this attribute. it is available as soon as the Momentary Switch (MS) feature is used.

Hierarchy

  • SwitchServerBase
    • SwitchServerLogic

Constructors

Properties

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

The implemented cluster.

context: ActionContext
endpoint: Endpoint<Empty>
events: Events

Access the behavior's events.

features: TypeFromBitSchema<{
    latchingSwitch: BitFlag;
    momentarySwitch: BitFlag;
    momentarySwitchLongPress: BitFlag;
    momentarySwitchMultiPress: BitFlag;
    momentarySwitchRelease: BitFlag;
}> & TypeFromBitSchema<{
    latchingSwitch: BitFlag;
    momentarySwitch: BitFlag;
    momentarySwitchLongPress: BitFlag;
    momentarySwitchMultiPress: BitFlag;
    momentarySwitchRelease: BitFlag;
}>

Supported features as a flag object.

internal: Internal
schema: Schema = schema
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<Switch.Complete, readonly [LatchingSwitch, MomentarySwitch, MomentarySwitchRelease, MomentarySwitchLongPress, MomentarySwitchMultiPress]>, Type<Switch.Complete, Type<Of<{
    attributes: {
        currentPosition: Attribute<number, any>;
        numberOfPositions: FixedAttribute<number, any>;
    };
    extensions: readonly [{
        component: {
            attributes: {
                multiPressMax: FixedAttribute<number, any>;
            };
            events: {
                multiPressComplete: Event<TypeFromFields<(...)>, any>;
                multiPressOngoing: Event<TypeFromFields<(...)>, any>;
            };
        };
        flags: {
            momentarySwitchMultiPress: true;
        };
    }, {
        component: {
            events: {
                switchLatched: Event<TypeFromFields<(...)>, any>;
            };
        };
        flags: {
            latchingSwitch: true;
        };
    }, {
        component: {
            events: {
                initialPress: Event<TypeFromFields<(...)>, any>;
            };
        };
        flags: {
            momentarySwitch: true;
        };
    }, {
        component: {
            events: {
                longPress: Event<TypeFromFields<(...)>, any>;
                longRelease: Event<TypeFromFields<(...)>, any>;
            };
        };
        flags: {
            momentarySwitchLongPress: true;
        };
    }, {
        component: {
            events: {
                shortRelease: Event<TypeFromFields<(...)>, any>;
            };
        };
        flags: {
            momentarySwitchRelease: true;
        };
    }, {
        component: false;
        flags: {
            momentarySwitch: false;
            momentarySwitchRelease: true;
        };
    }, {
        component: false;
        flags: {
            momentarySwitch: false;
            momentarySwitchLongPress: true;
        };
    }, {
        component: false;
        flags: {
            momentarySwitchLongPress: true;
            momentarySwitchRelease: false;
        };
    }, {
        component: false;
        flags: {
            momentarySwitch: false;
            momentarySwitchMultiPress: true;
        };
    }, {
        component: false;
        flags: {
            momentarySwitchMultiPress: true;
            momentarySwitchRelease: false;
        };
    }, {
        component: false;
        flags: {
            latchingSwitch: true;
            momentarySwitch: true;
        };
    }, {
        component: false;
        flags: {
            latchingSwitch: false;
            momentarySwitch: false;
        };
    }];
    features: {
        latchingSwitch: BitFlag;
        momentarySwitch: BitFlag;
        momentarySwitchLongPress: BitFlag;
        momentarySwitchMultiPress: BitFlag;
        momentarySwitchRelease: BitFlag;
    };
    id: 59;
    name: "Switch";
    revision: 1;
}>, typeof ClusterBehavior, {
    components: never[];
}>, {
    components: never[];
}>>
dependencies?: Iterable<Type, any, any>
early: boolean
ExtensionInterface: {}
id

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

Interface: {
    components: never[];
}
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

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

  • 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