isy-nodejs 1.0.1-alpha.24 → 1.0.1-alpha.26

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.
Files changed (65) hide show
  1. package/dist/cjs/Converters.js +19 -8
  2. package/dist/cjs/Converters.js.map +1 -1
  3. package/dist/cjs/Definitions/Global/Drivers.js +19 -7
  4. package/dist/cjs/Definitions/Global/Drivers.js.map +1 -1
  5. package/dist/cjs/Devices/Insteon/DimmerLampSwitch.js +23 -23
  6. package/dist/cjs/Devices/Insteon/DimmerLampSwitch.js.map +1 -1
  7. package/dist/cjs/Devices/Insteon/RelayLampSwitch.js +2 -2
  8. package/dist/cjs/Devices/Insteon/RelayLampSwitch.js.map +1 -1
  9. package/dist/cjs/ISY.js +11 -5
  10. package/dist/cjs/ISY.js.map +1 -1
  11. package/dist/cjs/Matter/Behaviors/ISYClusterBehavior.js +4 -2
  12. package/dist/cjs/Matter/Behaviors/ISYClusterBehavior.js.map +1 -1
  13. package/dist/cjs/Matter/Behaviors/ISYOnOffBehavior.js +1 -3
  14. package/dist/cjs/Matter/Behaviors/ISYOnOffBehavior.js.map +1 -1
  15. package/dist/cjs/Model/NodeInfo.js.map +1 -1
  16. package/dist/cjs/types/Converters.d.ts +1 -1
  17. package/dist/cjs/types/Converters.d.ts.map +1 -1
  18. package/dist/cjs/types/Definitions/Global/Drivers.d.ts.map +1 -1
  19. package/dist/cjs/types/Devices/Insteon/DimmerLampSwitch.d.ts +43 -43
  20. package/dist/cjs/types/Devices/Insteon/DimmerLampSwitch.d.ts.map +1 -1
  21. package/dist/cjs/types/ISY.d.ts.map +1 -1
  22. package/dist/cjs/types/Matter/Behaviors/ISYClusterBehavior.d.ts +1 -1
  23. package/dist/cjs/types/Matter/Behaviors/ISYClusterBehavior.d.ts.map +1 -1
  24. package/dist/cjs/types/Matter/Behaviors/ISYOnOffBehavior.d.ts.map +1 -1
  25. package/dist/cjs/types/Model/EnumDefinition.d.ts +1 -1
  26. package/dist/cjs/types/Model/NodeInfo.d.ts +5 -1
  27. package/dist/cjs/types/Model/NodeInfo.d.ts.map +1 -1
  28. package/dist/esm/Converters.js +19 -8
  29. package/dist/esm/Converters.js.map +1 -1
  30. package/dist/esm/Definitions/Global/Drivers.js +19 -7
  31. package/dist/esm/Definitions/Global/Drivers.js.map +1 -1
  32. package/dist/esm/Devices/Insteon/DimmerLampSwitch.js +23 -23
  33. package/dist/esm/Devices/Insteon/DimmerLampSwitch.js.map +1 -1
  34. package/dist/esm/Devices/Insteon/RelayLampSwitch.js +2 -2
  35. package/dist/esm/Devices/Insteon/RelayLampSwitch.js.map +1 -1
  36. package/dist/esm/ISY.js +11 -5
  37. package/dist/esm/ISY.js.map +1 -1
  38. package/dist/esm/Matter/Behaviors/ISYClusterBehavior.js +4 -2
  39. package/dist/esm/Matter/Behaviors/ISYClusterBehavior.js.map +1 -1
  40. package/dist/esm/Matter/Behaviors/ISYOnOffBehavior.js +1 -3
  41. package/dist/esm/Matter/Behaviors/ISYOnOffBehavior.js.map +1 -1
  42. package/dist/esm/Model/NodeInfo.js.map +1 -1
  43. package/dist/esm/types/Converters.d.ts +1 -1
  44. package/dist/esm/types/Converters.d.ts.map +1 -1
  45. package/dist/esm/types/Definitions/Global/Drivers.d.ts.map +1 -1
  46. package/dist/esm/types/Devices/Insteon/DimmerLampSwitch.d.ts +43 -43
  47. package/dist/esm/types/Devices/Insteon/DimmerLampSwitch.d.ts.map +1 -1
  48. package/dist/esm/types/ISY.d.ts.map +1 -1
  49. package/dist/esm/types/Matter/Behaviors/ISYClusterBehavior.d.ts +1 -1
  50. package/dist/esm/types/Matter/Behaviors/ISYClusterBehavior.d.ts.map +1 -1
  51. package/dist/esm/types/Matter/Behaviors/ISYOnOffBehavior.d.ts.map +1 -1
  52. package/dist/esm/types/Model/EnumDefinition.d.ts +1 -1
  53. package/dist/esm/types/Model/NodeInfo.d.ts +5 -1
  54. package/dist/esm/types/Model/NodeInfo.d.ts.map +1 -1
  55. package/dist/tsconfig.cjs.tsbuildinfo +1 -1
  56. package/dist/tsconfig.esm.tsbuildinfo +1 -1
  57. package/package.json +2 -2
  58. package/src/Converters.ts +20 -10
  59. package/src/Definitions/Global/Drivers.ts +17 -8
  60. package/src/Devices/Insteon/DimmerLampSwitch.ts +68 -70
  61. package/src/Devices/Insteon/RelayLampSwitch.ts +2 -2
  62. package/src/ISY.ts +14 -10
  63. package/src/Matter/Behaviors/ISYClusterBehavior.ts +6 -4
  64. package/src/Matter/Behaviors/ISYOnOffBehavior.ts +1 -3
  65. package/src/Model/NodeInfo.ts +2 -1
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "isy-nodejs",
3
3
  "description": "Node.js wrapper for ISY interface including websockets for change notifications. Fork of isy-js by Rod Toll. Designed to be used in a node.js application.",
