isy-nodejs 1.0.1-alpha.5 → 1.0.1-alpha.9

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 (225) hide show
  1. package/dist/cjs/Converters.js +66 -30
  2. package/dist/cjs/Converters.js.map +1 -1
  3. package/dist/cjs/Definitions/Global/Drivers.js +10 -3
  4. package/dist/cjs/Definitions/Global/Drivers.js.map +1 -1
  5. package/dist/cjs/Definitions/Global/Events.js +1 -2
  6. package/dist/cjs/Definitions/Global/Events.js.map +1 -1
  7. package/dist/cjs/Devices/Elk/ElkAlarmPanelDevice.js +3 -3
  8. package/dist/cjs/Devices/Elk/ElkAlarmSensorDevice.js +9 -6
  9. package/dist/cjs/Devices/Elk/ElkAlarmSensorDevice.js.map +1 -1
  10. package/dist/cjs/Devices/Insteon/InsteonBaseDevice.js +1 -1
  11. package/dist/cjs/Devices/Insteon/InsteonBaseDevice.js.map +1 -1
  12. package/dist/cjs/Devices/Insteon/InsteonFanDevice.js +5 -3
  13. package/dist/cjs/Devices/Insteon/InsteonFanDevice.js.map +1 -1
  14. package/dist/cjs/Devices/Insteon/InsteonMotionSensorDevice.js +5 -5
  15. package/dist/cjs/Devices/Insteon/InsteonRelayDevice.js +3 -9
  16. package/dist/cjs/Devices/Insteon/InsteonRelayDevice.js.map +1 -1
  17. package/dist/cjs/Devices/Insteon/RelayLampSwitch.js +72 -0
  18. package/dist/cjs/Devices/Insteon/RelayLampSwitch.js.map +1 -0
  19. package/dist/cjs/ISY.js +36 -27
  20. package/dist/cjs/ISY.js.map +1 -1
  21. package/dist/cjs/ISYNode.js +12 -9
  22. package/dist/cjs/ISYNode.js.map +1 -1
  23. package/dist/cjs/ISYScene.js +3 -3
  24. package/dist/cjs/ISYScene.js.map +1 -1
  25. package/dist/cjs/Matter/Behaviors/ISYBridgedDeviceBehavior.js +11 -4
  26. package/dist/cjs/Matter/Behaviors/ISYBridgedDeviceBehavior.js.map +1 -1
  27. package/dist/cjs/Matter/Behaviors/ISYClusterBehavior.js +26 -7
  28. package/dist/cjs/Matter/Behaviors/ISYClusterBehavior.js.map +1 -1
  29. package/dist/cjs/Matter/Behaviors/ISYOnOffBehavior.js +9 -7
  30. package/dist/cjs/Matter/Behaviors/ISYOnOffBehavior.js.map +1 -1
  31. package/dist/cjs/Matter/{Server → Bridge}/Server.js +31 -45
  32. package/dist/cjs/Matter/Bridge/Server.js.map +1 -0
  33. package/dist/cjs/Matter/Mappings/Insteon.js +19 -15
  34. package/dist/cjs/Matter/Mappings/Insteon.js.map +1 -1
  35. package/dist/cjs/Matter/Mappings/register.js +1 -0
  36. package/dist/cjs/Matter/Mappings/register.js.map +1 -0
  37. package/dist/cjs/Model/ClusterMap.js +12 -9
  38. package/dist/cjs/Model/ClusterMap.js.map +1 -1
  39. package/dist/cjs/Utils.js +0 -9
  40. package/dist/cjs/Utils.js.map +1 -1
  41. package/dist/cjs/types/Converters.d.ts +28 -8
  42. package/dist/cjs/types/Converters.d.ts.map +1 -1
  43. package/dist/cjs/types/Definitions/Global/Drivers.d.ts +4 -3
  44. package/dist/cjs/types/Definitions/Global/Drivers.d.ts.map +1 -1
  45. package/dist/cjs/types/Definitions/Global/Events.d.ts.map +1 -1
  46. package/dist/cjs/types/Devices/Elk/ElkAlarmSensorDevice.d.ts.map +1 -1
  47. package/dist/cjs/types/Devices/EndpointFor.d.ts +2 -2
  48. package/dist/cjs/types/Devices/Insteon/InsteonDevice.d.ts +4 -4
  49. package/dist/cjs/types/Devices/Insteon/InsteonFanDevice.d.ts.map +1 -1
  50. package/dist/cjs/types/Devices/Insteon/InsteonRelayDevice.d.ts +2 -4
  51. package/dist/cjs/types/Devices/Insteon/InsteonRelayDevice.d.ts.map +1 -1
  52. package/dist/cjs/types/Devices/Insteon/RelayLampSwitch.d.ts +93 -0
  53. package/dist/cjs/types/Devices/Insteon/RelayLampSwitch.d.ts.map +1 -0
  54. package/dist/cjs/types/ISY.d.ts +21 -18
  55. package/dist/cjs/types/ISY.d.ts.map +1 -1
  56. package/dist/cjs/types/ISYNode.d.ts +4 -4
  57. package/dist/cjs/types/ISYNode.d.ts.map +1 -1
  58. package/dist/cjs/types/Matter/Behaviors/ISYBridgedDeviceBehavior.d.ts +16 -6
  59. package/dist/cjs/types/Matter/Behaviors/ISYBridgedDeviceBehavior.d.ts.map +1 -1
  60. package/dist/cjs/types/Matter/Behaviors/ISYClusterBehavior.d.ts +13 -11
  61. package/dist/cjs/types/Matter/Behaviors/ISYClusterBehavior.d.ts.map +1 -1
  62. package/dist/cjs/types/Matter/Behaviors/ISYOnOffBehavior.d.ts +4 -4
  63. package/dist/cjs/types/Matter/Behaviors/ISYOnOffBehavior.d.ts.map +1 -1
  64. package/dist/cjs/types/Matter/Bridge/Server.d.ts +17 -0
  65. package/dist/cjs/types/Matter/Bridge/Server.d.ts.map +1 -0
  66. package/dist/cjs/types/Matter/Mappings/register.d.ts +1 -0
  67. package/dist/cjs/types/Matter/Mappings/register.d.ts.map +1 -0
  68. package/dist/cjs/types/Model/ClusterMap.d.ts +19 -11
  69. package/dist/cjs/types/Model/ClusterMap.d.ts.map +1 -1
  70. package/dist/cjs/types/Utils.d.ts +0 -5
  71. package/dist/cjs/types/Utils.d.ts.map +1 -1
  72. package/dist/esm/Converters.js +63 -28
  73. package/dist/esm/Converters.js.map +1 -1
  74. package/dist/esm/Definitions/Global/Drivers.js +10 -3
  75. package/dist/esm/Definitions/Global/Drivers.js.map +1 -1
  76. package/dist/esm/Definitions/Global/Events.js +1 -2
  77. package/dist/esm/Definitions/Global/Events.js.map +1 -1
  78. package/dist/esm/Devices/Brultech/index.js +4 -0
  79. package/dist/esm/Devices/Brultech/index.js.map +1 -0
  80. package/dist/esm/Devices/Constructor.js +2 -0
  81. package/dist/esm/Devices/Constructor.js.map +1 -0
  82. package/dist/esm/Devices/DeviceFactory.js +13 -0
  83. package/dist/esm/Devices/DeviceFactory.js.map +1 -0
  84. package/dist/esm/Devices/DeviceMap.js +4 -0
  85. package/dist/esm/Devices/DeviceMap.js.map +1 -0
  86. package/dist/esm/Devices/Elk/ElkAlarmPanelDevice.js +181 -0
  87. package/dist/esm/Devices/Elk/ElkAlarmPanelDevice.js.map +1 -0
  88. package/dist/esm/Devices/Elk/ElkAlarmSensorDevice.js +110 -0
  89. package/dist/esm/Devices/Elk/ElkAlarmSensorDevice.js.map +1 -0
  90. package/dist/esm/Devices/EndpointFor.js +31 -0
  91. package/dist/esm/Devices/EndpointFor.js.map +1 -0
  92. package/dist/esm/Devices/ISYDevice.js +35 -0
  93. package/dist/esm/Devices/ISYDevice.js.map +1 -0
  94. package/dist/esm/Devices/ISYDeviceNode.js +62 -0
  95. package/dist/esm/Devices/ISYDeviceNode.js.map +1 -0
  96. package/dist/esm/Devices/ISYMultiNodeDevice.js +89 -0
  97. package/dist/esm/Devices/ISYMultiNodeDevice.js.map +1 -0
  98. package/dist/esm/Devices/Insteon/InsteonBallastDimmerDevice.js +8 -0
  99. package/dist/esm/Devices/Insteon/InsteonBallastDimmerDevice.js.map +1 -0
  100. package/dist/esm/Devices/Insteon/InsteonBaseDevice.js +2 -2
  101. package/dist/esm/Devices/Insteon/InsteonBaseDevice.js.map +1 -1
  102. package/dist/esm/Devices/Insteon/InsteonDimmerOutletDevice.js +7 -0
  103. package/dist/esm/Devices/Insteon/InsteonDimmerOutletDevice.js.map +1 -0
  104. package/dist/esm/Devices/Insteon/InsteonDimmerSwitchDevice.js +8 -0
  105. package/dist/esm/Devices/Insteon/InsteonDimmerSwitchDevice.js.map +1 -0
  106. package/dist/esm/Devices/Insteon/InsteonFanDevice.js +5 -3
  107. package/dist/esm/Devices/Insteon/InsteonFanDevice.js.map +1 -1
  108. package/dist/esm/Devices/Insteon/InsteonKeypadDimmerDevice.js +8 -0
  109. package/dist/esm/Devices/Insteon/InsteonKeypadDimmerDevice.js.map +1 -0
  110. package/dist/esm/Devices/Insteon/InsteonMotionSensorDevice.js +5 -5
  111. package/dist/esm/Devices/Insteon/InsteonRelayDevice.js +3 -9
  112. package/dist/esm/Devices/Insteon/InsteonRelayDevice.js.map +1 -1
  113. package/dist/esm/Devices/Insteon/RelayLampSwitch.js +68 -0
  114. package/dist/esm/Devices/Insteon/RelayLampSwitch.js.map +1 -0
  115. package/dist/esm/Devices/Lutron/index.js +4 -0
  116. package/dist/esm/Devices/Lutron/index.js.map +1 -0
  117. package/dist/esm/Devices/MapsTo.js +2 -0
  118. package/dist/esm/Devices/MapsTo.js.map +1 -0
  119. package/dist/esm/Devices/NCD/index.js +4 -0
  120. package/dist/esm/Devices/NCD/index.js.map +1 -0
  121. package/dist/esm/Devices/NodeFactory.js +48 -0
  122. package/dist/esm/Devices/NodeFactory.js.map +1 -0
  123. package/dist/esm/Devices/Poly/index.js +4 -0
  124. package/dist/esm/Devices/Poly/index.js.map +1 -0
  125. package/dist/esm/Devices/Scene/index.js +4 -0
  126. package/dist/esm/Devices/Scene/index.js.map +1 -0
  127. package/dist/esm/Devices/UDI/index.js +4 -0
  128. package/dist/esm/Devices/UDI/index.js.map +1 -0
  129. package/dist/esm/Devices/ZWave/ZWaveBaseDevice.js +38 -0
  130. package/dist/esm/Devices/ZWave/ZWaveBaseDevice.js.map +1 -0
  131. package/dist/esm/Devices/ZWave/ZWaveDimmerSwitchDevice.js +8 -0
  132. package/dist/esm/Devices/ZWave/ZWaveDimmerSwitchDevice.js.map +1 -0
  133. package/dist/esm/Devices/ZWave/ZWaveLockDevice.js +35 -0
  134. package/dist/esm/Devices/ZWave/ZWaveLockDevice.js.map +1 -0
  135. package/dist/esm/Devices/ZWave/index.js +20 -0
  136. package/dist/esm/Devices/ZWave/index.js.map +1 -0
  137. package/dist/esm/Devices/index.js +9 -0
  138. package/dist/esm/Devices/index.js.map +1 -0
  139. package/dist/esm/ISY.js +35 -26
  140. package/dist/esm/ISY.js.map +1 -1
  141. package/dist/esm/ISYNode.js +13 -10
  142. package/dist/esm/ISYNode.js.map +1 -1
  143. package/dist/esm/ISYScene.js +3 -3
  144. package/dist/esm/ISYScene.js.map +1 -1
  145. package/dist/esm/Matter/Behaviors/ISYBridgedDeviceBehavior.js +11 -4
  146. package/dist/esm/Matter/Behaviors/ISYBridgedDeviceBehavior.js.map +1 -1
  147. package/dist/esm/Matter/Behaviors/ISYClusterBehavior.js +26 -7
  148. package/dist/esm/Matter/Behaviors/ISYClusterBehavior.js.map +1 -1
  149. package/dist/esm/Matter/Behaviors/ISYOnOffBehavior.js +10 -8
  150. package/dist/esm/Matter/Behaviors/ISYOnOffBehavior.js.map +1 -1
  151. package/dist/esm/Matter/{Server → Bridge}/Server.js +29 -44
  152. package/dist/esm/Matter/Bridge/Server.js.map +1 -0
  153. package/dist/esm/Matter/Mappings/Insteon.js +22 -18
  154. package/dist/esm/Matter/Mappings/Insteon.js.map +1 -1
  155. package/dist/esm/Matter/Mappings/register.js +2 -0
  156. package/dist/esm/Matter/Mappings/register.js.map +1 -0
  157. package/dist/esm/Model/ClusterMap.js +12 -9
  158. package/dist/esm/Model/ClusterMap.js.map +1 -1
  159. package/dist/esm/Utils.js +0 -8
  160. package/dist/esm/Utils.js.map +1 -1
  161. package/dist/esm/types/Converters.d.ts +28 -8
  162. package/dist/esm/types/Converters.d.ts.map +1 -1
  163. package/dist/esm/types/Definitions/Global/Drivers.d.ts +4 -3
  164. package/dist/esm/types/Definitions/Global/Drivers.d.ts.map +1 -1
  165. package/dist/esm/types/Definitions/Global/Events.d.ts.map +1 -1
  166. package/dist/esm/types/Devices/Elk/ElkAlarmSensorDevice.d.ts.map +1 -1
  167. package/dist/esm/types/Devices/EndpointFor.d.ts +2 -2
  168. package/dist/esm/types/Devices/Insteon/InsteonDevice.d.ts +4 -4
  169. package/dist/esm/types/Devices/Insteon/InsteonFanDevice.d.ts.map +1 -1
  170. package/dist/esm/types/Devices/Insteon/InsteonRelayDevice.d.ts +2 -4
  171. package/dist/esm/types/Devices/Insteon/InsteonRelayDevice.d.ts.map +1 -1
  172. package/dist/esm/types/Devices/Insteon/RelayLampSwitch.d.ts +93 -0
  173. package/dist/esm/types/Devices/Insteon/RelayLampSwitch.d.ts.map +1 -0
  174. package/dist/esm/types/ISY.d.ts +21 -18
  175. package/dist/esm/types/ISY.d.ts.map +1 -1
  176. package/dist/esm/types/ISYNode.d.ts +4 -4
  177. package/dist/esm/types/ISYNode.d.ts.map +1 -1
  178. package/dist/esm/types/Matter/Behaviors/ISYBridgedDeviceBehavior.d.ts +16 -6
  179. package/dist/esm/types/Matter/Behaviors/ISYBridgedDeviceBehavior.d.ts.map +1 -1
  180. package/dist/esm/types/Matter/Behaviors/ISYClusterBehavior.d.ts +13 -11
  181. package/dist/esm/types/Matter/Behaviors/ISYClusterBehavior.d.ts.map +1 -1
  182. package/dist/esm/types/Matter/Behaviors/ISYOnOffBehavior.d.ts +4 -4
  183. package/dist/esm/types/Matter/Behaviors/ISYOnOffBehavior.d.ts.map +1 -1
  184. package/dist/esm/types/Matter/Bridge/Server.d.ts +17 -0
  185. package/dist/esm/types/Matter/Bridge/Server.d.ts.map +1 -0
  186. package/dist/esm/types/Matter/Mappings/register.d.ts +2 -0
  187. package/dist/esm/types/Matter/Mappings/register.d.ts.map +1 -0
  188. package/dist/esm/types/Model/ClusterMap.d.ts +19 -11
  189. package/dist/esm/types/Model/ClusterMap.d.ts.map +1 -1
  190. package/dist/esm/types/Utils.d.ts +0 -5
  191. package/dist/esm/types/Utils.d.ts.map +1 -1
  192. package/package.json +4 -7
  193. package/src/Converters.ts +137 -69
  194. package/src/Definitions/Global/Drivers.ts +16 -7
  195. package/src/Definitions/Global/Events.ts +4 -3
  196. package/src/Devices/Elk/ElkAlarmPanelDevice.ts +3 -3
  197. package/src/Devices/Elk/ElkAlarmSensorDevice.ts +15 -21
  198. package/src/Devices/Insteon/Generated/RelayLamp.ts +8 -7
  199. package/src/Devices/Insteon/InsteonBaseDevice.ts +2 -2
  200. package/src/Devices/Insteon/InsteonFanDevice.ts +12 -10
  201. package/src/Devices/Insteon/InsteonMotionSensorDevice.ts +5 -5
  202. package/src/Devices/Insteon/InsteonRelayDevice.ts +3 -6
  203. package/src/Devices/Insteon/RelayLampSwitch.ts +131 -0
  204. package/src/ISY.ts +57 -42
  205. package/src/ISYNode.ts +14 -11
  206. package/src/ISYScene.ts +3 -3
  207. package/src/Matter/Behaviors/ISYBridgedDeviceBehavior.ts +29 -11
  208. package/src/Matter/Behaviors/ISYClusterBehavior.ts +46 -28
  209. package/src/Matter/Behaviors/ISYOnOffBehavior.ts +49 -60
  210. package/src/Matter/{Server → Bridge}/Server.ts +50 -50
  211. package/src/Matter/Mappings/Insteon.ts +53 -60
  212. package/src/Matter/Mappings/register.ts +0 -0
  213. package/src/Model/ClassDefinition.ts +1 -1
  214. package/src/Model/ClusterMap.ts +31 -22
  215. package/src/Utils.ts +1 -19
  216. package/tsconfig.json +2 -2
  217. package/LICENSE +0 -22
  218. package/dist/cjs/Matter/Server/Server.js.map +0 -1
  219. package/dist/cjs/types/Matter/Server/Server.d.ts +0 -4
  220. package/dist/cjs/types/Matter/Server/Server.d.ts.map +0 -1
  221. package/dist/esm/Matter/Server/Server.js.map +0 -1
  222. package/dist/esm/types/Matter/Server/Server.d.ts +0 -4
  223. package/dist/esm/types/Matter/Server/Server.d.ts.map +0 -1
  224. package/dist/tsconfig.cjs.tsbuildinfo +0 -1
  225. package/dist/tsconfig.esm.tsbuildinfo +0 -1
