isy-nodejs 1.0.1-alpha.2 → 1.0.1-alpha.20
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/dist/cjs/Converters.js +66 -30
- package/dist/cjs/Converters.js.map +1 -1
- package/dist/cjs/Definitions/Global/Drivers.js +10 -3
- package/dist/cjs/Definitions/Global/Drivers.js.map +1 -1
- package/dist/cjs/Definitions/Global/Events.js +1 -2
- package/dist/cjs/Definitions/Global/Events.js.map +1 -1
- package/dist/cjs/Devices/Elk/ElkAlarmPanelDevice.js +3 -3
- package/dist/cjs/Devices/Elk/ElkAlarmSensorDevice.js +9 -6
- package/dist/cjs/Devices/Elk/ElkAlarmSensorDevice.js.map +1 -1
- package/dist/cjs/Devices/Insteon/InsteonBaseDevice.js +5 -3
- package/dist/cjs/Devices/Insteon/InsteonBaseDevice.js.map +1 -1
- package/dist/cjs/Devices/Insteon/InsteonFanDevice.js +7 -3
- package/dist/cjs/Devices/Insteon/InsteonFanDevice.js.map +1 -1
- package/dist/cjs/Devices/Insteon/InsteonMotionSensorDevice.js +5 -5
- package/dist/cjs/Devices/Insteon/InsteonRelayDevice.js +3 -8
- package/dist/cjs/Devices/Insteon/InsteonRelayDevice.js.map +1 -1
- package/dist/cjs/Devices/Insteon/RelayLampSwitch.js +72 -0
- package/dist/cjs/Devices/Insteon/RelayLampSwitch.js.map +1 -0
- package/dist/cjs/ISY.js +58 -43
- package/dist/cjs/ISY.js.map +1 -1
- package/dist/cjs/ISYNode.js +15 -12
- package/dist/cjs/ISYNode.js.map +1 -1
- package/dist/cjs/ISYScene.js +3 -3
- package/dist/cjs/ISYScene.js.map +1 -1
- package/dist/cjs/Matter/Behaviors/ISYBridgedDeviceBehavior.js +11 -4
- package/dist/cjs/Matter/Behaviors/ISYBridgedDeviceBehavior.js.map +1 -1
- package/dist/cjs/Matter/Behaviors/ISYClusterBehavior.js +26 -7
- package/dist/cjs/Matter/Behaviors/ISYClusterBehavior.js.map +1 -1
- package/dist/cjs/Matter/Behaviors/ISYOnOffBehavior.js +11 -8
- package/dist/cjs/Matter/Behaviors/ISYOnOffBehavior.js.map +1 -1
- package/dist/cjs/Matter/{Server → Bridge}/Server.js +88 -51
- package/dist/cjs/Matter/Bridge/Server.js.map +1 -0
- package/dist/cjs/Matter/Mappings/Insteon.js +19 -15
- package/dist/cjs/Matter/Mappings/Insteon.js.map +1 -1
- package/dist/cjs/Matter/Mappings/register.js +1 -0
- package/dist/cjs/Matter/Mappings/register.js.map +1 -0
- package/dist/cjs/Model/ClusterMap.js +12 -9
- package/dist/cjs/Model/ClusterMap.js.map +1 -1
- package/dist/cjs/Utils.js +60 -9
- package/dist/cjs/Utils.js.map +1 -1
- package/dist/cjs/types/CodeGeneration/EnumFactory.d.ts +1 -1
- package/dist/cjs/types/Converters.d.ts +28 -8
- package/dist/cjs/types/Converters.d.ts.map +1 -1
- package/dist/cjs/types/Definitions/Global/Drivers.d.ts +4 -3
- package/dist/cjs/types/Definitions/Global/Drivers.d.ts.map +1 -1
- package/dist/cjs/types/Definitions/Global/Events.d.ts.map +1 -1
- package/dist/cjs/types/Devices/Elk/ElkAlarmSensorDevice.d.ts.map +1 -1
- package/dist/cjs/types/Devices/EndpointFor.d.ts +2 -2
- package/dist/cjs/types/Devices/Insteon/InsteonBaseDevice.d.ts +3 -3
- package/dist/cjs/types/Devices/Insteon/InsteonBaseDevice.d.ts.map +1 -1
- package/dist/cjs/types/Devices/Insteon/InsteonDevice.d.ts +4 -4
- package/dist/cjs/types/Devices/Insteon/InsteonFanDevice.d.ts +5 -4
- package/dist/cjs/types/Devices/Insteon/InsteonFanDevice.d.ts.map +1 -1
- package/dist/cjs/types/Devices/Insteon/InsteonRelayDevice.d.ts +2 -4
- package/dist/cjs/types/Devices/Insteon/InsteonRelayDevice.d.ts.map +1 -1
- package/dist/cjs/types/Devices/Insteon/RelayLampSwitch.d.ts +93 -0
- package/dist/cjs/types/Devices/Insteon/RelayLampSwitch.d.ts.map +1 -0
- package/dist/cjs/types/ISY.d.ts +27 -21
- package/dist/cjs/types/ISY.d.ts.map +1 -1
- package/dist/cjs/types/ISYNode.d.ts +4 -4
- package/dist/cjs/types/ISYNode.d.ts.map +1 -1
- package/dist/cjs/types/Matter/Behaviors/ISYBridgedDeviceBehavior.d.ts +16 -6
- package/dist/cjs/types/Matter/Behaviors/ISYBridgedDeviceBehavior.d.ts.map +1 -1
- package/dist/cjs/types/Matter/Behaviors/ISYClusterBehavior.d.ts +13 -11
- package/dist/cjs/types/Matter/Behaviors/ISYClusterBehavior.d.ts.map +1 -1
- package/dist/cjs/types/Matter/Behaviors/ISYOnOffBehavior.d.ts +4 -4
- package/dist/cjs/types/Matter/Behaviors/ISYOnOffBehavior.d.ts.map +1 -1
- package/dist/cjs/types/Matter/Bridge/Server.d.ts +27 -0
- package/dist/cjs/types/Matter/Bridge/Server.d.ts.map +1 -0
- package/dist/cjs/types/Matter/Mappings/register.d.ts +1 -0
- package/dist/cjs/types/Matter/Mappings/register.d.ts.map +1 -0
- package/dist/cjs/types/Model/ClusterMap.d.ts +19 -11
- package/dist/cjs/types/Model/ClusterMap.d.ts.map +1 -1
- package/dist/cjs/types/Utils.d.ts +3 -5
- package/dist/cjs/types/Utils.d.ts.map +1 -1
- package/dist/esm/Converters.js +63 -28
- package/dist/esm/Converters.js.map +1 -1
- package/dist/esm/Definitions/Global/Drivers.js +10 -3
- package/dist/esm/Definitions/Global/Drivers.js.map +1 -1
- package/dist/esm/Definitions/Global/Events.js +1 -2
- package/dist/esm/Definitions/Global/Events.js.map +1 -1
- package/dist/esm/Devices/Brultech/index.js +4 -0
- package/dist/esm/Devices/Brultech/index.js.map +1 -0
- package/dist/esm/Devices/Constructor.js +2 -0
- package/dist/esm/Devices/Constructor.js.map +1 -0
- package/dist/esm/Devices/DeviceFactory.js +13 -0
- package/dist/esm/Devices/DeviceFactory.js.map +1 -0
- package/dist/esm/Devices/DeviceMap.js +4 -0
- package/dist/esm/Devices/DeviceMap.js.map +1 -0
- package/dist/esm/Devices/Elk/ElkAlarmPanelDevice.js +181 -0
- package/dist/esm/Devices/Elk/ElkAlarmPanelDevice.js.map +1 -0
- package/dist/esm/Devices/Elk/ElkAlarmSensorDevice.js +110 -0
- package/dist/esm/Devices/Elk/ElkAlarmSensorDevice.js.map +1 -0
- package/dist/esm/Devices/EndpointFor.js +31 -0
- package/dist/esm/Devices/EndpointFor.js.map +1 -0
- package/dist/esm/Devices/ISYDevice.js +35 -0
- package/dist/esm/Devices/ISYDevice.js.map +1 -0
- package/dist/esm/Devices/ISYDeviceNode.js +62 -0
- package/dist/esm/Devices/ISYDeviceNode.js.map +1 -0
- package/dist/esm/Devices/ISYMultiNodeDevice.js +89 -0
- package/dist/esm/Devices/ISYMultiNodeDevice.js.map +1 -0
- package/dist/esm/Devices/Insteon/InsteonBallastDimmerDevice.js +8 -0
- package/dist/esm/Devices/Insteon/InsteonBallastDimmerDevice.js.map +1 -0
- package/dist/esm/Devices/Insteon/InsteonBaseDevice.js +49 -0
- package/dist/esm/Devices/Insteon/InsteonBaseDevice.js.map +1 -0
- package/dist/esm/Devices/Insteon/InsteonCOSensorDevice.js +14 -0
- package/dist/esm/Devices/Insteon/InsteonCOSensorDevice.js.map +1 -0
- package/dist/esm/Devices/Insteon/InsteonDevice.js +17 -0
- package/dist/esm/Devices/Insteon/InsteonDevice.js.map +1 -0
- package/dist/esm/Devices/Insteon/InsteonDeviceFactory.js +875 -0
- package/dist/esm/Devices/Insteon/InsteonDeviceFactory.js.map +1 -0
- package/dist/esm/Devices/Insteon/InsteonDimmableDevice.js +32 -0
- package/dist/esm/Devices/Insteon/InsteonDimmableDevice.js.map +1 -0
- package/dist/esm/Devices/Insteon/InsteonDimmerOutletDevice.js +7 -0
- package/dist/esm/Devices/Insteon/InsteonDimmerOutletDevice.js.map +1 -0
- package/dist/esm/Devices/Insteon/InsteonDimmerSwitchDevice.js +8 -0
- package/dist/esm/Devices/Insteon/InsteonDimmerSwitchDevice.js.map +1 -0
- package/dist/esm/Devices/Insteon/InsteonDoorWindowSensorDevice.js +11 -0
- package/dist/esm/Devices/Insteon/InsteonDoorWindowSensorDevice.js.map +1 -0
- package/dist/esm/Devices/Insteon/InsteonFanDevice.js +60 -0
- package/dist/esm/Devices/Insteon/InsteonFanDevice.js.map +1 -0
- package/dist/esm/Devices/Insteon/InsteonKeypadDevice.js +8 -0
- package/dist/esm/Devices/Insteon/InsteonKeypadDevice.js.map +1 -0
- package/dist/esm/Devices/Insteon/InsteonKeypadDimmerDevice.js +8 -0
- package/dist/esm/Devices/Insteon/InsteonKeypadDimmerDevice.js.map +1 -0
- package/dist/esm/Devices/Insteon/InsteonKeypadRelayDevice.js +8 -0
- package/dist/esm/Devices/Insteon/InsteonKeypadRelayDevice.js.map +1 -0
- package/dist/esm/Devices/Insteon/InsteonLeakSensorDevice.js +11 -0
- package/dist/esm/Devices/Insteon/InsteonLeakSensorDevice.js.map +1 -0
- package/dist/esm/Devices/Insteon/InsteonLockDevice.js +32 -0
- package/dist/esm/Devices/Insteon/InsteonLockDevice.js.map +1 -0
- package/dist/esm/Devices/Insteon/InsteonMotionSensorDevice.js +36 -0
- package/dist/esm/Devices/Insteon/InsteonMotionSensorDevice.js.map +1 -0
- package/dist/esm/Devices/Insteon/InsteonOnOffOutletDevice.js +19 -0
- package/dist/esm/Devices/Insteon/InsteonOnOffOutletDevice.js.map +1 -0
- package/dist/esm/Devices/Insteon/InsteonRelayDevice.js +41 -0
- package/dist/esm/Devices/Insteon/InsteonRelayDevice.js.map +1 -0
- package/dist/esm/Devices/Insteon/InsteonRelaySwitchDevice.js +8 -0
- package/dist/esm/Devices/Insteon/InsteonRelaySwitchDevice.js.map +1 -0
- package/dist/esm/Devices/Insteon/InsteonSmokeSensorDevice.js +11 -0
- package/dist/esm/Devices/Insteon/InsteonSmokeSensorDevice.js.map +1 -0
- package/dist/esm/Devices/Insteon/InsteonThermostatDevice.js +30 -0
- package/dist/esm/Devices/Insteon/InsteonThermostatDevice.js.map +1 -0
- package/dist/esm/Devices/Insteon/RelayLampSwitch.js +68 -0
- package/dist/esm/Devices/Insteon/RelayLampSwitch.js.map +1 -0
- package/dist/esm/Devices/Insteon/index.js +31 -0
- package/dist/esm/Devices/Insteon/index.js.map +1 -0
- package/dist/esm/Devices/Lutron/index.js +4 -0
- package/dist/esm/Devices/Lutron/index.js.map +1 -0
- package/dist/esm/Devices/MapsTo.js +2 -0
- package/dist/esm/Devices/MapsTo.js.map +1 -0
- package/dist/esm/Devices/NCD/index.js +4 -0
- package/dist/esm/Devices/NCD/index.js.map +1 -0
- package/dist/esm/Devices/NodeFactory.js +48 -0
- package/dist/esm/Devices/NodeFactory.js.map +1 -0
- package/dist/esm/Devices/Poly/index.js +4 -0
- package/dist/esm/Devices/Poly/index.js.map +1 -0
- package/dist/esm/Devices/Scene/index.js +4 -0
- package/dist/esm/Devices/Scene/index.js.map +1 -0
- package/dist/esm/Devices/UDI/index.js +4 -0
- package/dist/esm/Devices/UDI/index.js.map +1 -0
- package/dist/esm/Devices/ZWave/ZWaveBaseDevice.js +38 -0
- package/dist/esm/Devices/ZWave/ZWaveBaseDevice.js.map +1 -0
- package/dist/esm/Devices/ZWave/ZWaveDimmerSwitchDevice.js +8 -0
- package/dist/esm/Devices/ZWave/ZWaveDimmerSwitchDevice.js.map +1 -0
- package/dist/esm/Devices/ZWave/ZWaveLockDevice.js +35 -0
- package/dist/esm/Devices/ZWave/ZWaveLockDevice.js.map +1 -0
- package/dist/esm/Devices/ZWave/index.js +20 -0
- package/dist/esm/Devices/ZWave/index.js.map +1 -0
- package/dist/esm/Devices/index.js +9 -0
- package/dist/esm/Devices/index.js.map +1 -0
- package/dist/esm/ISY.js +56 -41
- package/dist/esm/ISY.js.map +1 -1
- package/dist/esm/ISYNode.js +16 -13
- package/dist/esm/ISYNode.js.map +1 -1
- package/dist/esm/ISYScene.js +3 -3
- package/dist/esm/ISYScene.js.map +1 -1
- package/dist/esm/Matter/Behaviors/ISYBridgedDeviceBehavior.js +11 -4
- package/dist/esm/Matter/Behaviors/ISYBridgedDeviceBehavior.js.map +1 -1
- package/dist/esm/Matter/Behaviors/ISYClusterBehavior.js +26 -7
- package/dist/esm/Matter/Behaviors/ISYClusterBehavior.js.map +1 -1
- package/dist/esm/Matter/Behaviors/ISYOnOffBehavior.js +12 -9
- package/dist/esm/Matter/Behaviors/ISYOnOffBehavior.js.map +1 -1
- package/dist/esm/Matter/{Server → Bridge}/Server.js +60 -50
- package/dist/esm/Matter/Bridge/Server.js.map +1 -0
- package/dist/esm/Matter/Mappings/Insteon.js +22 -18
- package/dist/esm/Matter/Mappings/Insteon.js.map +1 -1
- package/dist/esm/Matter/Mappings/register.js +2 -0
- package/dist/esm/Matter/Mappings/register.js.map +1 -0
- package/dist/esm/Model/ClusterMap.js +12 -9
- package/dist/esm/Model/ClusterMap.js.map +1 -1
- package/dist/esm/Utils.js +55 -8
- package/dist/esm/Utils.js.map +1 -1
- package/dist/esm/types/CodeGeneration/EnumFactory.d.ts +1 -1
- package/dist/esm/types/Converters.d.ts +28 -8
- package/dist/esm/types/Converters.d.ts.map +1 -1
- package/dist/esm/types/Definitions/Global/Drivers.d.ts +4 -3
- package/dist/esm/types/Definitions/Global/Drivers.d.ts.map +1 -1
- package/dist/esm/types/Definitions/Global/Events.d.ts.map +1 -1
- package/dist/esm/types/Devices/Elk/ElkAlarmSensorDevice.d.ts.map +1 -1
- package/dist/esm/types/Devices/EndpointFor.d.ts +2 -2
- package/dist/esm/types/Devices/Insteon/InsteonBaseDevice.d.ts +3 -3
- package/dist/esm/types/Devices/Insteon/InsteonBaseDevice.d.ts.map +1 -1
- package/dist/esm/types/Devices/Insteon/InsteonDevice.d.ts +4 -4
- package/dist/esm/types/Devices/Insteon/InsteonFanDevice.d.ts +5 -4
- package/dist/esm/types/Devices/Insteon/InsteonFanDevice.d.ts.map +1 -1
- package/dist/esm/types/Devices/Insteon/InsteonRelayDevice.d.ts +2 -4
- package/dist/esm/types/Devices/Insteon/InsteonRelayDevice.d.ts.map +1 -1
- package/dist/esm/types/Devices/Insteon/RelayLampSwitch.d.ts +93 -0
- package/dist/esm/types/Devices/Insteon/RelayLampSwitch.d.ts.map +1 -0
- package/dist/esm/types/ISY.d.ts +27 -21
- package/dist/esm/types/ISY.d.ts.map +1 -1
- package/dist/esm/types/ISYNode.d.ts +4 -4
- package/dist/esm/types/ISYNode.d.ts.map +1 -1
- package/dist/esm/types/Matter/Behaviors/ISYBridgedDeviceBehavior.d.ts +16 -6
- package/dist/esm/types/Matter/Behaviors/ISYBridgedDeviceBehavior.d.ts.map +1 -1
- package/dist/esm/types/Matter/Behaviors/ISYClusterBehavior.d.ts +13 -11
- package/dist/esm/types/Matter/Behaviors/ISYClusterBehavior.d.ts.map +1 -1
- package/dist/esm/types/Matter/Behaviors/ISYOnOffBehavior.d.ts +4 -4
- package/dist/esm/types/Matter/Behaviors/ISYOnOffBehavior.d.ts.map +1 -1
- package/dist/esm/types/Matter/Bridge/Server.d.ts +27 -0
- package/dist/esm/types/Matter/Bridge/Server.d.ts.map +1 -0
- package/dist/esm/types/Matter/Mappings/register.d.ts +2 -0
- package/dist/esm/types/Matter/Mappings/register.d.ts.map +1 -0
- package/dist/esm/types/Model/ClusterMap.d.ts +19 -11
- package/dist/esm/types/Model/ClusterMap.d.ts.map +1 -1
- package/dist/esm/types/Utils.d.ts +3 -5
- package/dist/esm/types/Utils.d.ts.map +1 -1
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +4 -6
- package/src/Converters.ts +137 -69
- package/src/Definitions/Global/Drivers.ts +16 -7
- package/src/Definitions/Global/Events.ts +4 -3
- package/src/Devices/Elk/ElkAlarmPanelDevice.ts +3 -3
- package/src/Devices/Elk/ElkAlarmSensorDevice.ts +15 -21
- package/src/Devices/Insteon/Generated/RelayLamp.ts +8 -7
- package/src/Devices/Insteon/InsteonBaseDevice.ts +10 -9
- package/src/Devices/Insteon/InsteonFanDevice.ts +16 -11
- package/src/Devices/Insteon/InsteonMotionSensorDevice.ts +5 -5
- package/src/Devices/Insteon/InsteonRelayDevice.ts +3 -5
- package/src/Devices/Insteon/RelayLampSwitch.ts +131 -0
- package/src/ISY.ts +87 -61
- package/src/ISYNode.ts +17 -14
- package/src/ISYScene.ts +3 -3
- package/src/Matter/Behaviors/ISYBridgedDeviceBehavior.ts +29 -11
- package/src/Matter/Behaviors/ISYClusterBehavior.ts +46 -28
- package/src/Matter/Behaviors/ISYOnOffBehavior.ts +50 -64
- package/src/Matter/{Server → Bridge}/Server.ts +87 -59
- package/src/Matter/Mappings/Insteon.ts +53 -60
- package/src/Matter/Mappings/register.ts +0 -0
- package/src/Model/ClassDefinition.ts +1 -1
- package/src/Model/ClusterMap.ts +31 -22
- package/src/Utils.ts +62 -19
- package/tsconfig.json +2 -2
- package/dist/cjs/Matter/Server/Server.js.map +0 -1
- package/dist/cjs/types/Matter/Server/Server.d.ts +0 -4
- package/dist/cjs/types/Matter/Server/Server.d.ts.map +0 -1
- package/dist/esm/Matter/Server/Server.js.map +0 -1
- package/dist/esm/types/Matter/Server/Server.d.ts +0 -4
- package/dist/esm/types/Matter/Server/Server.d.ts.map +0 -1
|
@@ -11,11 +11,11 @@ import internal from 'stream';
|
|
|
11
11
|
import type { Driver } from '../../Definitions/Global/Drivers.js';
|
|
12
12
|
import { ISY, type Family, type ISYNode } from '../../ISY.js';
|
|
13
13
|
import type { ISYDevice } from '../../ISYDevice.js';
|
|
14
|
-
import { DeviceToClusterMap, MappingRegistry, type ClusterMapping } from '../../Model/ClusterMap.js';
|
|
14
|
+
import { DeviceToClusterMap, MappingRegistry, type ClusterMapping, type BehaviorMapping } from '../../Model/ClusterMap.js';
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
type ClusterForBehavior<B extends ClusterBehavior> = B extends ClusterBehavior.Type<infer C> ? C : never;
|
|
18
|
-
export class ISYBridgedDeviceBehavior extends Behavior {
|
|
18
|
+
export class ISYBridgedDeviceBehavior<N extends ISYNode<any, D, any, any>, D extends ISYNode.DriverSignatures = ISYNode.DriverSignatures> extends Behavior {
|
|
19
19
|
static override readonly id = 'isyNode';
|
|
20
20
|
|
|
21
21
|
static override readonly early = true;
|
|
@@ -23,16 +23,24 @@ export class ISYBridgedDeviceBehavior extends Behavior {
|
|
|
23
23
|
declare internal: ISYBridgedDeviceBehavior.Internal;
|
|
24
24
|
declare state: ISYBridgedDeviceBehavior.State;
|
|
25
25
|
|
|
26
|
-
declare events: ISYBridgedDeviceBehavior.Events
|
|
26
|
+
declare events: ISYBridgedDeviceBehavior.Events & ISYBridgedDeviceBehavior.EventsFor<N["drivers"]>;
|
|
27
27
|
|
|
28
28
|
override async initialize(_options?: {}) {
|
|
29
29
|
await super.initialize(_options);
|
|
30
30
|
var address = this.state.address;
|
|
31
|
-
|
|
32
|
-
this.internal.
|
|
31
|
+
const d = ISY.instance.nodeMap.get(this.state.address);
|
|
32
|
+
this.internal.device = d;
|
|
33
|
+
this.internal.map = MappingRegistry.getMapping(this.internal.device as unknown as ISYNode<Family, any, any, any>);
|
|
33
34
|
ISY.instance.logger.debug(`Initializing ${this.constructor.name} for ${this.internal.device.constructor.name} ${this.internal.device.name} with address ${address}`);
|
|
34
|
-
if (
|
|
35
|
-
|
|
35
|
+
if (d) {
|
|
36
|
+
d.events.on('PropertyChanged', this.handlePropertyChange.bind(this));
|
|
37
|
+
for(const f in d.drivers)
|
|
38
|
+
{
|
|
39
|
+
let evt = `${d.drivers[f].name}Changed`;
|
|
40
|
+
this.events[evt] = Observable<[{ driver: string; newValue: any; oldValue: any; formattedValue: string }]>();
|
|
41
|
+
//@ts-ignore
|
|
42
|
+
d.events.on(evt, (driver: string, newValue: any, oldValue: any, formattedValue: string) => this.events.emit(evt, { driver, newValue, oldValue, formattedValue } as unknown as any));
|
|
43
|
+
}
|
|
36
44
|
}
|
|
37
45
|
}
|
|
38
46
|
|
|
@@ -44,15 +52,15 @@ export class ISYBridgedDeviceBehavior extends Behavior {
|
|
|
44
52
|
return this.internal.map;
|
|
45
53
|
}
|
|
46
54
|
|
|
47
|
-
mapForBehavior<B extends
|
|
48
|
-
return this.map[behavior.cluster['name']];
|
|
55
|
+
mapForBehavior<B extends ClusterBehavior>(behavior: B): BehaviorMapping<B, typeof this.internal.device> {
|
|
56
|
+
return this.map.mapping[behavior.cluster['name']];
|
|
49
57
|
}
|
|
50
58
|
|
|
51
59
|
handlePropertyChange(driver: string, newValue: any, oldValue: any, formattedValue: string) {
|
|
52
60
|
this.events.propertyChanged.emit({ driver, newValue, oldValue, formattedValue });
|
|
53
61
|
}
|
|
54
62
|
|
|
55
|
-
[Symbol.asyncDispose]() {
|
|
63
|
+
override [Symbol.asyncDispose]() {
|
|
56
64
|
this.internal.device = null;
|
|
57
65
|
return super[Symbol.asyncDispose]();
|
|
58
66
|
}
|
|
@@ -64,8 +72,18 @@ export namespace ISYBridgedDeviceBehavior {
|
|
|
64
72
|
map?: DeviceToClusterMap<typeof this.device, any>;
|
|
65
73
|
}
|
|
66
74
|
|
|
67
|
-
export
|
|
75
|
+
export type EventsFor<D extends {[x: string]: Driver<any,any,any>}> = {
|
|
76
|
+
[s in keyof D as `${D[s]["name"]}Changed`] : Observable<[{ driver: s; newValue: any; oldValue: any; formattedValue: string }]>;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
export class Events extends EventEmitter{
|
|
68
83
|
propertyChanged = Observable<[{ driver: string; newValue: any; oldValue: any; formattedValue: string }]>();
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
69
87
|
}
|
|
70
88
|
|
|
71
89
|
export class State {
|
|
@@ -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 {
|
|
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 {
|
|
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
|
-
|
|
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
|
-
|
|
27
|
+
bridgedDeviceBehavior: ISYBridgedDeviceBehavior<P>;
|
|
25
28
|
|
|
26
|
-
|
|
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
|
-
|
|
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:
|
|
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
|
-
|
|
56
|
-
|
|
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 (
|
|
60
|
-
|
|
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] =
|
|
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
|
-
|
|
105
|
-
|
|
106
|
-
handlePropertyChange(chg: PropertyChange<P>): void;
|
|
107
|
-
};
|
|
125
|
+
// #endregion Functions (1)
|
|
@@ -1,80 +1,66 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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 {
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
override on = async () => {
|
|
33
|
-
await super.on();
|
|
34
|
-
|
|
14
|
+
import { Converter } from '../../Converters.js';
|
|
35
15
|
|
|
36
|
-
|
|
37
|
-
|
|
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
|
+
}
|
|
38
21
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
22
|
+
override on = async () => {
|
|
23
|
+
await super.on();
|
|
24
|
+
await this.device.on();
|
|
43
25
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
26
|
+
//this.device.commands.DON = true;
|
|
27
|
+
};
|
|
47
28
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
29
|
+
override async off() {
|
|
30
|
+
await super.off();
|
|
31
|
+
await this.device.off();
|
|
51
32
|
|
|
52
|
-
|
|
33
|
+
// this.device.drivers = false;
|
|
34
|
+
}
|
|
53
35
|
|
|
54
|
-
|
|
55
|
-
|
|
36
|
+
override toggle = async () => {
|
|
37
|
+
//this.device.state = !(await this.device.state);
|
|
38
|
+
};
|
|
56
39
|
|
|
40
|
+
override async handlePropertyChange({ driver, newValue, oldValue, formattedValue }: PropertyChange<InsteonRelayDevice>) {
|
|
41
|
+
/*if (driver === 'ST') {
|
|
42
|
+
this.state.onOff = newValue;
|
|
43
|
+
}*/
|
|
57
44
|
|
|
45
|
+
return super.handlePropertyChange({ driver, newValue, oldValue, formattedValue });
|
|
46
|
+
}
|
|
58
47
|
}
|
|
59
48
|
|
|
60
|
-
|
|
61
49
|
export class ISYDimmableBehavior extends ISYClusterBehavior(DimmableLightRequirements.LevelControlServer, InsteonDimmableDevice) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
}
|
|
50
|
+
override async initialize(_options?: {}) {
|
|
51
|
+
await super.initialize(_options);
|
|
52
|
+
/*this.state.onLevel = Converter.get('Level255toZero.LightingLevel').to(this.device.drivers.OL)*/
|
|
53
|
+
//this.state.currentLevel = this.device.drivers.ST.value;
|
|
54
|
+
|
|
55
|
+
//this.state.onLevel = this.device.drivers.OL;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
override setLevel(level: number): MaybePromise<void> {
|
|
59
|
+
level = Converter.Matter.LevelFrom0To255.LightingLevel.from(level);
|
|
60
|
+
if (level > 0) {
|
|
61
|
+
return this.device.sendCommand('DON', level);
|
|
62
|
+
} else {
|
|
63
|
+
return this.device.sendCommand('DOF');
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -1,54 +1,79 @@
|
|
|
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';
|
|
3
4
|
import { BridgedDeviceBasicInformationServer } from '@project-chip/matter.js/behaviors/bridged-device-basic-information';
|
|
4
5
|
import { VendorId } from '@project-chip/matter.js/datatype';
|
|
5
|
-
import { logEndpoint
|
|
6
|
+
import { logEndpoint } from '@project-chip/matter.js/device';
|
|
6
7
|
import { Endpoint, EndpointServer } from '@project-chip/matter.js/endpoint';
|
|
7
8
|
import { DimmableLightDevice, OnOffLightDevice } from '@project-chip/matter.js/endpoint/definitions';
|
|
8
9
|
import type { SupportedBehaviors } from '@project-chip/matter.js/endpoint/properties';
|
|
9
|
-
import {
|
|
10
|
+
import { MutableEndpoint } from '@project-chip/matter.js/endpoint/type';
|
|
10
11
|
import { AggregatorEndpoint } from '@project-chip/matter.js/endpoints/AggregatorEndpoint';
|
|
11
|
-
import {
|
|
12
|
+
import { StorageService } from '@project-chip/matter.js/environment';
|
|
12
13
|
import { Level, levelFromString, Logger as MatterLogger } from '@project-chip/matter.js/log';
|
|
13
14
|
import { ServerNode } from '@project-chip/matter.js/node';
|
|
15
|
+
//@ts-ignore
|
|
16
|
+
import PackageJson from '@project-chip/matter.js/package.json' with { type: 'json' };
|
|
14
17
|
import { QrCode } from '@project-chip/matter.js/schema';
|
|
15
|
-
import { resolve } from 'path';
|
|
16
|
-
import {
|
|
18
|
+
import path, { resolve } from 'path';
|
|
19
|
+
import { format, loggers } from 'winston';
|
|
20
|
+
import type { ISYDeviceNode } from '../../Devices/ISYDeviceNode.js';
|
|
17
21
|
import { InsteonDimmableDevice, InsteonKeypadButtonDevice, InsteonRelayDevice, ISY } from '../../ISY.js';
|
|
18
22
|
import { ISYBridgedDeviceBehavior } from '../Behaviors/ISYBridgedDeviceBehavior.js';
|
|
19
23
|
import { ISYDimmableBehavior, ISYOnOffBehavior } from '../Behaviors/ISYOnOffBehavior.js';
|
|
24
|
+
import '../Mappings/Insteon.js';
|
|
20
25
|
|
|
21
|
-
// #region
|
|
26
|
+
// #region Interfaces (1)
|
|
22
27
|
|
|
23
|
-
|
|
24
|
-
//let { Utils } = await import ('isy-nodejs');
|
|
28
|
+
export let instance: ServerNode;
|
|
25
29
|
|
|
26
|
-
|
|
27
|
-
|
|
30
|
+
//@ts-ignore
|
|
31
|
+
export let version: string = PackageJson.version;
|
|
32
|
+
export interface Config {
|
|
33
|
+
// #region Properties (8)
|
|
28
34
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
// });
|
|
35
|
+
discriminator: number;
|
|
36
|
+
passcode: number;
|
|
37
|
+
port: number;
|
|
38
|
+
productId: number;
|
|
39
|
+
productName?: string;
|
|
40
|
+
uniqueId: string;
|
|
41
|
+
vendorId: number;
|
|
42
|
+
vendorName?: string;
|
|
38
43
|
|
|
39
|
-
//
|
|
40
|
-
|
|
44
|
+
// #endregion Properties (8)
|
|
45
|
+
}
|
|
41
46
|
|
|
42
|
-
//
|
|
47
|
+
// #endregion Interfaces (1)
|
|
43
48
|
|
|
44
|
-
//
|
|
45
|
-
|
|
46
|
-
|
|
49
|
+
// #region Functions (3)
|
|
50
|
+
|
|
51
|
+
export function create(isy?: ISY, config?: Config): Promise<ServerNode> {
|
|
52
|
+
return createMatterServer(isy, config);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export async function createMatterServer(isy?: ISY, config?: Config): Promise<ServerNode> {
|
|
56
|
+
var logger = loggers.add('matter', {
|
|
57
|
+
transports: isy.logger.transports,
|
|
58
|
+
levels: isy.logger.levels,
|
|
59
|
+
format: format.label({ label: 'Matter' })
|
|
60
|
+
});
|
|
61
|
+
if (isy === undefined) {
|
|
62
|
+
isy = ISY.instance;
|
|
63
|
+
}
|
|
47
64
|
|
|
48
65
|
try {
|
|
49
66
|
MatterLogger.addLogger(
|
|
50
67
|
'polyLogger',
|
|
51
|
-
(
|
|
68
|
+
(lvl, message) => {
|
|
69
|
+
let msg = message.slice(23).remove(Level[lvl]).trimStart();
|
|
70
|
+
let level = Level[lvl].toLowerCase().replace('notice', 'info');
|
|
71
|
+
if (msg.startsWith('EndpointStructureLogger')) {
|
|
72
|
+
if (lvl === Level.INFO) level = 'debug';
|
|
73
|
+
}
|
|
74
|
+
logger.log(level, msg);
|
|
75
|
+
},
|
|
76
|
+
/*Preserve existing formatting, but trim off date*/
|
|
52
77
|
{
|
|
53
78
|
defaultLogLevel: levelFromString(logger.level),
|
|
54
79
|
logFormat: 'plain'
|
|
@@ -58,11 +83,11 @@ export async function createServerNode(isy: ISY = ISY.instance): Promise<ServerN
|
|
|
58
83
|
MatterLogger.defaultLogLevel = levelFromString(logger.level);
|
|
59
84
|
}
|
|
60
85
|
|
|
61
|
-
|
|
86
|
+
config = await initializeConfiguration(isy, config);
|
|
62
87
|
|
|
63
88
|
logger.info(`Matter config read: ${JSON.stringify(config)}`);
|
|
64
|
-
|
|
65
|
-
|
|
89
|
+
MatterLogger.removeLogger('default');
|
|
90
|
+
let server = await ServerNode.create({
|
|
66
91
|
// Required: Give the Node a unique ID which is used to store the state of this node
|
|
67
92
|
id: config.uniqueId,
|
|
68
93
|
|
|
@@ -70,6 +95,7 @@ export async function createServerNode(isy: ISY = ISY.instance): Promise<ServerN
|
|
|
70
95
|
// Optional when operating only one device on a host, Default port is 5540
|
|
71
96
|
network: {
|
|
72
97
|
port: config.port,
|
|
98
|
+
|
|
73
99
|
//ipv4: false,
|
|
74
100
|
discoveryCapabilities: {
|
|
75
101
|
onIpNetwork: true
|
|
@@ -124,7 +150,8 @@ export async function createServerNode(isy: ISY = ISY.instance): Promise<ServerN
|
|
|
124
150
|
|
|
125
151
|
const endpoints: { 0: Endpoint; 1: InsteonRelayDevice }[] = [];
|
|
126
152
|
|
|
127
|
-
for (const
|
|
153
|
+
for (const node of isy.nodeMap.values()) {
|
|
154
|
+
let device = node as ISYDeviceNode<any, any, any>;
|
|
128
155
|
let serialNumber = `${device.address.replaceAll(' ', '_').replaceAll('.', '_')}`;
|
|
129
156
|
if (device.enabled && !(device instanceof InsteonKeypadButtonDevice)) {
|
|
130
157
|
//const name = `OnOff ${isASocket ? "Socket" : "Light"} ${i}`;
|
|
@@ -147,6 +174,7 @@ export async function createServerNode(isy: ISY = ISY.instance): Promise<ServerN
|
|
|
147
174
|
}
|
|
148
175
|
|
|
149
176
|
if (baseBehavior !== undefined) {
|
|
177
|
+
//@ts-ignore
|
|
150
178
|
const endpoint = new Endpoint(baseBehavior, {
|
|
151
179
|
id: serialNumber,
|
|
152
180
|
isyNode: {
|
|
@@ -192,7 +220,7 @@ export async function createServerNode(isy: ISY = ISY.instance): Promise<ServerN
|
|
|
192
220
|
*/
|
|
193
221
|
|
|
194
222
|
logger.info('Bringing server online');
|
|
195
|
-
await server.
|
|
223
|
+
await server.start();
|
|
196
224
|
|
|
197
225
|
logger.info('Matter Server is online');
|
|
198
226
|
/**
|
|
@@ -206,44 +234,44 @@ export async function createServerNode(isy: ISY = ISY.instance): Promise<ServerN
|
|
|
206
234
|
// logEndpoint(EndpointServer.forEndpoint(server), {logAttributePrimitiveValues: true, logAttributeObjectValues: true});
|
|
207
235
|
//else if(logger.isDebugEnabled())
|
|
208
236
|
// {
|
|
209
|
-
logEndpoint(EndpointServer.forEndpoint(server), { logAttributePrimitiveValues: true, logAttributeObjectValues: false });
|
|
237
|
+
logEndpoint(EndpointServer.forEndpoint(server), { logAttributePrimitiveValues: true, logAttributeObjectValues: false, logClusterGlobalAttributes: false });
|
|
210
238
|
// }
|
|
211
239
|
if (server.lifecycle.isOnline) {
|
|
212
240
|
const { qrPairingCode, manualPairingCode } = server.state.commissioning.pairingCodes;
|
|
213
241
|
|
|
214
|
-
logger.info(QrCode.get(qrPairingCode));
|
|
242
|
+
logger.info('\n' + QrCode.get(qrPairingCode));
|
|
215
243
|
logger.info(`QR Code URL: https://project-chip.github.io/connectedhomeip/qrcode.html?data=${qrPairingCode}`);
|
|
216
244
|
logger.info(`Manual pairing code: ${manualPairingCode}`);
|
|
217
245
|
}
|
|
218
246
|
/*for(let e of endpoints)
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
247
|
+
{
|
|
248
|
+
e[1].initialize(e[0] as any);
|
|
249
|
+
}*/
|
|
250
|
+
instance = server;
|
|
223
251
|
return server;
|
|
252
|
+
}
|
|
224
253
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
254
|
+
type PairingCodeData = {
|
|
255
|
+
qrPairingCode: string;
|
|
256
|
+
manualPairingCode: string;
|
|
257
|
+
renderedQrPairingCode: string;
|
|
258
|
+
url: string | URL;
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
export function getPairingCode(server: ServerNode = instance): PairingCodeData {
|
|
262
|
+
let codes = server.state.commissioning.pairingCodes as PairingCodeData;
|
|
263
|
+
codes.renderedQrPairingCode = QrCode.get(codes.qrPairingCode);
|
|
264
|
+
codes.url = `https://project-chip.github.io/connectedhomeip/qrcode.html?data=${codes.qrPairingCode}`;
|
|
265
|
+
return codes;
|
|
229
266
|
}
|
|
230
267
|
|
|
231
|
-
async function
|
|
268
|
+
async function initializeConfiguration(isy: ISY, config?: Config): Promise<Config> {
|
|
232
269
|
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
270
|
|
|
243
271
|
const environment = NodeJsEnvironment();
|
|
244
272
|
|
|
245
273
|
const storageService = environment.get(StorageService);
|
|
246
|
-
environment.vars.set('storage.path',
|
|
274
|
+
environment.vars.set('storage.path', path.resolve(isy.storagePath, 'matter'));
|
|
247
275
|
environment.vars.use(() => {
|
|
248
276
|
const location = environment.vars.get('storage.path', environment.vars.get('path.root', '.'));
|
|
249
277
|
storageService.location = location;
|
|
@@ -254,15 +282,15 @@ async function getConfiguration(isy: ISY) {
|
|
|
254
282
|
const deviceStorage = (await storageService.open('device')).createContext('data');
|
|
255
283
|
|
|
256
284
|
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));
|
|
285
|
+
const passcode = config.passcode ?? environment.vars.number('passcode') ?? (await deviceStorage.get('passcode', 20202021));
|
|
286
|
+
const discriminator = config.discriminator ?? environment.vars.number('discriminator') ?? (await deviceStorage.get('discriminator', 3840));
|
|
259
287
|
// 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));
|
|
288
|
+
const vendorId = config.vendorId ?? environment.vars.number('vendorid') ?? (await deviceStorage.get('vendorid', 0xfff1));
|
|
289
|
+
const productId = config.productId ?? environment.vars.number('productid') ?? (await deviceStorage.get('productid', 0x8000));
|
|
262
290
|
const productName = isy.productName;
|
|
263
|
-
const port = environment.vars.number('port') ?? 5540;
|
|
291
|
+
const port = config.port ?? environment.vars.number('port') ?? 5540;
|
|
264
292
|
|
|
265
|
-
const uniqueId = isy.id;
|
|
293
|
+
const uniqueId = isy.id.replaceAll(':', '_');
|
|
266
294
|
//environment.vars.string("uniqueid") ?? (await deviceStorage.get("uniqueid", Time.nowMs().toString()));
|
|
267
295
|
|
|
268
296
|
// Persist basic data to keep them also on restart
|
|
@@ -287,4 +315,4 @@ async function getConfiguration(isy: ISY) {
|
|
|
287
315
|
};
|
|
288
316
|
}
|
|
289
317
|
|
|
290
|
-
// #endregion Functions (
|
|
318
|
+
// #endregion Functions (3)
|