isy-nodejs 1.0.1-alpha.18 → 1.0.1-alpha.19

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.1-alpha.18",
5
+ "version": "1.0.1-alpha.19",
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": "98360c70b5fe830599dcbc8fd9c7ad44dcd55085"
72
+ "gitHead": "e12b10c35ca86c8e6a2ffa9a286ffefff8ce3677"
73
73
  }
package/src/ISY.ts CHANGED
@@ -6,7 +6,7 @@ import { parseBooleans, parseNumbers } from 'xml2js/lib/processors.js';
6
6
 
7
7
  import axios from 'axios';
8
8
  import { EventEmitter } from 'events';
9
- import winston, { format, Logger, loggers, type LeveledLogMethod } from 'winston';
9
+ import { format, Logger, loggers } from 'winston';
10
10
  import { Category } from './Definitions/Global/Categories.js';
11
11
  import { Family } from './Definitions/Global/Families.js';
12
12
  import { DeviceFactory } from './Devices/DeviceFactory.js';
@@ -30,13 +30,10 @@ export class ISYOnOffBehavior extends ISYClusterBehavior(OnOffLightRequirements.
30
30
  await super.off();
31
31
  await this.device.off();
32
32
 
33
-
34
-
35
33
  // this.device.drivers = false;
36
34
  }
37
35
 
38
36
  override toggle = async () => {
39
-
40
37
  //this.device.state = !(await this.device.state);
41
38
  };
42
39
 
@@ -45,7 +42,6 @@ export class ISYOnOffBehavior extends ISYClusterBehavior(OnOffLightRequirements.
45
42
  this.state.onOff = newValue;
46
43
  }*/
47
44
 
48
-
49
45
  return super.handlePropertyChange({ driver, newValue, oldValue, formattedValue });
50
46
  }
51
47
  }