@@ -1,38 +1,50 @@
1
- import type { ClusterBehavior, ClusterInterface } from '@project-chip/matter.js/behavior/cluster';
2
-
3
- import type { DriversOf, ISYNode } from '../../ISYNode.js';
4
-
5
1
  import type { Behavior } from '@project-chip/matter.js/behavior';
2
+ import type { ClusterBehavior, ClusterInterface } from '@project-chip/matter.js/behavior/cluster';
6
3
  import { BridgedDeviceBasicInformationServer } from '@project-chip/matter.js/behaviors/bridged-device-basic-information';
7
4
  import type { LevelControlBehavior } from '@project-chip/matter.js/behaviors/level-control';
8
5
  import type { OnOffBehavior, OnOffServer } from '@project-chip/matter.js/behaviors/on-off';
9
6
  import type { Cluster, ClusterServerHandlers, ClusterType as CT } from '@project-chip/matter.js/cluster';
10
7
  import '@project-chip/matter.js/device';
11
8
  import { OnOffLightRequirements } from '@project-chip/matter.js/devices/OnOffLightDevice';
12
- import { DriverType } from '../../Definitions/Global/Drivers.js';
9
+ import { Converter } from '../../Converters.js';
10
+ import { Driver, DriverType } from '../../Definitions/Global/Drivers.js';
13
11
  import type { Constructor } from '../../Devices/Constructor.js';