4
4
  "license": "MIT",
5
- "version": "1.0.1-alpha.24",
5
+ "version": "1.0.1-alpha.26",
6
6
  "author": {
7
7
  "name": "Pradeep Mouli"
8
8
  },
@@ -69,5 +69,5 @@
69
69
  "publishConfig": {
70
70
  "access": "public"
71
71
  },
72
- "gitHead": "a84d9f53c93e1177b1237aeca4cf18f5e42b50f7"
72
+ "gitHead": "256b7ec74dbf1f1abcbfb7e0023f7c43ace45ad9"
73
73
  }
package/src/Converters.ts CHANGED
@@ -51,8 +51,8 @@ export const ConverterRegistry = new Map<string, Converter<any, any>>();
51
51
  function registerConverters() {
52
52
  for (const from in StandardConverters) {
53
53
  for (const to in StandardConverters[from]) {
54
- registerConverter(UnitOfMeasure[from], UnitOfMeasure[to], StandardConverters[from][to] as Converter<any, any>);
55
- registerConverter(UnitOfMeasure[to], UnitOfMeasure[from], invert(StandardConverters[from][to]) as Converter<any, any>);
54
+ registerConverter(from, to, StandardConverters[from][to] as Converter<any, any>);
55
+ registerConverter(to, from, invert(StandardConverters[from][to]) as Converter<any, any>);
56
56
  }
57
57
  }
58
58
  for (const from in Converter.Matter) {
@@ -64,8 +64,8 @@ function registerConverters() {
64
64
  }
65
65
 
66
66
  export function registerConverter(
67
- from: keyof typeof StandardConverters | UnitOfMeasure | keyof typeof Converter.Matter | string,
68
- to: keyof typeof StandardConverters | UnitOfMeasure | keyof typeof Converter.Matter | string,
67
+ from: keyof typeof StandardConverters | keyof typeof Converter.Matter | string,
68
+ to: keyof typeof StandardConverters | keyof typeof Converter.Matter | string,
69
69
  converter: Converter<any, any>
70
70
  ) {
71
71
  if (!StdConverterRegistry.has(from)) {
@@ -108,7 +108,7 @@ export namespace Converter {
108
108
  export type MatterConverters = `${MatterISYConvertibleTypes}.${ISYMatterConvertibleTypes}` | `${ISYMatterConvertibleTypes}.${MatterISYConvertibleTypes}`;
109
109
 
110
110
  export type KnownConverters = StandardConverters | MatterConverters;
111
-
111
+ const cache : {[x:string]:Converter<any,any>} = {};
112
112
  export function get(label: KnownConverters): Converter<any, any>;
113
113
  export function get(from: UnitOfMeasure, to: UnitOfMeasure);
114
114
  export function get(from: ConverterTypes, to: ConverterTypes);
@@ -116,16 +116,26 @@ export namespace Converter {
116
116
  export function get(from: MatterISYConvertibleTypes, to: ISYMatterConvertibleTypes);
117
117
  export function get(to: ISYMatterConvertibleTypes, from: MatterISYConvertibleTypes);
118
118
  export function get(from: UnitOfMeasure | `${keyof typeof UnitOfMeasure}` | string, to?: UnitOfMeasure | `${keyof typeof UnitOfMeasure}` | string): Converter<any, any> {
119
+ if(to === undefined) {
120
+ return ConverterRegistry.get(from as string) ?? NullConverter;
121
+ }
122
+ if(cache[`${from}.${to}`]) {
123
+ return cache[`${from}.${to}`];
124
+ }
125
+ else if(cache[`${to}.${from}`]) {
126
+ cache[`${from}.${to}`] = invert(cache[`${to}.${from}`]);
127
+ return cache[`${from}.${to}`];
128
+ }
119
129
  let isString = typeof from === 'string';
120
- let fuom = isString ? UnitOfMeasure[from] : from;
130
+ let fuom = isString ? from : UnitOfMeasure[from];
121
131
  if (to) {
122
- let tuom = typeof to === 'string' ? UnitOfMeasure[to] : to;
132
+ let tuom = typeof to === 'string' ? to : UnitOfMeasure[to]; ;
123
133
 
124
134
  if (StdConverterRegistry.has(fuom)) {
125
- return StdConverterRegistry.get(fuom).get(tuom);
135
+ if(StdConverterRegistry.get(fuom).has(tuom)) {
136
+ return StdConverterRegistry.get(fuom).get(tuom);
137
+ }
126
138
  }
127
- } else if (typeof from === 'string') {
128
- return ConverterRegistry.get(from);
129
139
  }
130
140
  return NullConverter;
131
141
  }
@@ -427,6 +427,7 @@ export namespace Driver {
427
427
  converter ? converter.from(initState.value)
428
428
  : (node.convertFrom(initState?.value, initState?.uom, driver as D) as T)
429
429
  : null,
430
+ rawValue: initState ? initState.value : null,
430
431
  formattedValue: initState ? initState.formatted : null,
431
432
  pendingValue: null
432
433
  },
@@ -437,22 +438,30 @@ export namespace Driver {
437
438
  return s;
438
439
  },
439
440
  apply(state: DriverState, notify = false) {
440
- let previousValue = this.state.value;
441
- this.state.value = converter ? converter.from(state.value) : node.convertFrom(state.value, state.uom, driver as D);
442
- this.state.formattedValue = state.formatted;
443
- if (previousValue == this.state.value) {
441
+ let previousValue = this.state.rawValue;
442
+ this.state.rawValue = state.value;
443
+ if (previousValue === this.state.rawValue) {
444
444
  return false;
445
445
  }
446
+ if (state.uom != this.uom) {
447
+ this.serverUom == state.uom;
448
+ this.state.value = converter ? converter.from(this.state.rawValue) : Converter.convert(state.uom, this.uom, this.state.rawValue);
449
+ } else if (converter) {
450
+ this.state.value = converter.from(state.value);
451
+ } else {
452
+ this.state.value = state.value;
453
+ }
454
+ this.state.formattedValue = state.formatted;
446
455
  if (notify) node.events.emit(`${this.name}Changed`, driver as D, this.state.value, previousValue, this.state.formattedValue);
447
456
  return true;
448
457
  },
449
458
  patch(value: T, formattedValue: string, uom: UnitOfMeasure, prec: number, notify = true) {
450
- let previousValue = this.state.value;
451
-
459
+ let previousValue = this.state.rawValue;
460
+ this.state.rawValue = value;
452
461
  this.state.formattedValue = formattedValue;
453
462
  if (uom != this.uom) {
454
463
  this.serverUom == uom;
455
- this.state.value = converter ? converter.from(value) : Converter.convert(uom, this.uom, value);
464
+ this.state.value = converter ? converter.from(this.state.rawValue) : Converter.convert(uom, this.uom, this.state.rawValue);
456
465
 
457
466
  }
458
467
  else if(converter)
@@ -466,7 +475,7 @@ export namespace Driver {
466
475
  if (previousValue == this.state.value) {
467
476
  return false;
468
477
  }
469
- if (notify) node.events.emit(`${this.name}Changed`, driver as D, value, previousValue, formattedValue);
478
+ if (notify) node.events.emit(`${this.name}Changed`, driver as D, this.state.value, previousValue, formattedValue);
470
479
  return true;
471
480
  },
472
481
  get value() {
@@ -1,19 +1,18 @@
1
1
  /* THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT DIRECTLY. */
2
2
 
3
- import { UnitOfMeasure } from '../../Definitions/Global/UOM.js';
3
+ import { Driver } from '../../Definitions/Global/Drivers.js';
4
4
  import { Family } from '../../Definitions/Global/Families.js';
5
- import type { NodeInfo } from '../../Model/NodeInfo.js';
5
+ import { UnitOfMeasure } from '../../Definitions/Global/UOM.js';
6
+ import { Insteon } from '../../Definitions/index.js';
6
7
  import type { ISY } from '../../ISY.js';
7
8
  import type { ISYNode } from '../../ISYNode.js';
8
- import { InsteonBaseDevice as Base } from './InsteonBaseDevice.js';
9
- import { ISYDeviceNode } from '../ISYDeviceNode.js';
10
- import { Driver } from '../../Definitions/Global/Drivers.js';
11
- import { Insteon } from '../../Definitions/index.js';
12
9
  import type { DriverState } from '../../Model/DriverState.js';
10
+ import type { NodeInfo } from '../../Model/NodeInfo.js';
11
+ import { ISYDeviceNode } from '../ISYDeviceNode.js';
13
12
  import { NodeFactory } from '../NodeFactory.js';
13
+ import { InsteonBaseDevice as Base } from './InsteonBaseDevice.js';
14
14
 
15
-
16
- export const nodeDefId = "DimmerLampSwitch";
15
+ export const nodeDefId = 'DimmerLampSwitch';
17
16
 
18
17
  type Commands = DimmerLampSwitch.Commands;
19
18
  type Drivers = DimmerLampSwitch.Drivers;
@@ -36,60 +35,59 @@ export class DimmerLampSwitchNode extends Base<Drivers, Commands> implements Dim
36
35
  BL: this.backlight,
37
36
  WDU: this.writeChanges
38
37
  };
39
- static override nodeDefId = "DimmerLampSwitch";
40
- declare readonly nodeDefId: "DimmerLampSwitch";
41
- constructor (isy: ISY, nodeInfo: NodeInfo) {
38
+ static override nodeDefId = 'DimmerLampSwitch';
39
+ declare readonly nodeDefId: 'DimmerLampSwitch';
40
+ constructor(isy: ISY, nodeInfo: NodeInfo) {
42
41
  super(isy, nodeInfo);
43
- this.drivers.ST = Driver.create("ST", this, nodeInfo.property as DriverState, { uom: UnitOfMeasure.Percent, label: "Status", name: "status" });
44
- this.drivers.OL = Driver.create("OL", this, nodeInfo.property as DriverState, { uom: UnitOfMeasure.Percent, label: "On Level", name: "onLevel" });
45
- this.drivers.RR = Driver.create("RR", this, nodeInfo.property as DriverState, { uom: UnitOfMeasure.Index, label: "Ramp Rate", name: "rampRate" });
46
- this.drivers.ERR = Driver.create("ERR", this, nodeInfo.property as DriverState, { uom: UnitOfMeasure.Index, label: "Responding", name: "responding" });
47
-
42
+ this.drivers.ST = Driver.create('ST', this, nodeInfo.state['ST'], { uom: UnitOfMeasure.Percent, label: 'Status', name: 'status' });
43
+ this.drivers.OL = Driver.create('OL', this, nodeInfo.state['OL'] as DriverState, { uom: UnitOfMeasure.Percent, label: 'On Level', name: 'onLevel' });
44
+ this.drivers.RR = Driver.create('RR', this, nodeInfo.state['RR'] as DriverState, { uom: UnitOfMeasure.Index, label: 'Ramp Rate', name: 'rampRate' });
45
+ this.drivers.ERR = Driver.create('ERR', this, nodeInfo.state['ERR'] as DriverState, { uom: UnitOfMeasure.Index, label: 'Responding', name: 'responding' });
48
46
  }
49
47
  async on(value?: number) {
50
- return this.sendCommand("DON", { value: value });
48
+ return this.sendCommand('DON', { value: value });
51
49
  }
52
50
  async off() {
53
- return this.sendCommand("DOF");
51
+ return this.sendCommand('DOF');
54
52
  }
55
53
  async fastOff() {
56
- return this.sendCommand("DFOF");
54
+ return this.sendCommand('DFOF');
57
55
  }
58
56
  async fastOn() {
59
- return this.sendCommand("DFON");
57
+ return this.sendCommand('DFON');
60
58
  }
61
59
  async brighten() {
62
- return this.sendCommand("BRT");
60
+ return this.sendCommand('BRT');
63
61
  }
64
62
  async dim() {
65
- return this.sendCommand("DIM");
63
+ return this.sendCommand('DIM');
66
64
  }
67
65
  async fadeUp() {
68
- return this.sendCommand("FDUP");
66
+ return this.sendCommand('FDUP');
69
67
  }
70
68
  async fadeDown() {
71
- return this.sendCommand("FDDOWN");
69
+ return this.sendCommand('FDDOWN');
72
70
  }
73
71
  async fadeStop() {
74
- return this.sendCommand("FDSTOP");
72
+ return this.sendCommand('FDSTOP');
75
73
  }
76
74
  async query() {
77
- return this.sendCommand("QUERY");
75
+ return this.sendCommand('QUERY');
78
76
  }
79
77
  async beep(value?: number) {
80
- return this.sendCommand("BEEP", { value: value });
78
+ return this.sendCommand('BEEP', { value: value });
81
79
  }
82
80
  async updateOnLevel(value: number) {
83
- return this.sendCommand("OL", { value: value });
81
+ return this.sendCommand('OL', { value: value });
84
82
  }
85
83
  async updateRampRate(value: number) {
86
- return this.sendCommand("RR", { value: value });
84
+ return this.sendCommand('RR', { value: value });
87
85
  }
88
86
  async backlight(value: number) {
89
- return this.sendCommand("BL", { value: value });
87
+ return this.sendCommand('BL', { value: value });
90
88
  }
91
89
  async writeChanges() {
92
- return this.sendCommand("WDU");
90
+ return this.sendCommand('WDU');
93
91
  }
94
92
  public get status(): number {
95
93
  return this.drivers.ST?.value;
@@ -109,7 +107,7 @@ NodeFactory.register(DimmerLampSwitchNode);
109
107
 
110
108
  export namespace DimmerLampSwitch {
111
109
  export interface Interface extends Omit<InstanceType<typeof DimmerLampSwitchNode>, keyof ISYDeviceNode<any, any, any, any>> {
112
- nodeDefId: "DimmerLampSwitch";
110
+ nodeDefId: 'DimmerLampSwitch';
113
111
  }
114
112
  export function is(node: ISYNode<any, any, any, any>): node is DimmerLampSwitchNode {
115
113
  return node.nodeDefId === nodeDefId;
@@ -120,90 +118,90 @@ export namespace DimmerLampSwitch {
120
118
  export const Node = DimmerLampSwitchNode;
121
119
  export type Commands = {
122
120
  DON: ((value?: number) => Promise<boolean>) & {
123
- label: "On";
124
- name: "on";
121
+ label: 'On';
122
+ name: 'on';
125
123
  };
126
124
  DOF: (() => Promise<boolean>) & {
127
- label: "Off";
128
- name: "off";
125
+ label: 'Off';
126
+ name: 'off';
129
127
  };
130
128
  DFOF: (() => Promise<boolean>) & {
131
- label: "Fast Off";
132
- name: "fastOff";
129
+ label: 'Fast Off';
130
+ name: 'fastOff';
133
131
  };
134
132
  DFON: (() => Promise<boolean>) & {
135
- label: "Fast On";
136
- name: "fastOn";
133
+ label: 'Fast On';
134
+ name: 'fastOn';
137
135
  };
138
136
  BRT: (() => Promise<boolean>) & {
139
- label: "Brighten";
140
- name: "brighten";
137
+ label: 'Brighten';
138
+ name: 'brighten';
141
139
  };
142
140
  DIM: (() => Promise<boolean>) & {
143
- label: "Dim";
144
- name: "dim";
141
+ label: 'Dim';
142
+ name: 'dim';
145
143
  };
146
144
  FDUP: (() => Promise<boolean>) & {
147
- label: "Fade Up";
148
- name: "fadeUp";
145
+ label: 'Fade Up';
146
+ name: 'fadeUp';
149
147
  };
150
148
  FDDOWN: (() => Promise<boolean>) & {
151
- label: "Fade Down";
152
- name: "fadeDown";
149
+ label: 'Fade Down';
150
+ name: 'fadeDown';
153
151
  };
154
152
  FDSTOP: (() => Promise<boolean>) & {
155
- label: "Fade Stop";
156
- name: "fadeStop";
153
+ label: 'Fade Stop';
154
+ name: 'fadeStop';
157
155
  };
158
156
  QUERY: (() => Promise<boolean>) & {
159
- label: "Query";
160
- name: "query";
157
+ label: 'Query';
158
+ name: 'query';
161
159
  };
162
160
  BEEP: ((value?: number) => Promise<boolean>) & {
163
- label: "Beep";
164
- name: "beep";
161
+ label: 'Beep';
162
+ name: 'beep';
165
163
  };
166
164
  OL: ((value: number) => Promise<boolean>) & {
167
- label: "On Level";
168
- name: "updateOnLevel";
165
+ label: 'On Level';
166
+ name: 'updateOnLevel';
169
167
  };
170
168
  RR: ((value: number) => Promise<boolean>) & {
171
- label: "Ramp Rate";
172
- name: "updateRampRate";
169
+ label: 'Ramp Rate';
170
+ name: 'updateRampRate';
173
171
  };
174
172
  BL: ((value: number) => Promise<boolean>) & {
175
- label: "Backlight";
176
- name: "backlight";
173
+ label: 'Backlight';
174
+ name: 'backlight';
177
175
  };
178
176
  WDU: (() => Promise<boolean>) & {
179
- label: "Write Changes";
180
- name: "writeChanges";
177
+ label: 'Write Changes';
178
+ name: 'writeChanges';
181
179
  };
182
180
  };
183
181
  export type Drivers = {
184
182
  ST: {
185
183
  uom: UnitOfMeasure.Percent;
186
184
  value: number;
187
- label: "Status";
188
- name: "status";
185
+ label: 'Status';
186
+ name: 'status';
189
187
  };
190
188
  OL: {
191
189
  uom: UnitOfMeasure.Percent;
192
190
  value: number;
193
- label: "On Level";
194
- name: "onLevel";
191
+ label: 'On Level';
192
+ name: 'onLevel';
195
193
  };
196
194
  RR: {
197
195
  uom: UnitOfMeasure.Index;
198
196
  value: number;
199
- label: "Ramp Rate";
200
- name: "rampRate";
197
+ label: 'Ramp Rate';
198
+ name: 'rampRate';
201
199
  };
202
200
  ERR: {
203
201
  uom: UnitOfMeasure.Index;
204
202
  value: Insteon.Error;
205
- label: "Responding";
206
- name: "responding";
203
+ label: 'Responding';
204
+ name: 'responding';
207
205
  };
208
206
  };
209
207
  }
@@ -32,8 +32,8 @@ export class RelayLampSwitchNode extends InsteonBaseDevice<Drivers, Commands> im
32
32
  declare readonly nodeDefId: 'RelayLampSwitch';
33
33
  constructor(isy: ISY, nodeInfo: NodeInfo) {
34
34
  super(isy, nodeInfo);
35
- this.drivers.ST = Driver.create('ST', this, nodeInfo.property as DriverState, { uom: UnitOfMeasure.Percent, label: 'Status', name: 'status' });
36
- this.drivers.ERR = Driver.create('ERR', this, nodeInfo.property as DriverState, { uom: UnitOfMeasure.Index, label: 'Responding', name: 'responding' });
35
+ this.drivers.ST = Driver.create('ST', this, nodeInfo.state['ST'], { uom: UnitOfMeasure.Percent, label: 'Status', name: 'status' });
36
+ this.drivers.ERR = Driver.create('ERR', this, nodeInfo.state['ERR'], { uom: UnitOfMeasure.Index, label: 'Responding', name: 'responding' });
37
37
  }
38
38
  async on(value?: 0 | 100) {
39
39
  return this.sendCommand('DON', { value: value });
package/src/ISY.ts CHANGED
@@ -41,10 +41,10 @@ import type { NodeInfo } from './Model/NodeInfo.js';
41
41
  import * as Utils from './Utils.js';
42
42
 
43
43
  import { X2jOptions, XMLParser } from 'fast-xml-parser';
44
+ import path from 'path';
44
45
  import { NodeFactory } from './Devices/NodeFactory.js';
45
46
  import type { Config } from './Model/Config.js';
46
47
  import { findPackageJson } from './Utils.js';
47
- import path from 'path';
48
48
 
49
49
  export {
50
50
  Category as Categories,
@@ -561,16 +561,13 @@ export class ISY extends EventEmitter implements Disposable {
561
561
  let uriToUse = `nodes/${node.address}/cmd/${command}`;
562
562
  if (parameters !== null && parameters !== undefined) {
563
563
  if (typeof parameters == 'object') {
564
-
565
564
  var q = parameters as Record<P, string | number>;
566
565
  for (const paramName of Object.getOwnPropertyNames(q)) {
567
- if(paramName === 'value')
568
- {
566
+ if (paramName === 'value') {
569
567
  uriToUse += `/${q[paramName]}`;
570
568
  continue;
571
569
  }
572
- if(typeof q[paramName] === 'string' || typeof q[paramName] === 'number')
573
- uriToUse += `/${paramName}/${q[paramName]}`;
570
+ if (typeof q[paramName] === 'string' || typeof q[paramName] === 'number') uriToUse += `/${paramName}/${q[paramName]}`;
574
571
  }
575
572
 
576
573
  //uriToUse += `/${q[((p : Record<string,number|number>) => `${p[]}/${p.paramValue}` ).join('/')}`;
@@ -752,17 +749,24 @@ export class ISY extends EventEmitter implements Disposable {
752
749
  const enabled = nodeInfo.enabled ?? true;
753
750
  const d = await NodeFactory.get(nodeInfo);
754
751
  const m = DeviceFactory.getDeviceDetails(nodeInfo);
752
+ const cls = m?.class ?? d;
753
+ nodeInfo.property = Array.isArray(nodeInfo.property) ? nodeInfo.property : [nodeInfo.property];
754
+ nodeInfo.state = nodeInfo.property.reduce((acc, p) => {
755
+ if (p && p?.id) {
756
+ p.name = p.name == '' ? undefined : p.name;
757
+ acc[p.id] = p;
758
+ }
759
+ return acc;
760
+ }, {});
761
+ newDevice = new cls(this, nodeInfo) as ISYDeviceNode<any, any, any, any>;
755
762
 
756
- if (d) {
757
- newDevice = new d(this, nodeInfo) as ISYDeviceNode<any, any, any, any>;
758
- }
759
763
  if (m) {
760
- newDevice = newDevice ?? (new m.class(this, nodeInfo) as unknown as ISYDeviceNode<any, any, any, any>);
761
764
  newDevice.productName = m.name;
762
765
  newDevice.model = `(${m.modelNumber}) ${m.name} v.${m.version}`;
763
766
  newDevice.modelNumber = m.modelNumber;
764
767
  newDevice.version = m.version;
765
768
  }
769
+
766
770
  if (enabled) {
767
771
  if (newDevice === null) {
768
772
  this.logger.warn(`Device type resolution failed for ${nodeInfo.name} with type: ${nodeInfo.type} and nodedef: ${nodeInfo.nodeDefId}`);
@@ -6,6 +6,7 @@ import type { OnOffBehavior, OnOffServer } from '@project-chip/matter.js/behavio
6
6
  import type { Cluster, ClusterServerHandlers, ClusterType as CT } from '@project-chip/matter.js/cluster';
7
7
  import '@project-chip/matter.js/device';
8
8
  import { OnOffLightRequirements } from '@project-chip/matter.js/devices/OnOffLightDevice';
9
+ import type { AnyMxRecord } from 'dns';
9
10
  import { Converter } from '../../Converters.js';
10
11
  import { Driver, DriverType } from '../../Definitions/Global/Drivers.js';
11
12
  import type { Constructor } from '../../Devices/Constructor.js';
@@ -21,7 +22,7 @@ export type ClusterForBehavior<B> = B extends ClusterBehavior.Type<infer C, infe
21
22
  export type ConstructedType<B extends Constructor<any>> = B extends Constructor<infer C> ? C : never;
22
23
  // <reference path="MatterDevice.js" />
23
24
  // @ts-ignore
24
- export type DeviceBehavior<P extends ISYNode, T extends { cluster? }> = {
25
+ export type DeviceBehavior<P extends ISYNode<any, any, any, any>, T extends { cluster? }> = {
25
26
  device: P;
26
27
 
27
28
  bridgedDeviceBehavior: ISYBridgedDeviceBehavior<P>;
@@ -86,7 +87,8 @@ export function ISYClusterBehavior<T extends Constructor<ClusterBehavior> & { cl
86
87
  }
87
88
  if (driverObj) {
88
89
  let evt = `${driverObj.name}Changed`;
89
- this.reactTo(behavior.events[evt], this.handlePropertyChange.bind(this), { lock: false });
90
+ (this as any).evt = this.handlers[driverObj.name];
91
+ this.reactTo(behavior.events[evt], this.handlePropertyChange, { lock: false });
90
92
  }
91
93
  }
92
94
 
@@ -99,9 +101,9 @@ export function ISYClusterBehavior<T extends Constructor<ClusterBehavior> & { cl
99
101
  return (this._device = this._device ?? (this.agent.get(ISYBridgedDeviceBehavior).device as P));
100
102
  }
101
103
 
102
- handlePropertyChange({ driver, newValue, oldValue, formattedValue }: PropertyChange<P>) {
104
+ async handlePropertyChange({ driver, newValue, oldValue, formattedValue }: PropertyChange<P>) {
103
105
  // for (const key2 in this.map.attributes) {
104
-
106
+ await this.initialize();
105
107
  if (this.handlers[driver]) {
106
108
  this.handlers[driver](newValue, oldValue, formattedValue);
107
109
  }
@@ -16,6 +16,7 @@ import { Converter } from '../../Converters.js';
16
16
  export class ISYOnOffBehavior extends ISYClusterBehavior(OnOffLightRequirements.OnOffServer, InsteonRelayDevice) {
17
17
  override async initialize(_options?: {}) {
18
18
  await super.initialize(_options);
19
+ this.state.onOff = (await this.device.status) > 0;
19
20
  //this.state.onOff = await this.device.state;
20
21
  }
21
22
 
@@ -38,9 +39,6 @@ export class ISYOnOffBehavior extends ISYClusterBehavior(OnOffLightRequirements.
38
39
  };
39
40
 
40
41
  override async handlePropertyChange({ driver, newValue, oldValue, formattedValue }: PropertyChange<InsteonRelayDevice>) {
41
- /*if (driver === 'ST') {
42
- this.state.onOff = newValue;
43
- }*/
44
42
 
45
43
  return super.handlePropertyChange({ driver, newValue, oldValue, formattedValue });
46
44
  }
@@ -4,7 +4,7 @@ import type { DriverState } from './DriverState.js';
4
4
 
5
5
  // #region Type aliases (1)
6
6
 
7
- export type NodeInfo<T extends Family = Family> = T extends Family.ZWave ? DynamicNodeInfo : StaticNodeInfo;
7
+ export type NodeInfo<T extends Family = Family> = (T extends Family.ZWave ? DynamicNodeInfo : StaticNodeInfo) & { state?: { [x: string]: DriverState } };
8
8
 
9
9
  // #endregion Type aliases (1)
10
10
 
@@ -47,6 +47,7 @@ export interface DynamicNodeInfo {
47
47
  parent?: Parent;
48
48
  pnode: any;
49
49
  property?: DriverState[] | DriverState;
50
+
50
51
  rpnode: string;
51
52
  sgid: string;
52
53
  startDelay: number;