isy-nodejs 1.0.6-alpha.2 → 1.0.7-alpha.0

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.
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.6-alpha.2",
5
+ "version": "1.0.7-alpha.0",
6
6
  "author": {
7
7
  "name": "Pradeep Mouli"
8
8
  },
@@ -74,5 +74,5 @@
74
74
  "publishConfig": {
75
75
  "access": "public"
76
76
  },
77
- "gitHead": "3de345bb19ced109099ec8beb4707293e1924922"
77
+ "gitHead": "ce35a40c2400673ba8035446eb91348ff94d0df4"
78
78
  }
@@ -282,6 +282,7 @@ export interface Driver<
282
282
  value: T;
283
283
  formattedValue?: any;
284
284
  pendingValue: T;
285
+ rawValue?: ST;
285
286
  };
286
287
  uom: U;
287
288
 
package/src/ISYNode.ts CHANGED
@@ -270,9 +270,9 @@ export class ISYNode<
270
270
  const e = event.control;
271
271
  const dispName = this.commands[e]?.name;
272
272
  if (dispName !== undefined && dispName !== null) {
273
- this.logger(`Command ${dispName} (${e}) event sent.`);
273
+ this.logger(`Command ${dispName} (${e}) event received.`);
274
274
  } else {
275
- this.logger(`Command ${e} event sent.`);
275
+ this.logger(`Command ${e} event received.`);
276
276
  }
277
277
  this.handleControlTrigger(e);
278
278
  return true;
@@ -282,11 +282,12 @@ export class ISYNode<
282
282
  public handlePropertyChange(propertyName: StringKeys<D>, value: any, uom: UnitOfMeasure, prec?: number, formattedValue?: string): boolean {
283
283
  this.lastChanged = new Date();
284
284
  let driver = this.drivers[propertyName];
285
- this.logger(`Driver ${propertyName} (${driver?.label} value update ${value} (${formattedValue}) uom: ${UnitOfMeasure[uom]} event received.`);
286
- const oldValue = driver?.value;
285
+ /*this.logger(`Driver ${propertyName} (${driver?.label} value update ${value} (${formattedValue}) uom: ${UnitOfMeasure[uom]} event received.`);*/
286
+ const oldValue = driver?.state.value;
287
+ const oldValueRaw = driver?.state.rawValue;
287
288
  if (driver?.patch(value, formattedValue, uom, prec)) {
288
- this.logger(`Driver ${driver.label} updated from ${oldValue} to ${value} (${formattedValue})`);
289
- this.emit('propertyChanged', propertyName, value, oldValue, formattedValue);
289
+ this.logger(`Driver ${driver.label} updated from ${oldValue} (${oldValueRaw}) to ${driver.state.value} (${driver.state.rawValue})`);
290
+ //this.emit('propertyChanged', propertyName, value, oldValue, formattedValue);
290
291
  this.scenes?.forEach((element) => {
291
292
  this.logger(`Recalulating ${element.deviceFriendlyName}`);
292
293
  element.recalculateState();
@@ -592,7 +593,7 @@ export namespace ISYNode {
592
593
  export type WithDrivers<D extends DriverSignatures> =
593
594
  D extends Driver.Signatures<infer U extends keyof D> ?
594
595
  {
595
- [K in D[U]['name']]: D[U] extends { name: K } ? D[U]['value'] : unknown;
596
+ [K in D[U] as K['name']]: K['value'];
596
597
  }
597
598
  : never;
598
599
 
@@ -68,7 +68,7 @@ export class ISYBridgedDeviceBehavior<N extends ISYNode<any, D, any, any>, D ext
68
68
 
69
69
  override [Symbol.asyncDispose]() {
70
70
  this.internal.device = null;
71
-
71
+
72
72
 
73
73
  return super[Symbol.asyncDispose]();
74
74
  }
@@ -80,7 +80,7 @@ export namespace ISYBridgedDeviceBehavior {
80
80
  map?: DeviceToClusterMap<typeof this.device, any>;
81
81
  }
82
82
 
83
- export type EventsFor<D extends { [x: string]: Driver<any, any, any> }> = {
83
+ export type EventsFor<D extends { [x: string]: Driver<any,any,any,any,any,any> }> = {
84
84
  [s in keyof D as `${D[s]['name']}Changed`]: Observable<[{ driver: s; newValue: any; oldValue: any; formattedValue: string }]>;
85
85
  };
86
86
 
@@ -59,7 +59,7 @@ export function ISYClusterBehavior<T extends Constructor<ClusterBehavior> & { cl
59
59
  this.bridgedDeviceBehavior = behavior;
60
60
  //var behavior = this.agent.get(ISYBridgedDeviceBehavior);
61
61
  this._device = behavior.device as P;
62
- this._device.logger('Initializing cluster behavior');
62
+ this._device.logger(`Initializing cluster behavior: ${this.constructor.name}`);
63
63
  //@ts-ignore
64
64
 
65
65
  this.map = behavior.mapForBehavior<T>(this as unknown as T);
@@ -80,7 +80,8 @@ export function ISYClusterBehavior<T extends Constructor<ClusterBehavior> & { cl
80
80
  if (!convFunc) throw new Error(`Converter ${converter} not found`);
81
81
  this.state[key2 as string] = convFunc(this._device.drivers[driver as string].value);
82
82
  this.handlers[driver] = (newValue, oldValue, formattedValue) => {
83
- //if (convFunc) this.state[key2 as string] = convFunc(newValue);
83
+ //this.device.logger(`Handling property change for ${driver} (${key2}) with value ${newValue}`);
84
+ //if (convFunc) this.state[key2 as string] = convFunc(newValue);
84
85
  this.state[key2 as string] = convFunc(newValue);
85
86
  };
86
87
  }
@@ -102,7 +103,8 @@ export function ISYClusterBehavior<T extends Constructor<ClusterBehavior> & { cl
102
103
 
103
104
  async handlePropertyChange({ driver, newValue, oldValue, formattedValue }: PropertyChange<P>) {
104
105
  // for (const key2 in this.map.attributes) {
105
- await this.initialize();
106
+ //await this.initialize();
107
+ this.device.logger(`${this.constructor.name}: handling property change for ${String(driver)} with value ${newValue}`);
106
108
  if (this.handlers[driver]) {
107
109
  this.handlers[driver](newValue, oldValue, formattedValue);
108
110
  }