14
12
  import type { RelaxTypes } from '../../Devices/MapsTo.js';
15
13
  import { ISY, type ISYDevice } from '../../ISY.js';
16
- import { MappingRegistry, type ClusterMapping, type DeviceToClusterMap } from '../../Model/ClusterMap.js';
17
-
14
+ import type { DriversOf, ISYNode } from '../../ISYNode.js';
15
+ import { BehaviorMapping, MappingRegistry, type ClusterMapping, type DeviceToClusterMap } from '../../Model/ClusterMap.js';
18
16
  import { ISYBridgedDeviceBehavior } from './ISYBridgedDeviceBehavior.js';
19
17
 
20
- type NotUnknown<T extends ClusterBehavior> = T extends { cluster: { name: 'Unknown' } } ? never : T;
18
+ // #region Type aliases (6)
21
19
 
20
+ export type ClusterForBehavior<B> = B extends ClusterBehavior.Type<infer C, infer D, infer E> ? C : never;
22
21
  export type ConstructedType<B extends Constructor<any>> = B extends Constructor<infer C> ? C : never;
22
+ // <reference path="MatterDevice.js" />
23
+ // @ts-ignore
24
+ export type DeviceBehavior<P extends ISYNode, T extends { cluster? }> = {
25
+ device: P;
23
26
 
24
- export type ClusterForBehavior<B> = B extends ClusterBehavior.Type<infer C, infer D, infer E> ? C : never;
27
+ bridgedDeviceBehavior: ISYBridgedDeviceBehavior<P>;
25
28
 
26
- type t = ClusterForBehavior<LevelControlBehavior>;
29
+ //ts-ignore
30
+ map: BehaviorMapping<T, P>;
27
31
 
32
+ handlePropertyChange(chg: PropertyChange<P>): void;
33
+ };
34
+ type NotUnknown<T extends ClusterBehavior> = T extends { cluster: { name: 'Unknown' } } ? never : T;
28
35
  export type PropertyChange<P extends ISYNode<any, any, any, any>> = {
29
36
  driver: keyof DriversOf<P>;
30
37
  newValue: any;
31
38
  oldValue: any;
32
39
  formattedValue: string;
33
40
  };
