interface PowerSourceBehavior {
    [reference]: Datasource<StateType>;
    agent: Agent;
    cluster: never;
    context: ActionContext;
    endpoint: Endpoint<Empty>;
    env: Environment;
    events: EventEmitter & Omit<Events, never> & {
        description$Changing: ClusterEvents.AttributeObservable<FixedAttribute<string, any>>;
        endpointList$Changing: ClusterEvents.AttributeObservable<Attribute<EndpointNumber[], any>>;
        order$Changing: ClusterEvents.AttributeObservable<Attribute<number, any>>;
        status$Changing: ClusterEvents.AttributeObservable<Attribute<PowerSource.PowerSourceStatus, any>>;
    } & {} & {
        description$Changed: ClusterEvents.AttributeObservable<FixedAttribute<string, any>>;
        endpointList$Changed: ClusterEvents.AttributeObservable<Attribute<EndpointNumber[], any>>;
        order$Changed: ClusterEvents.AttributeObservable<Attribute<number, any>>;
        status$Changed: ClusterEvents.AttributeObservable<Attribute<PowerSource.PowerSourceStatus, any>>;
    } & {} & {} & {};
    features: TypeFromBitSchema<{
        battery: BitFlag;
        rechargeable: BitFlag;
        replaceable: BitFlag;
        wired: BitFlag;
    }>;
    session: SecureSession;
    state: Omit<{}, never> & {
        endpointList: EndpointNumber[];
        order: number;
        status: PowerSource.PowerSourceStatus;
    } & {} & {
        description: string;
    } & {};
    [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 (view full)

Properties

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

The implemented cluster.

context: ActionContext
endpoint: Endpoint<Empty>
events: EventEmitter & Omit<Events, never> & {
    description$Changing: ClusterEvents.AttributeObservable<FixedAttribute<string, any>>;
    endpointList$Changing: ClusterEvents.AttributeObservable<Attribute<EndpointNumber[], any>>;
    order$Changing: ClusterEvents.AttributeObservable<Attribute<number, any>>;
    status$Changing: ClusterEvents.AttributeObservable<Attribute<PowerSource.PowerSourceStatus, any>>;
} & {} & {
    description$Changed: ClusterEvents.AttributeObservable<FixedAttribute<string, any>>;
    endpointList$Changed: ClusterEvents.AttributeObservable<Attribute<EndpointNumber[], any>>;
    order$Changed: ClusterEvents.AttributeObservable<Attribute<number, any>>;
    status$Changed: ClusterEvents.AttributeObservable<Attribute<PowerSource.PowerSourceStatus, any>>;
} & {} & {} & {}

Access the behavior's events.

features: TypeFromBitSchema<{
    battery: BitFlag;
    rechargeable: BitFlag;
    replaceable: BitFlag;
    wired: BitFlag;
}>

Supported features as a flag object.

Type declaration

  • Readonlybattery: BitFlag

    Battery

    A battery power source

  • Readonlyrechargeable: BitFlag

    Rechargeable

    A rechargeable battery power source

  • Readonlyreplaceable: BitFlag

    Replaceable

    A replaceable battery power source

  • Readonlywired: BitFlag

    Wired

    A wired power source

session: SecureSession
state: Omit<{}, never> & {
    endpointList: EndpointNumber[];
    order: number;
    status: PowerSource.PowerSourceStatus;
} & {} & {
    description: string;
} & {}

Access the behavior's state.

Type declaration

  • ReadonlyendpointList: EndpointNumber[]

    Indicates a list of endpoints that are powered by the source defined by this cluster. Multiple instances of this cluster may list the same endpoint, because it is possible for power for an endpoint to come from multiple sources. In that case the Order attribute indicates their priority.

    For each power source on a node, there shall only be one instance of this cluster.

    A cluster instance with an empty list shall indicate that the power source is for the entire node, which includes all endpoints.

    A cluster instance with a non-empty list shall include the endpoint, upon which the cluster instance resides.

    The above rules allow that some endpoints can have an unknown power source, and therefore would not be indicated by any instance of this cluster.

    Empty list examples

    Typically, there is one power source for the node. Also common is mains power for the node with battery backup power for the node. In both these common cases, for each cluster instance described, the list is empty.

    Populated list example

    A node has a mains power source with Order as 0 (zero), but some application endpoints (not all) have a battery back up source with Order as 1, which means this list is empty for the Power Source cluster associated with the mains power, because it indicates the entire node, but the Power Source cluster instance associated with the battery backup would list the endpoints that have a battery backup.

    MatterSpecification.v13.Core § 11.7.7.32

  • Readonlyorder: number

    Indicates the relative preference with which the Node will select this source to provide power. A source with a lower order shall be selected by the Node to provide power before any other source with a higher order, if the lower order source is available (see Status).

    Note, Order is read-only and therefore NOT intended to allow clients control over power source selection.

    MatterSpecification.v13.Core § 11.7.7.2

  • Readonlystatus: PowerSource.PowerSourceStatus

    Indicates the participation of this power source in providing power to the Node as specified in PowerSourceStatusEnum.

    MatterSpecification.v13.Core § 11.7.7.1

Type declaration

  • Readonlydescription: string

    This attribute shall provide a user-facing description of this source, used to distinguish it from other power sources, e.g. "DC Power", "Primary Battery" or "Battery back-up". This attribute shall NOT be used to convey information such as battery form factor, or chemistry.

    MatterSpecification.v13.Core § 11.7.7.3

Methods

  • Release resources. This is the public API for releasing application resources held by behaviors in internal state.

    Returns MaybePromise

  • 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.

    Parameters

    • Optional_options: {}

      Returns MaybePromise

    • 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>

    • Description used in diagnostic messages.

      Returns string