interface SwitchBehavior {
    [reference]: Datasource<StateType>;
    agent: Agent;
    cluster: never;
    context: ActionContext;
    endpoint: Endpoint<Empty>;
    env: Environment;
    events: EventEmitter & Omit<Events, never> & {
        currentPosition$Changing: ClusterEvents.AttributeObservable<Attribute<number, any>>;
        numberOfPositions$Changing: ClusterEvents.AttributeObservable<FixedAttribute<number, any>>;
    } & {} & {
        currentPosition$Changed: ClusterEvents.AttributeObservable<Attribute<number, any>>;
        numberOfPositions$Changed: ClusterEvents.AttributeObservable<FixedAttribute<number, any>>;
    } & {} & {} & {};
    features: TypeFromBitSchema<{
        latchingSwitch: BitFlag;
        momentarySwitch: BitFlag;
        momentarySwitchLongPress: BitFlag;
        momentarySwitchMultiPress: BitFlag;
        momentarySwitchRelease: BitFlag;
    }>;
    session: SecureSession;
    state: Omit<{}, never> & {
        currentPosition: number;
    } & {} & {
        numberOfPositions: number;
    } & {};
    [asyncDispose](): MaybePromise;
    asAdmin(fn: (() => void)): void;
    assertAttributeEnabled<This, K>(this: This, attributeName: K): void;
    callback<A, R>(reactor: Reactor<A, R>, options?: Reactor.Options): ((...args: A) => undefined | R);
    initialize(_options?: {}): MaybePromise;
    reactTo<O>(observable: O, reactor: Reactor<Parameters<O["emit"]>, ReturnType<O["emit"]>>, options?: Reactor.Options): void;
    requireAttributeEnabled<This, K>(this: This, attributeName: K): Exclude<This["state"][K], undefined>;
    toString(): string;
    State: any;
}

Hierarchy

  • SwitchBehaviorType
    • SwitchBehavior

Properties

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

The implemented cluster.

context: ActionContext
endpoint: Endpoint<Empty>
events: EventEmitter & Omit<Events, never> & {
    currentPosition$Changing: ClusterEvents.AttributeObservable<Attribute<number, any>>;
    numberOfPositions$Changing: ClusterEvents.AttributeObservable<FixedAttribute<number, any>>;
} & {} & {
    currentPosition$Changed: ClusterEvents.AttributeObservable<Attribute<number, any>>;
    numberOfPositions$Changed: ClusterEvents.AttributeObservable<FixedAttribute<number, any>>;
} & {} & {} & {}

Access the behavior's events.

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

Supported features as a flag object.

Type declaration

  • ReadonlylatchingSwitch: BitFlag

    LatchingSwitch

    This feature is for a switch that maintains its position after being pressed (or turned).

    MatterSpecification.v13.Cluster § 1.13.4.1

  • ReadonlymomentarySwitch: BitFlag

    MomentarySwitch

    This feature is for a switch that does not maintain its position after being pressed (or turned). After releasing, it goes back to its idle position.

    MatterSpecification.v13.Cluster § 1.13.4.2

  • ReadonlymomentarySwitchLongPress: BitFlag

    MomentarySwitchLongPress

    This feature is for a momentary switch that can distinguish and report long presses from short presses. When this feature flag MSL is present, MS and MSR shall be present as well.

    MatterSpecification.v13.Cluster § 1.13.4.4

  • ReadonlymomentarySwitchMultiPress: BitFlag

    MomentarySwitchMultiPress

    This feature is for a momentary switch that can distinguish and report double press and potentially multiple presses with more events, such as triple press, etc. When this feature flag MSM is present, MS and MSR shall be present as well.

    MatterSpecification.v13.Cluster § 1.13.4.5

  • ReadonlymomentarySwitchRelease: BitFlag

    MomentarySwitchRelease

    This feature is for a momentary switch that can distinguish and report release events. When this feature flag MSR is present, MS shall be present as well.

    MatterSpecification.v13.Cluster § 1.13.4.3

session: SecureSession
state: Omit<{}, never> & {
    currentPosition: number;
} & {} & {
    numberOfPositions: number;
} & {}

Access the behavior's state.

Type declaration

  • ReadonlycurrentPosition: number

    Indicates the position of the switch. The valid range is zero to NumberOfPositions-1. CurrentPosition value 0 shall be assigned to the default position of the switch: for example the "open" state of a rocker switch, or the "idle" state of a push button switch.

    MatterSpecification.v13.Cluster § 1.13.5.2

Type declaration

  • ReadonlynumberOfPositions: number

    Indicates the maximum number of positions the switch has. Any kind of switch has a minimum of 2 positions. Also see Multi Position Details for the case NumberOfPositions>2.

    MatterSpecification.v13.Cluster § 1.13.5.1

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.

    Parameters

    • Optional_options: {}

      Returns MaybePromise