41
+ type t = ClusterForBehavior<LevelControlBehavior>;
42
+
43
+ // #endregion Type aliases (6)
34
44
 
35
- export function ISYClusterBehavior<T extends Constructor<ClusterBehavior> & { cluster: unknown }, P extends ISYNode<any, any, any, any>>(
45
+ // #region Functions (1)
46
+
47
+ export function ISYClusterBehavior<T extends Constructor<ClusterBehavior> & { cluster }, P extends ISYNode<any, any, any, any>>(
36
48
  base: T,
37
49
  p: Constructor<P>
38
50
  ): typeof base & { new (...args: any[]): DeviceBehavior<P, T> } {
@@ -41,30 +53,44 @@ export function ISYClusterBehavior<T extends Constructor<ClusterBehavior> & { cl
41
53
 
42
54
  handlers: { [x in keyof DriversOf<P>]: (newValue, oldValue, formattedValue) => void } = {} as any;
43
55
 
56
+ bridgedDeviceBehavior: ISYBridgedDeviceBehavior<P>;
44
57
  ///public map: ClusterMapping<ToClusterTypeByName<ClusterForBehavior<ConstructedType<typeof base>>["name"]>,ISYDeviceNode<any, any, any>>;
45
58
 
46
- map: ClusterMapping<T['cluster'], P>;
59
+ map: BehaviorMapping<T, P>;
47
60
 
48
61
  override async initialize(_options?: {}) {
49
62
  await super.initialize(_options);
50
- var behavior = await this.agent.load(ISYBridgedDeviceBehavior);
63
+ var behavior = (await this.agent.load(ISYBridgedDeviceBehavior)) as ISYBridgedDeviceBehavior<P>;
64
+ this.bridgedDeviceBehavior = behavior;
51
65
  //var behavior = this.agent.get(ISYBridgedDeviceBehavior);
52
66
  this._device = behavior.device as P;
67
+ //@ts-ignore
53
68
  this.map = behavior.mapForBehavior<T>(this as unknown as T);
54
69
  for (const key2 in this.map.attributes) {
55
- if (typeof this.map.attributes[key2] === 'string') {
56
- this.handlers[this.map.attributes[key2]] = (newValue, oldValue, formattedValue) => {
70
+ let val = this.map.attributes[key2];
71
+ let driverObj = null;
72
+ if (typeof val === 'string' || typeof val === 'symbol' || typeof val === 'number') {
73
+ driverObj = this._device.drivers[val];
74
+ this.handlers[val] = (newValue, oldValue, formattedValue) => {
57
75
  this.state[key2 as string] = newValue;
58
76
  };
59
- } else if (this.map.attributes[key2].driver) {
60
- let { driver, converter } = this.map.attributes[key2];
77
+ } else if (val.driver as DriversOf<P>) {
78
+ driverObj = this._device.drivers[val.driver as string];
79
+
80
+ let { driver, converter } = val;
81
+ const convFunc = Converter.get(converter)?.from;
61
82
  this.handlers[driver] = (newValue, oldValue, formattedValue) => {
62
- this.state[key2 as string] = converter(newValue);
83
+ if (convFunc) this.state[key2 as string] = convFunc(newValue);
84
+ else this.state[key2 as string] = newValue;
63
85
  };
64
86
  }
87
+ if (driverObj) {
88
+ let evt = `${driverObj.name}Changed`;
89
+ this.reactTo(behavior.events[evt], this.handlePropertyChange.bind(this), { lock: false });
90
+ }
65
91
  }
66
92
 
67
- this.reactTo(behavior.events.propertyChanged, this.handlePropertyChange, { lock: false });
93
+ //this.reactTo(behavior.events.propertyChanged, this.handlePropertyChange, { lock: false });
68
94
 
69
95
  //this._device.on("PropertyChanged", this.handlePropertyChange.bind(this));
70
96
  }
@@ -95,13 +121,5 @@ export function ISYClusterBehavior<T extends Constructor<ClusterBehavior> & { cl
95
121
  }
96
122
  };
97
123
  }
98
- // <reference path="MatterDevice.js" />
99
- // @ts-ignore
100
-
101
- export type DeviceBehavior<P extends ISYNode, T extends { cluster }> = {
102
- device: P;
103
124
 
104
- map: ClusterMapping<T['cluster'], P>;
105
-
106
- handlePropertyChange(chg: PropertyChange<P>): void;
107
- };
125
+ // #endregion Functions (1)
@@ -1,80 +1,69 @@
1
- import { InsteonRelayDevice } from "../../Devices/Insteon/InsteonRelayDevice.js"
2
- import { OnOffLightRequirements } from "@project-chip/matter.js/devices/OnOffLightDevice";
3
- import { ISYClusterBehavior, ClusterForBehavior, type PropertyChange } from "./ISYClusterBehavior.js";
1
+ import type { LevelControlInterface, LevelControlServer } from '@project-chip/matter.js/behaviors/level-control';
2
+ import type { OnOffBehavior, OnOffServer } from '@project-chip/matter.js/behaviors/on-off';
3
+ import type { MutableCluster, OnOffCluster } from '@project-chip/matter.js/cluster';
4
+ import { DimmableLightRequirements } from '@project-chip/matter.js/devices/DimmableLightDevice';
5
+ import { OnOffLightRequirements } from '@project-chip/matter.js/devices/OnOffLightDevice';
4
6
  import { OnOffLightSwitchDevice } from '@project-chip/matter.js/devices/OnOffLightSwitchDevice';
5
7
  import type { MaybePromise } from '@project-chip/matter.js/util';
6
- import { MappingRegistry } from '../../Model/ClusterMap.js';
7
- import type { MutableCluster, OnOffCluster } from '@project-chip/matter.js/cluster';
8
- import type { OnOffBehavior, OnOffServer } from '@project-chip/matter.js/behaviors/on-off';
9
- import type { LevelControlServer, LevelControlInterface } from '@project-chip/matter.js/behaviors/level-control';
10
8
  import { DriverType } from '../../Definitions/Global/Drivers.js';
11
- import { DimmableLightRequirements } from '@project-chip/matter.js/devices/DimmableLightDevice';
12
9
  import { InsteonDimmableDevice } from '../../Devices/Insteon/InsteonDimmableDevice.js';
10
+ import { InsteonRelayDevice } from '../../Devices/Insteon/InsteonRelayDevice.js';
11
+ import { MappingRegistry } from '../../Model/ClusterMap.js';
12
+ import { ClusterForBehavior, ISYClusterBehavior, type PropertyChange } from './ISYClusterBehavior.js';
13
13
 
14
- import {Converters} from '../../Converters.js';
15
-
16
-
17
-
18
-
19
-
20
- export class ISYOnOffBehavior extends ISYClusterBehavior(OnOffLightRequirements.OnOffServer, InsteonRelayDevice)
21
- {
22
-
23
- override async initialize(_options?: {}) {
24
- await super.initialize(_options);
25
- //this.state.onOff = await this.device.state;
26
-
27
-
14
+ import { Converter } from '../../Converters.js';
28
15
 
29
- }
16
+ export class ISYOnOffBehavior extends ISYClusterBehavior(OnOffLightRequirements.OnOffServer, InsteonRelayDevice) {
17
+ override async initialize(_options?: {}) {
18
+ await super.initialize(_options);
19
+ //this.state.onOff = await this.device.state;
20
+ }
30
21
 
22
+ override on = async () => {
23
+ await super.on();
24
+ await this.device.on();
31
25
 
32
- override on = async () => {
33
- await super.on();
26
+ //this.device.commands.DON = true;
27
+ };
34
28
 
29
+ override async off() {
30
+ await super.off();
31
+ await this.device.off();
35
32
 
36
- //this.device.commands.DON = true;
37
- }
38
33
 
39
- override async off() {
40
- //await super.off();
41
- // this.device.drivers = false;
42
- }
43
34
 
44
- override toggle = async () => {
45
- //this.device.state = !(await this.device.state);
46
- }
35
+ // this.device.drivers = false;
36
+ }
47
37
 
48
- override async handlePropertyChange({driver, newValue, oldValue, formattedValue}: PropertyChange<InsteonRelayDevice>) {
49
- if (driver === "ST") {
50
- this.state.onOff = newValue;
38
+ override toggle = async () => {
51
39
 
52
- }
40
+ //this.device.state = !(await this.device.state);
41
+ };
53
42
 
54
- return super.handlePropertyChange({driver, newValue, oldValue, formattedValue});
55
- }
43
+ override async handlePropertyChange({ driver, newValue, oldValue, formattedValue }: PropertyChange<InsteonRelayDevice>) {
44
+ /*if (driver === 'ST') {
45
+ this.state.onOff = newValue;
46
+ }*/
56
47
 
57
48
 
49
+ return super.handlePropertyChange({ driver, newValue, oldValue, formattedValue });
50
+ }
58
51
  }
59
52
 
60
-
61
53
  export class ISYDimmableBehavior extends ISYClusterBehavior(DimmableLightRequirements.LevelControlServer, InsteonDimmableDevice) {
62
- override async initialize(_options?: {}) {
63
- await super.initialize(_options);
64
- this.state.currentLevel = this.device.drivers.ST.value;
65
- //this.state.onLevel = this.device.drivers.OL;
66
-
67
- }
68
-
69
- override setLevel(level: number): MaybePromise<void> {
70
- level = Converters.Matter.LevelFrom0To255.LightingLevel.to(level);
71
- if(level > 0)
72
- {
73
- return this.device.sendCommand('DON',level);
74
- }
75
- else
76
- {
77
- return this.device.sendCommand('DOF');
78
- }
79
- }
80
- }
54
+ override async initialize(_options?: {}) {
55
+ await super.initialize(_options);
56
+ this.state.currentLevel = this.device.drivers.ST.value;
57
+
58
+ //this.state.onLevel = this.device.drivers.OL;
59
+ }
60
+
61
+ override setLevel(level: number): MaybePromise<void> {
62
+ level = Converter.Matter.LevelFrom0To255.LightingLevel.from(level);
63
+ if (level > 0) {
64
+ return this.device.sendCommand('DON', level);
65
+ } else {
66
+ return this.device.sendCommand('DOF');
67
+ }
68
+ }
69
+ }
@@ -1,5 +1,7 @@
1
+ import '@project-chip/matter-node.js';
1
2
  import { NodeJsEnvironment } from '@project-chip/matter-node.js/environment';
2
3
  import { StorageBackendDisk } from '@project-chip/matter-node.js/storage';
4
+ import { CommissioningOptions } from '@project-chip/matter.js/behavior/system/commissioning';
3
5
  import { BridgedDeviceBasicInformationServer } from '@project-chip/matter.js/behaviors/bridged-device-basic-information';
4
6
  import { VendorId } from '@project-chip/matter.js/datatype';
5
7
  import { logEndpoint, OnOffBaseDevice } from '@project-chip/matter.js/device';
@@ -8,42 +10,47 @@ import { DimmableLightDevice, OnOffLightDevice } from '@project-chip/matter.js/e
8
10
  import type { SupportedBehaviors } from '@project-chip/matter.js/endpoint/properties';
9
11
  import { EndpointType, MutableEndpoint } from '@project-chip/matter.js/endpoint/type';
10
12
  import { AggregatorEndpoint } from '@project-chip/matter.js/endpoints/AggregatorEndpoint';
11
- import { Environment, StorageService } from '@project-chip/matter.js/environment';
13
+ import { StorageService } from '@project-chip/matter.js/environment';
12
14
  import { Level, levelFromString, Logger as MatterLogger } from '@project-chip/matter.js/log';
13
15
  import { ServerNode } from '@project-chip/matter.js/node';
14
16
  import { QrCode } from '@project-chip/matter.js/schema';
15
17
  import { resolve } from 'path';
16
- import { config } from 'winston';
17
18
  import { InsteonDimmableDevice, InsteonKeypadButtonDevice, InsteonRelayDevice, ISY } from '../../ISY.js';
18
19
  import { ISYBridgedDeviceBehavior } from '../Behaviors/ISYBridgedDeviceBehavior.js';
19
20
  import { ISYDimmableBehavior, ISYOnOffBehavior } from '../Behaviors/ISYOnOffBehavior.js';
21
+ import '../Mappings/Insteon.js';
22
+ import type { ISYDeviceNode } from '../../Devices/ISYDeviceNode.js';
20
23
 
21
- // #region Functions (2)
24
+ // #region Interfaces (1)
22
25
 
23
- //import {clone} from 'isy-nodejs/Utils';
24
- //let { Utils } = await import ('isy-nodejs');
26
+ export interface Config {
27
+ // #region Properties (8)
25
28
 
26
- // function plainLogFormatter(now: Date, level: Level, facility: string, prefix: string, values: any[]) {
27
- // const creator = plaintextCreator();
29
+ discriminator: number;
30
+ passcode: number;
31
+ port: number;
32
+ productId: number;
33
+ productName?: string;
34
+ uniqueId: string;
35
+ vendorId: number;
36
+ vendorName?: string;
28
37
 
29
- // const formattedValues = renderDiagnostic(values, {
30
- // ...creator,
31
- // key: text => creator.text(`${text}: `),
32
- // value: producer => creator.text(producer()),
33
- // strong: producer => creator.text(`*${producer()}*`),
34
- // weak: producer => creator.text(producer()),
35
- // status: (status, producer) => `${creator.text(statusIcon(status))}${producer()}`,
36
- // via: text => creator.text(text),
37
- // });
38
+ // #endregion Properties (8)
39
+ }
40
+
41
+ // #endregion Interfaces (1)
38
42
 
39
- // return `${formatTime(now)} ${Level[level]} ${facility} ${prefix}${formattedValues}`;
40
- //
43
+ // #region Functions (3)
41
44
 
42
- //let matterLogger = clone(logger,'matter.js');
45
+ export function create(isy?: ISY, config?: Config): Promise<ServerNode> {
46
+ return createMatterServer(isy, config);
47
+ }
43
48
 
44
- //2024-07-03 16:30:43.693
45
- export async function createServerNode(isy: ISY = ISY.instance): Promise<ServerNode> {
49
+ export async function createMatterServer(isy?: ISY, config?: Config): Promise<ServerNode> {
46
50
  var logger = isy.logger;
51
+ if (isy === undefined) {
52
+ isy = ISY.instance;
53
+ }
47
54
 
48
55
  try {
49
56
  MatterLogger.addLogger(
@@ -58,7 +65,7 @@ export async function createServerNode(isy: ISY = ISY.instance): Promise<ServerN
58
65
  MatterLogger.defaultLogLevel = levelFromString(logger.level);
59
66
  }
60
67
 
61
- var config = await getConfiguration(isy);
68
+ config = await initializeConfiguration(isy, config);
62
69
 
63
70
  logger.info(`Matter config read: ${JSON.stringify(config)}`);
64
71
 
@@ -70,6 +77,7 @@ export async function createServerNode(isy: ISY = ISY.instance): Promise<ServerN
70
77
  // Optional when operating only one device on a host, Default port is 5540
71
78
  network: {
72
79
  port: config.port,
80
+
73
81
  //ipv4: false,
74
82
  discoveryCapabilities: {
75
83
  onIpNetwork: true
@@ -124,7 +132,8 @@ export async function createServerNode(isy: ISY = ISY.instance): Promise<ServerN
124
132
 
125
133
  const endpoints: { 0: Endpoint; 1: InsteonRelayDevice }[] = [];
126
134
 
127
- for (const device of isy.deviceList.values()) {
135
+ for (const node of isy.nodeMap.values()) {
136
+ let device = node as ISYDeviceNode<any, any, any>;
128
137
  let serialNumber = `${device.address.replaceAll(' ', '_').replaceAll('.', '_')}`;
129
138
  if (device.enabled && !(device instanceof InsteonKeypadButtonDevice)) {
130
139
  //const name = `OnOff ${isASocket ? "Socket" : "Light"} ${i}`;
@@ -147,6 +156,7 @@ export async function createServerNode(isy: ISY = ISY.instance): Promise<ServerN
147
156
  }
148
157
 
149
158
  if (baseBehavior !== undefined) {
159
+ //@ts-ignore
150
160
  const endpoint = new Endpoint(baseBehavior, {
151
161
  id: serialNumber,
152
162
  isyNode: {
@@ -190,9 +200,13 @@ export async function createServerNode(isy: ISY = ISY.instance): Promise<ServerN
190
200
  * offline again because we do not need anything more here. See the Full example for other starting options.
191
201
  * The QR Code is printed automatically.
192
202
  */
203
+ process.on('SIGINT', async () => {
204
+ logger.info('Bringing server offline');
205
+ server.close();
206
+ });
193
207
 
194
208
  logger.info('Bringing server online');
195
- await server.bringOnline();
209
+ await server.start();
196
210
 
197
211
  logger.info('Matter Server is online');
198
212
  /**
@@ -216,34 +230,20 @@ export async function createServerNode(isy: ISY = ISY.instance): Promise<ServerN
216
230
  logger.info(`Manual pairing code: ${manualPairingCode}`);
217
231
  }
218
232
  /*for(let e of endpoints)
219
- {
220
- e[1].initialize(e[0] as any);
221
- }*/
233
+ {
234
+ e[1].initialize(e[0] as any);
235
+ }*/
222
236
 
223
237
  return server;
224
-
225
- function createBaseBehavior(): any {
226
- let baseBehavior: any;
227
- return baseBehavior;
228
- }
229
238
  }
230
239
 
231
- async function getConfiguration(isy: ISY) {
240
+ async function initializeConfiguration(isy: ISY, config?: Config): Promise<Config> {
232
241
  var logger = isy.logger;
233
- /**
234
- * Collect all needed data
235
- *
236
- * This block collects all needed data from cli, environment or storage. Replace this with where ever your data come from.
237
- *
238
- * Note: This example uses the matter.js process storage system to store the device parameter data for convenience
239
- * and easy reuse. When you also do that be careful to not overlap with Matter-Server own storage contexts
240
- * (so maybe better not do it ;-)).
241
- */
242
242
 
243
243
  const environment = NodeJsEnvironment();
244
244
 
245
245
  const storageService = environment.get(StorageService);
246
- environment.vars.set('storage.path', ISY.instance.storagePath + '/matter');
246
+ environment.vars.set('storage.path', `${ISY.instance.storagePath}matter`);
247
247
  environment.vars.use(() => {
248
248
  const location = environment.vars.get('storage.path', environment.vars.get('path.root', '.'));
249
249
  storageService.location = location;
@@ -254,15 +254,15 @@ async function getConfiguration(isy: ISY) {
254
254
  const deviceStorage = (await storageService.open('device')).createContext('data');
255
255
 
256
256
  const vendorName = isy.vendorName;
257
- const passcode = environment.vars.number('passcode') ?? (await deviceStorage.get('passcode', 20202021));
258
- const discriminator = environment.vars.number('discriminator') ?? (await deviceStorage.get('discriminator', 3840));
257
+ const passcode = config.passcode ?? environment.vars.number('passcode') ?? (await deviceStorage.get('passcode', 20202021));
258
+ const discriminator = config.discriminator ?? environment.vars.number('discriminator') ?? (await deviceStorage.get('discriminator', 3840));
259
259
  // product name / id and vendor id should match what is in the device certificate
260
- const vendorId = environment.vars.number('vendorid') ?? (await deviceStorage.get('vendorid', 0xfff1));
261
- const productId = environment.vars.number('productid') ?? (await deviceStorage.get('productid', 0x8000));
260
+ const vendorId = config.vendorId ?? environment.vars.number('vendorid') ?? (await deviceStorage.get('vendorid', 0xfff1));
261
+ const productId = config.productId ?? environment.vars.number('productid') ?? (await deviceStorage.get('productid', 0x8000));
262
262
  const productName = isy.productName;
263
- const port = environment.vars.number('port') ?? 5540;
263
+ const port = config.port ?? environment.vars.number('port') ?? 5540;
264
264
 
265
- const uniqueId = isy.id;
265
+ const uniqueId = isy.id.replaceAll(':', '_');
266
266
  //environment.vars.string("uniqueid") ?? (await deviceStorage.get("uniqueid", Time.nowMs().toString()));
267
267
 
268
268
  // Persist basic data to keep them also on restart
@@ -287,4 +287,4 @@ async function getConfiguration(isy: ISY) {
287
287
  };
288
288
  }
289
289
 
290
- // #endregion Functions (2)
290
+ // #endregion Functions (3)
@@ -1,68 +1,61 @@
1
- import { OnOffCluster } from "@project-chip/matter.js/cluster";
2
- import { DriverType } from "../../Definitions/Global/Drivers.js";
3
- import { Family, type t } from "../../Definitions/Global/Families.js";
4
- import { Insteon } from "../../Devices/Insteon/index.js";
5
- import { Devices} from "../../Devices/index.js";
6
- import {
7
- MappingRegistry,
8
- type FamilyToClusterMap,
9
- type DeviceToClusterMap,
10
- type EndpointMapping
11
- } from "../../Model/ClusterMap.js";
12
- import { DeviceTypeDefinition, DeviceTypes, OnOffBaseDevice } from "@project-chip/matter.js/device";
13
- import { OnOffLightDevice } from "@project-chip/matter.js/devices/OnOffLightDevice";
1
+ import { OnOffCluster } from '@project-chip/matter.js/cluster';
2
+ import { DeviceTypeDefinition, DeviceTypes, OnOffBaseDevice } from '@project-chip/matter.js/device';
3
+ import { OnOffLightDevice } from '@project-chip/matter.js/devices/OnOffLightDevice';
4
+ import { DriverType } from '../../Definitions/Global/Drivers.js';
5
+ import { Family, type t } from '../../Definitions/Global/Families.js';
6
+ import { Insteon } from '../../Devices/Insteon/index.js';
7
+ import { Devices } from '../../Devices/index.js';
8
+ import { MappingRegistry, type DeviceToClusterMap, type EndpointMapping, type FamilyToClusterMap } from '../../Model/ClusterMap.js';
14
9
 
15
10
  //import InsteonMap from "./Insteon.json";
16
- import { DimmableLightDevice } from "@project-chip/matter.js/devices/DimmableLightDevice";
17
- import { Converters } from '../../Converters.js';
11
+ import { DimmableLightDevice } from '@project-chip/matter.js/devices/DimmableLightDevice';
12
+ import { Converter } from '../../Converters.js';
18
13
  import type { InsteonRelaySwitchDevice } from '../../Devices/Insteon/InsteonRelaySwitchDevice.js';
19
14
 
20
-
21
-
22
15
  const map: FamilyToClusterMap<Family.Insteon> = {
23
- Relay: {
24
- deviceType: OnOffLightDevice,
25
- mapping: {
26
-
27
- OnOff: {
28
- attributes: {
29
- onOff: { driver: "ST"},
30
- },
31
- commands: { on: 'DON'},
32
- },
33
-
34
-
35
-
36
- }
37
- } ,
38
- RelaySwitch: {
39
- deviceType: OnOffLightDevice,
40
- mapping: {
41
- OnOff: {
42
- attributes: {
43
- onOff: "ST",
44
- },
45
- commands: { on: "DON"},
46
- },
47
- },
48
- } ,
49
- Dimmer: {
50
- deviceType: DimmableLightDevice,
51
- mapping: {
52
- OnOff: {
53
- attributes: {
54
- onOff: { driver: "ST" },
55
- },
56
- commands: { on: "DON" },
57
- },
58
- LevelControl: {
59
- attributes: {
60
- currentLevel: { driver: DriverType.Status },
61
- },
62
- commands: { moveToLevel: {command: 'DON'}},
63
- },
64
- },
65
- },
16
+ Family: Family.Insteon,
17
+ Relay: {
18
+ deviceType: OnOffLightDevice,
19
+ mapping: {
20
+ OnOff: {
21
+ attributes: {
22
+ onOff: { driver: 'ST', converter: 'Percent.Boolean' }
23
+ },
24
+ commands: { on: 'DON' }
25
+ }
26
+ } as EndpointMapping<OnOffLightDevice, Insteon.Relay>
27
+ },
28
+ RelaySwitch: {
29
+ deviceType: OnOffLightDevice,
30
+ mapping: {
31
+ OnOff: {
32
+ attributes: {
33
+ onOff: 'ST'
34
+ },
35
+ commands: { on: 'DON' }
36
+ }
37
+ }
38
+ },
39
+ Dimmer: {
40
+ deviceType: DimmableLightDevice,
41
+ mapping: {
42
+ OnOff: {
43
+ attributes: {
44
+ onOff: { driver: 'ST', converter: 'LevelFrom0To255.Boolean' }
45
+ },
46
+ commands: { on: 'DON' }
47
+ },
48
+ LevelControl: {
49
+ attributes: {
50
+ currentLevel: { driver: DriverType.Status, converter: 'LevelFrom0To255.LightingLevel' }
51
+ },
52
+ commands: { moveToLevel: { command: 'DON' } }
53
+ }
54
+ }
55
+ }
66
56
  };
67
57
 
58
+ map.KeypadDimmer = map.Dimmer;
59
+ map.DimmerSwitch = map.Dimmer;
60
+
68
61
  MappingRegistry.register(map);
File without changes
@@ -1,7 +1,7 @@
1
1
  import { camelize, capitalize } from '@project-chip/matter.js/util';
2
2
  import camelcase from 'camelcase';
3
3
  import { getRandomValues } from 'crypto';
4
- import { detailedDiff } from 'deep-object-diff';
4
+ //import { detailedDiff } from 'deep-object-diff';
5
5
  import { create } from 'domain';
6
6
  import * as fs from 'fs';
7
7
  import diff from 'microdiff';