@@ -53,7 +49,8 @@ export class ISYOnOffBehavior extends ISYClusterBehavior(OnOffLightRequirements.
53
49
  export class ISYDimmableBehavior extends ISYClusterBehavior(DimmableLightRequirements.LevelControlServer, InsteonDimmableDevice) {
54
50
  override async initialize(_options?: {}) {
55
51
  await super.initialize(_options);
56
- this.state.currentLevel = this.device.drivers.ST.value;
52
+ /*this.state.onLevel = Converter.get('Level255toZero.LightingLevel').to(this.device.drivers.OL)*/
53
+ //this.state.currentLevel = this.device.drivers.ST.value;
57
54
 
58
55
  //this.state.onLevel = this.device.drivers.OL;
59
56
  }
@@ -1,18 +1,18 @@
1
1
  import '@project-chip/matter-node.js';
2
2
  import { NodeJsEnvironment } from '@project-chip/matter-node.js/environment';
3
3
  import { StorageBackendDisk } from '@project-chip/matter-node.js/storage';
4
- import { CommissioningOptions } from '@project-chip/matter.js/behavior/system/commissioning';
5
4
  import { BridgedDeviceBasicInformationServer } from '@project-chip/matter.js/behaviors/bridged-device-basic-information';
6
5
  import { VendorId } from '@project-chip/matter.js/datatype';
7
- import { logEndpoint, OnOffBaseDevice } from '@project-chip/matter.js/device';
6
+ import { logEndpoint } from '@project-chip/matter.js/device';
8
7
  import { Endpoint, EndpointServer } from '@project-chip/matter.js/endpoint';
9
8
  import { DimmableLightDevice, OnOffLightDevice } from '@project-chip/matter.js/endpoint/definitions';
10
9
  import type { SupportedBehaviors } from '@project-chip/matter.js/endpoint/properties';
11
- import { EndpointType, MutableEndpoint } from '@project-chip/matter.js/endpoint/type';
10
+ import { MutableEndpoint } from '@project-chip/matter.js/endpoint/type';
12
11
  import { AggregatorEndpoint } from '@project-chip/matter.js/endpoints/AggregatorEndpoint';
13
12
  import { StorageService } from '@project-chip/matter.js/environment';
14
13
  import { Level, levelFromString, Logger as MatterLogger } from '@project-chip/matter.js/log';
15
14
  import { ServerNode } from '@project-chip/matter.js/node';
15
+ import PackageJson from '@project-chip/matter.js/package.json';
16
16
  import { QrCode } from '@project-chip/matter.js/schema';
17
17
  import path, { resolve } from 'path';
18
18
  import type { ISYDeviceNode } from '../../Devices/ISYDeviceNode.js';
@@ -20,10 +20,14 @@ import { InsteonDimmableDevice, InsteonKeypadButtonDevice, InsteonRelayDevice, I
20
20
  import { ISYBridgedDeviceBehavior } from '../Behaviors/ISYBridgedDeviceBehavior.js';
21
21
  import { ISYDimmableBehavior, ISYOnOffBehavior } from '../Behaviors/ISYOnOffBehavior.js';
22
22
  import '../Mappings/Insteon.js';
23
+ import { format, loggers } from 'winston';
23
24
 
24
25
  // #region Interfaces (1)
25
26
 
26
27
  export let instance: ServerNode;
28
+
29
+ //@ts-ignore
30
+ export let version: string = PackageJson.version;
27
31
  export interface Config {
28
32
  // #region Properties (8)
29
33
 
@@ -47,8 +51,13 @@ export function create(isy?: ISY, config?: Config): Promise<ServerNode> {
47
51
  return createMatterServer(isy, config);
48
52
  }
49
53
 
54
+
50
55
  export async function createMatterServer(isy?: ISY, config?: Config): Promise<ServerNode> {
51
- var logger = isy.logger;
56
+ var logger = loggers.add('matter', {
57
+ transports: isy.logger.transports,
58
+ levels: isy.logger.levels,
59
+ format: format.label({ label: 'Matter' })
60
+ });
52
61
  if (isy === undefined) {
53
62
  isy = ISY.instance;
54
63
  }
@@ -70,7 +79,6 @@ export async function createMatterServer(isy?: ISY, config?: Config): Promise<Se
70
79
  logFormat: 'plain'
71
80
  }
72
81
  );
73
-
74
82
  } finally {
75
83
  MatterLogger.defaultLogLevel = levelFromString(logger.level);
76
84
  }
@@ -231,7 +239,7 @@ export async function createMatterServer(isy?: ISY, config?: Config): Promise<Se
231
239
  if (server.lifecycle.isOnline) {
232
240
  const { qrPairingCode, manualPairingCode } = server.state.commissioning.pairingCodes;
233
241
 
234
- logger.info('/n' + QrCode.get(qrPairingCode));
242
+ logger.info('\n' + QrCode.get(qrPairingCode));
235
243
  logger.info(`QR Code URL: https://project-chip.github.io/connectedhomeip/qrcode.html?data=${qrPairingCode}`);
236
244
  logger.info(`Manual pairing code: ${manualPairingCode}`);
237
245
  }
package/src/Utils.ts CHANGED
@@ -15,6 +15,7 @@ import path from 'path';
15
15
  import { isBoxedPrimitive } from 'util/types';
16
16
  import { Family, type Driver, type DriverType, type EnumLiteral } from './Definitions/index.js';
17
17
  import { EventType } from './Events/EventType.js';
18
+ import { readFile } from 'fs/promises';
18
19
 
19
20
  export type StringKeys<T> = Extract<keyof T, string>;
20
21
 
@@ -276,20 +277,19 @@ function getImportMeta() {
276
277
  return { dirname, filename };
277
278
  }
278
279
  }
279
- export async function findPackageJson(currentPath: string = './'): Promise<PackageJson> {
280
+ export async function findPackageJson(currentPath: string = getImportMeta().dirname): Promise<PackageJson> {
280
281
  try {
281
282
  while (currentPath !== '/') {
282
283
  const packageJsonPath = path.join(currentPath, 'package.json');
283
284
  if (existsSync(packageJsonPath)) {
284
- try {
285
- return await import(packageJsonPath);
286
- } catch {}
285
+ return JSON.parse(await readFile(packageJsonPath, 'utf8'));
287
286
  }
288
287
  currentPath = path.join(currentPath, '..');
289
288
  }
290
289
  } catch {
290
+
291
291
  //@ts-expect-error
292
- return await import('package.json');
292
+ return (await import ('package.json')).default;
293
293
  }
294
294
  return null;
295
295
  }