Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add inclusion state changed event #7059

Merged
merged 1 commit into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions docs/api/controller.md
Original file line number Diff line number Diff line change
Expand Up @@ -1423,6 +1423,31 @@ A node could not be included into or excluded from the network for some reason.

The process to include or exclude a node was stopped successfully. Note that these events are also emitted after a node was included or excluded.

### `"inclusion state changed"`

The controller's inclusion state has changed. The new state is passed as an argument.

```ts
(state: InclusionState) => void
```

<!-- #import InclusionState from "zwave-js" -->

```ts
enum InclusionState {
/** The controller isn't doing anything regarding inclusion. */
Idle,
/** The controller is waiting for a node to be included. */
Including,
/** The controller is waiting for a node to be excluded. */
Excluding,
/** The controller is busy including or excluding a node. */
Busy,
/** The controller listening for SmartStart nodes to announce themselves. */
SmartStart,
}
```

### `"node found"`

A node has successfully been added to the network.
Expand Down
2 changes: 2 additions & 0 deletions packages/zwave-js/src/lib/controller/Controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ interface ControllerEventCallbacks
"exclusion started": () => void;
"inclusion stopped": () => void;
"exclusion stopped": () => void;
"inclusion state changed": (state: InclusionState) => void;
"node found": (node: FoundNode) => void;
"node added": (node: ZWaveNode, result: InclusionResult) => void;
"node removed": (node: ZWaveNode, reason: RemoveNodeReason) => void;
Expand Down Expand Up @@ -1960,6 +1961,7 @@ export class ZWaveController
public setInclusionState(state: InclusionState): void {
if (this._inclusionState === state) return;
this._inclusionState = state;
this.emit("inclusion state changed", state);
if (
state === InclusionState.Idle
&& this._smartStartEnabled
Expand Down
Loading