Skip to content

Commit

Permalink
feat: add inclusion state changed event (#7059)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCalzone authored Jul 30, 2024
1 parent 10d8f02 commit d6d1627
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
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

0 comments on commit d6d1627

Please sign in to comment.