@zwave-js/host 13.10.2-0-pr-7305-907444c → 13.10.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,88 +1,70 @@
1
- import type { DeviceConfig } from "@zwave-js/config";
2
- import type { CCId, CommandClasses, ControllerLogger, FrameType, MaybeNotKnown, NodeId, SecurityClass, SecurityManagers, SendCommandOptions, SendCommandReturnType, ValueDB, ValueID } from "@zwave-js/core";
1
+ import type { ConfigManager, DeviceConfig } from "@zwave-js/config";
2
+ import type { CommandClasses, ControllerLogger, ICommandClass, IZWaveNode, MaybeNotKnown, NodeIDType, SecurityClass, SecurityManager, SecurityManager2, SendCommandOptions, SendCommandReturnType, ValueDB, ValueID } from "@zwave-js/core";
3
+ import type { ReadonlyThrowingMap } from "@zwave-js/shared";
3
4
  import type { ZWaveHostOptions } from "./ZWaveHostOptions";
4
- /** Allows querying the home ID and node ID of the host */
5
- export interface HostIDs {
5
+ /** Host application abstractions to be used in Serial API and CC implementations */
6
+ export interface ZWaveHost {
6
7
  /** The ID of this node in the current network */
7
8
  ownNodeId: number;
8
9
  /** The Home ID of the current network */
9
10
  homeId: number;
10
- }
11
- /** Allows querying device configuration for a node */
12
- export interface GetDeviceConfig {
13
- getDeviceConfig(nodeId: number): DeviceConfig | undefined;
14
- }
15
- export interface GetSupportedCCVersion {
11
+ /** How many bytes a node ID occupies in serial API commands */
12
+ readonly nodeIdType?: NodeIDType;
13
+ /** Management of Security S0 keys and nonces */
14
+ securityManager: SecurityManager | undefined;
15
+ /** Management of Security S2 keys and nonces (Z-Wave Classic) */
16
+ securityManager2: SecurityManager2 | undefined;
17
+ /** Management of Security S2 keys and nonces (Z-Wave Long Range) */
18
+ securityManagerLR: SecurityManager2 | undefined;
19
+ /**
20
+ * Retrieves the maximum version of a command class that can be used to communicate with a node.
21
+ * Returns 1 if the node claims that it does not support a CC.
22
+ * Throws if the CC is not implemented in this library yet.
23
+ */
24
+ getSafeCCVersion(cc: CommandClasses, nodeId: number, endpointIndex?: number): number;
16
25
  /**
17
26
  * Retrieves the maximum version of a command class the given node/endpoint has reported support for.
18
27
  * Returns 0 when the CC is not supported or that information is not known yet.
19
28
  */
20
29
  getSupportedCCVersion(cc: CommandClasses, nodeId: number, endpointIndex?: number): number;
21
- }
22
- export interface GetSafeCCVersion {
23
30
  /**
24
- * Retrieves the maximum version of a command class that can be used to communicate with a node.
25
- * Returns 1 if the node claims that it does not support a CC.
26
- * Returns `undefined` for CCs that are not implemented in this library yet.
31
+ * Determines whether a CC must be secure for a given node and endpoint.
27
32
  */
28
- getSafeCCVersion(cc: CommandClasses, nodeId: number, endpointIndex?: number): number | undefined;
29
- }
30
- /** Additional context needed for deserializing CCs */
31
- export interface CCParsingContext extends Readonly<SecurityManagers>, GetDeviceConfig, HostIDs {
32
- sourceNodeId: number;
33
- __internalIsMockNode?: boolean;
34
- /** If known, the frame type of the containing message */
35
- frameType: FrameType;
36
- getHighestSecurityClass(nodeId: number): MaybeNotKnown<SecurityClass>;
37
- hasSecurityClass(nodeId: number, securityClass: SecurityClass): MaybeNotKnown<boolean>;
38
- setSecurityClass(nodeId: number, securityClass: SecurityClass, granted: boolean): void;
39
- }
40
- /** Additional context needed for serializing CCs */
41
- export interface CCEncodingContext extends Readonly<SecurityManagers>, GetDeviceConfig, HostIDs, GetSupportedCCVersion {
33
+ isCCSecure(cc: CommandClasses, nodeId: number, endpointIndex?: number): boolean;
42
34
  getHighestSecurityClass(nodeId: number): MaybeNotKnown<SecurityClass>;
43
35
  hasSecurityClass(nodeId: number, securityClass: SecurityClass): MaybeNotKnown<boolean>;
44
36
  setSecurityClass(nodeId: number, securityClass: SecurityClass, granted: boolean): void;
37
+ /**
38
+ * Returns the next callback ID. Callback IDs are used to correlate requests
39
+ * to the controller/nodes with its response
40
+ */
41
+ getNextCallbackId(): number;
42
+ /**
43
+ * Returns the next session ID for supervised communication
44
+ */
45
+ getNextSupervisionSessionId(nodeId: number): number;
46
+ getDeviceConfig?: (nodeId: number) => DeviceConfig | undefined;
47
+ __internalIsMockNode?: boolean;
45
48
  }
46
49
  /** Host application abstractions that provide support for reading and writing values to a database */
47
- export interface GetValueDB {
50
+ export interface ZWaveValueHost {
48
51
  /** Returns the value DB which belongs to the node with the given ID, or throws if the Value DB cannot be accessed */
49
52
  getValueDB(nodeId: number): ValueDB;
50
53
  /** Returns the value DB which belongs to the node with the given ID, or `undefined` if the Value DB cannot be accessed */
51
54
  tryGetValueDB(nodeId: number): ValueDB | undefined;
52
55
  }
53
- /** Allows accessing a specific node */
54
- export interface GetNode<T extends NodeId> {
55
- getNode(nodeId: number): T | undefined;
56
- getNodeOrThrow(nodeId: number): T;
57
- }
58
- /** Allows accessing all nodes */
59
- export interface GetAllNodes<T extends NodeId> {
60
- getAllNodes(): T[];
61
- }
62
- /** Allows looking up Z-Wave manufacturers by manufacturer ID */
63
- export interface LookupManufacturer {
64
- /** Looks up the name of the manufacturer with the given ID in the configuration DB */
65
- lookupManufacturer(manufacturerId: number): string | undefined;
66
- }
67
- /** Allows sending commands to one or more nodes */
68
- export interface SendCommand {
69
- sendCommand<TResponse extends CCId | undefined = undefined>(command: CCId, options?: SendCommandOptions): Promise<SendCommandReturnType<TResponse>>;
70
- }
71
- /** Allows reading options to use for interviewing devices */
72
- export interface GetInterviewOptions {
73
- getInterviewOptions(): ZWaveHostOptions["interview"];
74
- }
75
- /** Allows reading user preferences */
76
- export interface GetUserPreferences {
77
- getUserPreferences(): ZWaveHostOptions["preferences"];
78
- }
79
- /** Allows reading user preferences */
80
- export interface GetCommunicationTimeouts {
81
- getCommunicationTimeouts(): ZWaveHostOptions["timeouts"];
82
- }
83
- export type LogNode = Pick<ControllerLogger, "logNode">;
84
- /** Allows scheduling a value refresh (poll) for a later time */
85
- export interface SchedulePoll {
56
+ /** A more featureful version of the ZWaveHost interface, which is meant to be used on the controller application side. */
57
+ export interface ZWaveApplicationHost extends ZWaveValueHost, ZWaveHost {
58
+ /** Gives access to the configuration files */
59
+ configManager: ConfigManager;
60
+ options: ZWaveHostOptions;
61
+ controllerLog: ControllerLogger;
62
+ /** Readonly access to all node instances known to the host */
63
+ nodes: ReadonlyThrowingMap<number, IZWaveNode>;
64
+ /** Whether the node with the given ID is the controller */
65
+ isControllerNode(nodeId: number): boolean;
66
+ sendCommand<TResponse extends ICommandClass | undefined = undefined>(command: ICommandClass, options?: SendCommandOptions): Promise<SendCommandReturnType<TResponse>>;
67
+ waitForCommand<T extends ICommandClass>(predicate: (cc: ICommandClass) => boolean, timeout: number): Promise<T>;
86
68
  schedulePoll(nodeId: number, valueId: ValueID, options: NodeSchedulePollOptions): boolean;
87
69
  }
88
70
  export interface NodeSchedulePollOptions {
@@ -1 +1 @@
1
- {"version":3,"file":"ZWaveHost.d.ts","sourceRoot":"","sources":["../src/ZWaveHost.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EACX,IAAI,EACJ,cAAc,EACd,gBAAgB,EAChB,SAAS,EACT,aAAa,EACb,MAAM,EACN,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,qBAAqB,EACrB,OAAO,EACP,OAAO,EACP,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,0DAA0D;AAC1D,MAAM,WAAW,OAAO;IACvB,iDAAiD;IACjD,SAAS,EAAE,MAAM,CAAC;IAClB,yCAAyC;IACzC,MAAM,EAAE,MAAM,CAAC;CACf;AAED,sDAAsD;AACtD,MAAM,WAAW,eAAe;IAC/B,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAAC;CAC1D;AAED,MAAM,WAAW,qBAAqB;IACrC;;;OAGG;IACH,qBAAqB,CACpB,EAAE,EAAE,cAAc,EAClB,MAAM,EAAE,MAAM,EACd,aAAa,CAAC,EAAE,MAAM,GACpB,MAAM,CAAC;CACV;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AAC,qBAAqB,CAAC,SAAS,CAAC,CAAC,CAAC;IAE7C,cAAc,CAAC,CAAC,SAAS,aAAa,EACrC,SAAS,EAAE,CAAC,EAAE,EAAE,aAAa,KAAK,OAAO,EACzC,OAAO,EAAE,MAAM,GACb,OAAO,CAAC,CAAC,CAAC,CAAC;IAEd,YAAY,CACX,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,uBAAuB,GAC9B,OAAO,CAAC;CACX;AAED,MAAM,WAAW,uBAAuB;IACvC,0DAA0D;IAC1D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACxB"}
package/build/mocks.d.ts CHANGED
@@ -1,12 +1,16 @@
1
- import { type ControlsCC, type EndpointId, type GetEndpoint, type IsCCSecure, type ListenBehavior, type NodeId, type QuerySecurityClasses, type SetSecurityClass, type SupportsCC } from "@zwave-js/core";
2
- import type { GetAllNodes, GetDeviceConfig, GetNode, GetSupportedCCVersion, GetValueDB, HostIDs, LogNode } from "./ZWaveHost";
3
- export interface CreateTestingHostOptions extends HostIDs, GetDeviceConfig {
1
+ import { type IZWaveNode } from "@zwave-js/core";
2
+ import { type ThrowingMap } from "@zwave-js/shared";
3
+ import type { Overwrite } from "alcalzone-shared/types";
4
+ import type { ZWaveApplicationHost, ZWaveHost } from "./ZWaveHost";
5
+ export interface CreateTestingHostOptions {
6
+ homeId: ZWaveHost["homeId"];
7
+ ownNodeId: ZWaveHost["ownNodeId"];
8
+ getSafeCCVersion: ZWaveHost["getSafeCCVersion"];
9
+ getSupportedCCVersion?: ZWaveHost["getSupportedCCVersion"];
4
10
  }
5
- export type BaseTestEndpoint = EndpointId & SupportsCC & ControlsCC & IsCCSecure;
6
- export type BaseTestNode = BaseTestEndpoint & NodeId & ListenBehavior & QuerySecurityClasses & SetSecurityClass & SupportsCC & ControlsCC & IsCCSecure & GetEndpoint<BaseTestEndpoint>;
7
- export interface TestingHost extends HostIDs, GetValueDB, GetSupportedCCVersion, GetAllNodes<BaseTestNode>, GetNode<BaseTestNode>, GetDeviceConfig, LogNode {
8
- setNode(nodeId: number, node: BaseTestNode): void;
9
- }
10
- /** Creates a {@link TestingHost} that can be used instead of a real driver instance in tests */
11
+ export type TestingHost = Overwrite<Omit<ZWaveApplicationHost, "__internalIsMockNode">, {
12
+ nodes: ThrowingMap<number, IZWaveNode>;
13
+ }>;
14
+ /** Creates a {@link ZWaveApplicationHost} that can be used for testing */
11
15
  export declare function createTestingHost(options?: Partial<CreateTestingHostOptions>): TestingHost;
12
16
  //# sourceMappingURL=mocks.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mocks.d.ts","sourceRoot":"","sources":["../src/mocks.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,MAAM,EACX,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,UAAU,EAIf,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EACX,WAAW,EACX,eAAe,EACf,OAAO,EACP,qBAAqB,EACrB,UAAU,EACV,OAAO,EACP,OAAO,EACP,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,wBAAyB,SAAQ,OAAO,EAAE,eAAe;CAAG;AAE7E,MAAM,MAAM,gBAAgB,GACzB,UAAU,GACV,UAAU,GACV,UAAU,GACV,UAAU,CAAC;AAEd,MAAM,MAAM,YAAY,GACrB,gBAAgB,GAChB,MAAM,GACN,cAAc,GACd,oBAAoB,GACpB,gBAAgB,GAChB,UAAU,GACV,UAAU,GACV,UAAU,GACV,WAAW,CAAC,gBAAgB,CAAC,CAAC;AAEjC,MAAM,WAAW,WAChB,SACC,OAAO,EACP,UAAU,EACV,qBAAqB,EACrB,WAAW,CAAC,YAAY,CAAC,EACzB,OAAO,CAAC,YAAY,CAAC,EACrB,eAAe,EACf,OAAO;IAER,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAG,IAAI,CAAC;CAClD;AAED,gGAAgG;AAChG,wBAAgB,iBAAiB,CAChC,OAAO,GAAE,OAAO,CAAC,wBAAwB,CAAM,GAC7C,WAAW,CAsGb"}
1
+ {"version":3,"file":"mocks.d.ts","sourceRoot":"","sources":["../src/mocks.ts"],"names":[],"mappings":"AAEA,OAAO,EACN,KAAK,UAAU,EAMf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACN,KAAK,WAAW,EAGhB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAEnE,MAAM,WAAW,wBAAwB;IACxC,MAAM,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC;IAC5B,SAAS,EAAE,SAAS,CAAC,WAAW,CAAC,CAAC;IAClC,gBAAgB,EAAE,SAAS,CAAC,kBAAkB,CAAC,CAAC;IAChD,qBAAqB,CAAC,EAAE,SAAS,CAAC,uBAAuB,CAAC,CAAC;CAC3D;AAED,MAAM,MAAM,WAAW,GAAG,SAAS,CAClC,IAAI,CAAC,oBAAoB,EAAE,sBAAsB,CAAC,EAClD;IAAE,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;CAAE,CAC1C,CAAC;AAEF,0EAA0E;AAC1E,wBAAgB,iBAAiB,CAChC,OAAO,GAAE,OAAO,CAAC,wBAAwB,CAAM,GAC7C,WAAW,CAuGb"}
package/build/mocks.js CHANGED
@@ -1,68 +1,58 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createTestingHost = createTestingHost;
4
+ /* eslint-disable @typescript-eslint/require-await */
5
+ const config_1 = require("@zwave-js/config");
4
6
  const core_1 = require("@zwave-js/core");
5
7
  const shared_1 = require("@zwave-js/shared");
6
- /** Creates a {@link TestingHost} that can be used instead of a real driver instance in tests */
8
+ /** Creates a {@link ZWaveApplicationHost} that can be used for testing */
7
9
  function createTestingHost(options = {}) {
8
10
  const valuesStorage = new Map();
9
11
  const metadataStorage = new Map();
10
12
  const valueDBCache = new Map();
11
- const nodes = (0, shared_1.createThrowingMap)((nodeId) => {
12
- throw new core_1.ZWaveError(`Node ${nodeId} was not found!`, core_1.ZWaveErrorCodes.Controller_NodeNotFound);
13
- });
13
+ const supervisionSessionIDs = new Map();
14
14
  const ret = {
15
15
  homeId: options.homeId ?? 0x7e570001,
16
16
  ownNodeId: options.ownNodeId ?? 1,
17
- getDeviceConfig: options.getDeviceConfig ?? (() => undefined),
18
- // securityManager: undefined,
19
- // securityManager2: undefined,
20
- // securityManagerLR: undefined,
21
- // getDeviceConfig: () => undefined,
22
- // lookupManufacturer: () => undefined,
23
- logNode: () => { },
24
- // options: {
25
- // attempts: {
26
- // nodeInterview: 1,
27
- // // openSerialPort: 1,
28
- // sendData: 3,
29
- // controller: 3,
30
- // },
31
- // timeouts: {
32
- // refreshValue: 5000,
33
- // refreshValueAfterTransition: 1000,
34
- // },
35
- // },
36
- // getInterviewOptions() {
37
- // return {};
38
- // },
39
- // getUserPreferences() {
40
- // return undefined;
41
- // },
42
- // getCommunicationTimeouts() {
43
- // return {
44
- // refreshValue: 5000,
45
- // refreshValueAfterTransition: 1000,
46
- // };
47
- // },
48
- getNode(nodeId) {
49
- return nodes.get(nodeId);
17
+ nodeIdType: core_1.NodeIDType.Short,
18
+ isControllerNode: (nodeId) => nodeId === ret.ownNodeId,
19
+ securityManager: undefined,
20
+ securityManager2: undefined,
21
+ securityManagerLR: undefined,
22
+ getDeviceConfig: undefined,
23
+ controllerLog: new Proxy({}, {
24
+ get() {
25
+ return () => {
26
+ /* intentionally empty */
27
+ };
28
+ },
29
+ }),
30
+ configManager: new config_1.ConfigManager(),
31
+ options: {
32
+ attempts: {
33
+ nodeInterview: 1,
34
+ // openSerialPort: 1,
35
+ sendData: 3,
36
+ controller: 3,
37
+ },
38
+ timeouts: {
39
+ refreshValue: 5000,
40
+ refreshValueAfterTransition: 1000,
41
+ },
50
42
  },
51
- getNodeOrThrow(nodeId) {
52
- return nodes.getOrThrow(nodeId);
53
- },
54
- getAllNodes() {
55
- return [...nodes.values()];
56
- },
57
- setNode(nodeId, node) {
58
- nodes.set(nodeId, node);
59
- },
60
- // getSafeCCVersion: options.getSafeCCVersion ?? (() => 100),
61
- getSupportedCCVersion: (cc, nodeId, endpoint) => {
62
- return nodes.get(nodeId)?.getEndpoint(endpoint ?? 0)?.getCCVersion(cc) ?? 0;
63
- // return options.getSupportedCCVersion?.(cc, nodeId, endpoint)
64
- // ?? options.getSafeCCVersion?.(cc, nodeId, endpoint)
65
- // ?? 100;
43
+ nodes: (0, shared_1.createThrowingMap)((nodeId) => {
44
+ throw new core_1.ZWaveError(`Node ${nodeId} was not found!`, core_1.ZWaveErrorCodes.Controller_NodeNotFound);
45
+ }),
46
+ getSafeCCVersion: options.getSafeCCVersion ?? (() => 100),
47
+ getSupportedCCVersion: options.getSupportedCCVersion
48
+ ?? options.getSafeCCVersion
49
+ ?? (() => 100),
50
+ getNextCallbackId: (0, shared_1.createWrappingCounter)(0xff),
51
+ getNextSupervisionSessionId: (nodeId) => {
52
+ if (!supervisionSessionIDs.has(nodeId)) {
53
+ supervisionSessionIDs.set(nodeId, (0, shared_1.createWrappingCounter)(core_1.MAX_SUPERVISION_SESSION_ID, true));
54
+ }
55
+ return supervisionSessionIDs.get(nodeId)();
66
56
  },
67
57
  getValueDB: (nodeId) => {
68
58
  if (!valueDBCache.has(nodeId)) {
@@ -73,24 +63,34 @@ function createTestingHost(options = {}) {
73
63
  tryGetValueDB: (nodeId) => {
74
64
  return ret.getValueDB(nodeId);
75
65
  },
76
- // getHighestSecurityClass: (nodeId) => {
77
- // const node = nodes.getOrThrow(nodeId);
78
- // return node.getHighestSecurityClass();
79
- // },
80
- // hasSecurityClass: (nodeId, securityClass) => {
81
- // const node = nodes.getOrThrow(nodeId);
82
- // return node.hasSecurityClass(securityClass);
83
- // },
84
- // setSecurityClass: (nodeId, securityClass, granted) => {
85
- // const node = nodes.getOrThrow(nodeId);
86
- // node.setSecurityClass(securityClass, granted);
87
- // },
88
- // sendCommand: async (_command, _options) => {
89
- // return undefined as any;
90
- // },
91
- // schedulePoll: (_nodeId, _valueId, _options) => {
92
- // return false;
93
- // },
66
+ isCCSecure: (ccId, nodeId, endpointIndex = 0) => {
67
+ const node = ret.nodes.get(nodeId);
68
+ const endpoint = node?.getEndpoint(endpointIndex);
69
+ return (node?.isSecure !== false
70
+ && !!(endpoint ?? node)?.isCCSecure(ccId)
71
+ && !!(ret.securityManager || ret.securityManager2));
72
+ },
73
+ getHighestSecurityClass: (nodeId) => {
74
+ const node = ret.nodes.getOrThrow(nodeId);
75
+ return node.getHighestSecurityClass();
76
+ },
77
+ hasSecurityClass: (nodeId, securityClass) => {
78
+ const node = ret.nodes.getOrThrow(nodeId);
79
+ return node.hasSecurityClass(securityClass);
80
+ },
81
+ setSecurityClass: (nodeId, securityClass, granted) => {
82
+ const node = ret.nodes.getOrThrow(nodeId);
83
+ node.setSecurityClass(securityClass, granted);
84
+ },
85
+ sendCommand: async (_command, _options) => {
86
+ return undefined;
87
+ },
88
+ waitForCommand: async (_predicate, _timeout) => {
89
+ return undefined;
90
+ },
91
+ schedulePoll: (_nodeId, _valueId, _options) => {
92
+ return false;
93
+ },
94
94
  };
95
95
  return ret;
96
96
  }
@@ -1 +1 @@
1
- {"version":3,"file":"mocks.js","sourceRoot":"","sources":["../src/mocks.ts"],"names":[],"mappings":";;AA0DA,8CAwGC;AAlKD,yCAawB;AACxB,6CAAqD;AA2CrD,gGAAgG;AAChG,SAAgB,iBAAiB,CAChC,UAA6C,EAAE;IAE/C,MAAM,aAAa,GAAG,IAAI,GAAG,EAAE,CAAC;IAChC,MAAM,eAAe,GAAG,IAAI,GAAG,EAAE,CAAC;IAClC,MAA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AE,EAAE;YACnC,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;YAC1C,OAAO,IAAI,CAAC,uBAAuB,EAAE,CAAC;QACvC,CAAC;QACD,gBAAgB,EAAE,CAAC,MAAM,EAAE,aAAa,EAAE,EAAE;YAC3C,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;YAC1C,OAAO,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;QAC7C,CAAC;QACD,gBAAgB,EAAE,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,EAAE;YACpD,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;YAC1C,IAAI,CAAC,gBAAgB,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;QAC/C,CAAC;QACD,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE;YACzC,OAAO,SAAgB,CAAC;QACzB,CAAC;QACD,cAAc,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE;YAC9C,OAAO,SAAgB,CAAC;QACzB,CAAC;QACD,YAAY,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE;YAC7C,OAAO,KAAK,CAAC;QACd,CAAC;KACD,CAAC;IACF,OAAO,GAAG,CAAC;AACZ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zwave-js/host",
3
- "version": "13.10.2-0-pr-7305-907444c",
3
+ "version": "13.10.3",
4
4
  "description": "zwave-js: Host abstractions",
5
5
  "keywords": [],
6
6
  "publishConfig": {
@@ -50,9 +50,9 @@
50
50
  "lint:ts:fix": "yarn run lint:ts --fix"
51
51
  },
52
52
  "dependencies": {
53
- "@zwave-js/config": "13.10.2-0-pr-7305-907444c",
54
- "@zwave-js/core": "13.10.2-0-pr-7305-907444c",
55
- "@zwave-js/shared": "13.10.2-0-pr-7305-907444c",
53
+ "@zwave-js/config": "13.10.3",
54
+ "@zwave-js/core": "13.6.0",
55
+ "@zwave-js/shared": "13.6.0",
56
56
  "alcalzone-shared": "^4.0.8"
57
57
  },
58
58
  "devDependencies": {
@@ -60,6 +60,5 @@
60
60
  "@types/node": "^18.19.55",
61
61
  "del-cli": "^6.0.0",
62
62
  "typescript": "5.6.2"
63
- },
64
- "stableVersion": "13.10.1"
63
+ }
65
64
  }