isy-nodejs 1.0.1-alpha.26 → 1.0.1-alpha.27
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 +10 -13
- package/dist/cjs/Converters.js.map +1 -1
- package/dist/cjs/Definitions/Global/Commands.js.map +1 -1
- package/dist/cjs/Devices/Insteon/DimmerLampSwitch.js +2 -2
- package/dist/cjs/Devices/Insteon/DimmerLampSwitch.js.map +1 -1
- package/dist/cjs/Devices/Insteon/RelayLampSwitch.js +5 -5
- package/dist/cjs/Devices/Insteon/RelayLampSwitch.js.map +1 -1
- package/dist/cjs/ISYScene.js +1 -1
- package/dist/cjs/ISYScene.js.map +1 -1
- package/dist/cjs/Matter/Behaviors/ISYBridgedDeviceBehavior.js.map +1 -1
- package/dist/cjs/Matter/Behaviors/ISYClusterBehavior.js +7 -5
- package/dist/cjs/Matter/Behaviors/ISYClusterBehavior.js.map +1 -1
- package/dist/cjs/Matter/Behaviors/ISYOnOffBehavior.js +1 -1
- package/dist/cjs/Matter/Behaviors/ISYOnOffBehavior.js.map +1 -1
- package/dist/cjs/Matter/Behaviors/Insteon/ISYOnOffBehavior.js +47 -0
- package/dist/cjs/Matter/Behaviors/Insteon/ISYOnOffBehavior.js.map +1 -0
- package/dist/cjs/Matter/Bridge/Server.js +1 -1
- package/dist/cjs/Matter/Bridge/Server.js.map +1 -1
- package/dist/cjs/Matter/Mappings/Insteon.js +3 -4
- package/dist/cjs/Matter/Mappings/Insteon.js.map +1 -1
- package/dist/cjs/types/Converters.d.ts +15 -2
- package/dist/cjs/types/Converters.d.ts.map +1 -1
- package/dist/cjs/types/Definitions/Global/Commands.d.ts +1 -1
- package/dist/cjs/types/Definitions/Global/Commands.d.ts.map +1 -1
- package/dist/cjs/types/Devices/Insteon/DimmerLampSwitch.d.ts +1 -1
- package/dist/cjs/types/Devices/Insteon/DimmerLampSwitch.d.ts.map +1 -1
- package/dist/cjs/types/Devices/Insteon/RelayLampSwitch.d.ts +32 -32
- package/dist/cjs/types/Devices/Insteon/RelayLampSwitch.d.ts.map +1 -1
- package/dist/cjs/types/Matter/Behaviors/ISYBridgedDeviceBehavior.d.ts.map +1 -1
- package/dist/cjs/types/Matter/Behaviors/ISYClusterBehavior.d.ts.map +1 -1
- package/dist/cjs/types/Matter/Behaviors/Insteon/ISYOnOffBehavior.d.ts +54 -0
- package/dist/cjs/types/Matter/Behaviors/Insteon/ISYOnOffBehavior.d.ts.map +1 -0
- package/dist/cjs/types/Model/EnumDefinition.d.ts +1 -1
- package/dist/esm/Converters.js +10 -13
- package/dist/esm/Converters.js.map +1 -1
- package/dist/esm/Definitions/Global/Commands.js.map +1 -1
- package/dist/esm/Devices/Insteon/DimmerLampSwitch.js +2 -2
- package/dist/esm/Devices/Insteon/DimmerLampSwitch.js.map +1 -1
- package/dist/esm/Devices/Insteon/RelayLampSwitch.js +7 -7
- package/dist/esm/Devices/Insteon/RelayLampSwitch.js.map +1 -1
- package/dist/esm/ISYScene.js +1 -1
- package/dist/esm/ISYScene.js.map +1 -1
- package/dist/esm/Matter/Behaviors/ISYBridgedDeviceBehavior.js.map +1 -1
- package/dist/esm/Matter/Behaviors/ISYClusterBehavior.js +7 -5
- package/dist/esm/Matter/Behaviors/ISYClusterBehavior.js.map +1 -1
- package/dist/esm/Matter/Behaviors/ISYOnOffBehavior.js +1 -1
- package/dist/esm/Matter/Behaviors/ISYOnOffBehavior.js.map +1 -1
- package/dist/esm/Matter/Behaviors/Insteon/ISYOnOffBehavior.js +42 -0
- package/dist/esm/Matter/Behaviors/Insteon/ISYOnOffBehavior.js.map +1 -0
- package/dist/esm/Matter/Bridge/Server.js +1 -1
- package/dist/esm/Matter/Bridge/Server.js.map +1 -1
- package/dist/esm/Matter/Mappings/Insteon.js +3 -4
- package/dist/esm/Matter/Mappings/Insteon.js.map +1 -1
- package/dist/esm/types/Converters.d.ts +15 -2
- package/dist/esm/types/Converters.d.ts.map +1 -1
- package/dist/esm/types/Definitions/Global/Commands.d.ts +1 -1
- package/dist/esm/types/Definitions/Global/Commands.d.ts.map +1 -1
- package/dist/esm/types/Devices/Insteon/DimmerLampSwitch.d.ts +1 -1
- package/dist/esm/types/Devices/Insteon/DimmerLampSwitch.d.ts.map +1 -1
- package/dist/esm/types/Devices/Insteon/RelayLampSwitch.d.ts +32 -32
- package/dist/esm/types/Devices/Insteon/RelayLampSwitch.d.ts.map +1 -1
- package/dist/esm/types/Matter/Behaviors/ISYBridgedDeviceBehavior.d.ts.map +1 -1
- package/dist/esm/types/Matter/Behaviors/ISYClusterBehavior.d.ts.map +1 -1
- package/dist/esm/types/Matter/Behaviors/Insteon/ISYOnOffBehavior.d.ts +54 -0
- package/dist/esm/types/Matter/Behaviors/Insteon/ISYOnOffBehavior.d.ts.map +1 -0
- package/dist/esm/types/Model/EnumDefinition.d.ts +1 -1
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/Converters.ts +18 -24
- package/src/Definitions/Global/Commands.ts +13 -1
- package/src/Devices/Insteon/DimmerLampSwitch.ts +3 -3
- package/src/Devices/Insteon/Generated/DimmerLampSwitch.ts +8 -7
- package/src/Devices/Insteon/RelayLampSwitch.ts +39 -39
- package/src/ISYScene.ts +1 -1
- package/src/Matter/Behaviors/ISYBridgedDeviceBehavior.ts +9 -1
- package/src/Matter/Behaviors/ISYClusterBehavior.ts +10 -3
- package/src/Matter/Behaviors/{ISYOnOffBehavior.ts → Insteon/ISYOnOffBehavior.ts} +9 -14
- package/src/Matter/Bridge/Server.ts +1 -1
- package/src/Matter/Mappings/Insteon.ts +3 -3
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.
|
|
5
|
+
"version": "1.0.1-alpha.27",
|
|
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": "
|
|
72
|
+
"gitHead": "6818f4140be310656690e21c6a451f42cae1ef8f"
|
|
73
73
|
}
|
package/src/Converters.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
import { UnitOfMeasure } from './Definitions/Global/UOM.js';
|
|
3
2
|
import { type StringKeys } from './Utils.js';
|
|
4
3
|
|
|
@@ -9,26 +8,21 @@ let NullConverter: Converter<any, any>;
|
|
|
9
8
|
from: (value: any) => value;
|
|
10
9
|
}
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
to: (value: number): boolean => {
|
|
14
|
-
return value > 0;
|
|
15
|
-
},
|
|
16
|
-
from: (value: boolean): number => {
|
|
17
|
-
return value ? 100 : 0;
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const StandardConverters: {
|
|
22
|
-
[x in `${keyof typeof UnitOfMeasure}`]?: { [y in `${keyof typeof UnitOfMeasure}`]?: Converter<any, any> };
|
|
23
|
-
} = {
|
|
11
|
+
const StandardConverters = {
|
|
24
12
|
Boolean: {
|
|
25
13
|
LevelFrom0To255: {
|
|
26
14
|
to: (value: boolean) => (value ? 255 : 0),
|
|
27
15
|
from: (value: number) => value > 0
|
|
28
16
|
},
|
|
29
|
-
Percent:
|
|
17
|
+
Percent: {
|
|
18
|
+
to: (value: number): boolean => {
|
|
19
|
+
return value > 0;
|
|
20
|
+
},
|
|
21
|
+
from: (value: boolean): number => {
|
|
22
|
+
return value ? 100 : 0;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
30
25
|
},
|
|
31
|
-
Percent: {},
|
|
32
26
|
LevelFrom0To255: {
|
|
33
27
|
Percent: {
|
|
34
28
|
to: (value: number): number => {
|
|
@@ -41,8 +35,8 @@ const StandardConverters: {
|
|
|
41
35
|
}
|
|
42
36
|
};
|
|
43
37
|
|
|
44
|
-
StandardConverters.Percent.LevelFrom0To255 = invert(StandardConverters.LevelFrom0To255.Percent);
|
|
45
|
-
StandardConverters.LevelFrom0To255.Boolean = invert(StandardConverters.Boolean.LevelFrom0To255);
|
|
38
|
+
//StandardConverters.Percent.LevelFrom0To255 = invert(StandardConverters.LevelFrom0To255.Percent);
|
|
39
|
+
//StandardConverters.LevelFrom0To255.Boolean = invert(StandardConverters.Boolean.LevelFrom0To255);
|
|
46
40
|
|
|
47
41
|
export const StdConverterRegistry = new Map<UnitOfMeasure | string, Map<UnitOfMeasure | string, Converter<any, any>>>();
|
|
48
42
|
|
|
@@ -94,6 +88,7 @@ export namespace Converter {
|
|
|
94
88
|
: value === 255 ? 254
|
|
95
89
|
: value
|
|
96
90
|
}
|
|
91
|
+
|
|
97
92
|
}
|
|
98
93
|
};
|
|
99
94
|
|
|
@@ -108,7 +103,7 @@ export namespace Converter {
|
|
|
108
103
|
export type MatterConverters = `${MatterISYConvertibleTypes}.${ISYMatterConvertibleTypes}` | `${ISYMatterConvertibleTypes}.${MatterISYConvertibleTypes}`;
|
|
109
104
|
|
|
110
105
|
export type KnownConverters = StandardConverters | MatterConverters;
|
|
111
|
-
const cache
|
|
106
|
+
const cache: { [x: string]: Converter<any, any> } = {};
|
|
112
107
|
export function get(label: KnownConverters): Converter<any, any>;
|
|
113
108
|
export function get(from: UnitOfMeasure, to: UnitOfMeasure);
|
|
114
109
|
export function get(from: ConverterTypes, to: ConverterTypes);
|
|
@@ -116,23 +111,22 @@ export namespace Converter {
|
|
|
116
111
|
export function get(from: MatterISYConvertibleTypes, to: ISYMatterConvertibleTypes);
|
|
117
112
|
export function get(to: ISYMatterConvertibleTypes, from: MatterISYConvertibleTypes);
|
|
118
113
|
export function get(from: UnitOfMeasure | `${keyof typeof UnitOfMeasure}` | string, to?: UnitOfMeasure | `${keyof typeof UnitOfMeasure}` | string): Converter<any, any> {
|
|
119
|
-
if(to === undefined) {
|
|
114
|
+
if (to === undefined) {
|
|
120
115
|
return ConverterRegistry.get(from as string) ?? NullConverter;
|
|
121
116
|
}
|
|
122
|
-
if(cache[`${from}.${to}`]) {
|
|
117
|
+
if (cache[`${from}.${to}`]) {
|
|
123
118
|
return cache[`${from}.${to}`];
|
|
124
|
-
}
|
|
125
|
-
else if(cache[`${to}.${from}`]) {
|
|
119
|
+
} else if (cache[`${to}.${from}`]) {
|
|
126
120
|
cache[`${from}.${to}`] = invert(cache[`${to}.${from}`]);
|
|
127
121
|
return cache[`${from}.${to}`];
|
|
128
122
|
}
|
|
129
123
|
let isString = typeof from === 'string';
|
|
130
124
|
let fuom = isString ? from : UnitOfMeasure[from];
|
|
131
125
|
if (to) {
|
|
132
|
-
let tuom = typeof to === 'string' ? to : UnitOfMeasure[to];
|
|
126
|
+
let tuom = typeof to === 'string' ? to : UnitOfMeasure[to];
|
|
133
127
|
|
|
134
128
|
if (StdConverterRegistry.has(fuom)) {
|
|
135
|
-
if(StdConverterRegistry.get(fuom).has(tuom)) {
|
|
129
|
+
if (StdConverterRegistry.get(fuom).has(tuom)) {
|
|
136
130
|
return StdConverterRegistry.get(fuom).get(tuom);
|
|
137
131
|
}
|
|
138
132
|
}
|
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
import { TimeFormatLocalization } from '@project-chip/matter.js/cluster';
|
|
2
2
|
import type { Identity, Merge, UnionToIntersection } from '@project-chip/matter.js/util';
|
|
3
3
|
import type { Sign } from 'crypto';
|
|
4
|
+
import type { UnitOfMeasure } from './UOM.js';
|
|
5
|
+
|
|
6
|
+
/*export class Command<T extends string> extends Function {
|
|
7
|
+
|
|
8
|
+
constructor(public readonly label: string) {
|
|
9
|
+
super();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public async execute(...args: any[]): Promise<Boolean> {
|
|
13
|
+
return this(...args);
|
|
14
|
+
}
|
|
15
|
+
}*/
|
|
4
16
|
|
|
5
17
|
export namespace Command {
|
|
6
18
|
|
|
7
|
-
export type Signature<F extends {name
|
|
19
|
+
export type Signature<F extends {name} = CallableFunction, L extends string = string,N extends string = string> = F & {label: L, name: N,} ;
|
|
8
20
|
|
|
9
21
|
export type Signatures<C extends string> = {[K in C]: Signature<(...args: any[]) => Promise<Boolean>, string, string>};
|
|
10
22
|
|
|
@@ -39,13 +39,13 @@ export class DimmerLampSwitchNode extends Base<Drivers, Commands> implements Dim
|
|
|
39
39
|
declare readonly nodeDefId: 'DimmerLampSwitch';
|
|
40
40
|
constructor(isy: ISY, nodeInfo: NodeInfo) {
|
|
41
41
|
super(isy, nodeInfo);
|
|
42
|
-
this.drivers.ST = Driver.create('ST', this, nodeInfo.state['ST'], { uom: UnitOfMeasure.
|
|
42
|
+
this.drivers.ST = Driver.create('ST', this, nodeInfo.state['ST'], { uom: UnitOfMeasure.LevelFrom0To255, label: 'Status', name: 'status' });
|
|
43
43
|
this.drivers.OL = Driver.create('OL', this, nodeInfo.state['OL'] as DriverState, { uom: UnitOfMeasure.Percent, label: 'On Level', name: 'onLevel' });
|
|
44
44
|
this.drivers.RR = Driver.create('RR', this, nodeInfo.state['RR'] as DriverState, { uom: UnitOfMeasure.Index, label: 'Ramp Rate', name: 'rampRate' });
|
|
45
45
|
this.drivers.ERR = Driver.create('ERR', this, nodeInfo.state['ERR'] as DriverState, { uom: UnitOfMeasure.Index, label: 'Responding', name: 'responding' });
|
|
46
46
|
}
|
|
47
47
|
async on(value?: number) {
|
|
48
|
-
return this.sendCommand('DON',
|
|
48
|
+
return this.sendCommand('DON', value);
|
|
49
49
|
}
|
|
50
50
|
async off() {
|
|
51
51
|
return this.sendCommand('DOF');
|
|
@@ -180,7 +180,7 @@ export namespace DimmerLampSwitch {
|
|
|
180
180
|
};
|
|
181
181
|
export type Drivers = {
|
|
182
182
|
ST: {
|
|
183
|
-
uom: UnitOfMeasure.
|
|
183
|
+
uom: UnitOfMeasure.LevelFrom0To255;
|
|
184
184
|
value: number;
|
|
185
185
|
label: 'Status';
|
|
186
186
|
name: 'status';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/* THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT DIRECTLY. */
|
|
2
|
-
|
|
1
|
+
/* THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT DIRECTLY. */
|
|
2
|
+
|
|
3
3
|
import { UnitOfMeasure } from "../../../Definitions/Global/UOM.js";
|
|
4
4
|
import { Family } from "../../../Definitions/Global/Families.js";
|
|
5
5
|
import type { NodeInfo } from "../../../Model/NodeInfo.js";
|
|
@@ -11,12 +11,13 @@ import { Driver } from "../../../Definitions/Global/Drivers.js";
|
|
|
11
11
|
import { Insteon } from "../../../Definitions/index.js";
|
|
12
12
|
import type { DriverState } from "../../../Model/DriverState.js";
|
|
13
13
|
import { NodeFactory } from "../../NodeFactory.js";
|
|
14
|
-
|
|
14
|
+
import { validateHeaderName } from 'http';
|
|
15
|
+
|
|
15
16
|
export const nodeDefId = "DimmerLampSwitch";
|
|
16
|
-
|
|
17
|
+
|
|
17
18
|
type Commands = DimmerLampSwitch.Commands;
|
|
18
19
|
type Drivers = DimmerLampSwitch.Drivers;
|
|
19
|
-
|
|
20
|
+
|
|
20
21
|
export class DimmerLampSwitchNode extends Base<Drivers, Commands> implements DimmerLampSwitch.Interface {
|
|
21
22
|
public readonly commands = {
|
|
22
23
|
DON: this.on,
|
|
@@ -102,9 +103,9 @@ export class DimmerLampSwitchNode extends Base<Drivers, Commands> implements Dim
|
|
|
102
103
|
return this.drivers.ERR?.value;
|
|
103
104
|
}
|
|
104
105
|
}
|
|
105
|
-
|
|
106
|
+
|
|
106
107
|
NodeFactory.register(DimmerLampSwitchNode);
|
|
107
|
-
|
|
108
|
+
|
|
108
109
|
export namespace DimmerLampSwitch {
|
|
109
110
|
export interface Interface extends Omit<InstanceType<typeof DimmerLampSwitchNode>, keyof ISYDeviceNode<any, any, any, any>> {
|
|
110
111
|
nodeDefId: "DimmerLampSwitch";
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/* THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT DIRECTLY. */
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import { Family } from
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import type {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
3
|
+
import { Driver } from '../../Definitions/Global/Drivers.js';
|
|
4
|
+
import { Family } from '../../Definitions/Global/Families.js';
|
|
5
|
+
import { UnitOfMeasure } from '../../Definitions/Global/UOM.js';
|
|
6
|
+
import { Insteon } from '../../Definitions/index.js';
|
|
7
|
+
import type { ISY } from '../../ISY.js';
|
|
8
|
+
import type { ISYNode } from '../../ISYNode.js';
|
|
9
|
+
import type { DriverState } from '../../Model/DriverState.js';
|
|
10
|
+
import type { NodeInfo } from '../../Model/NodeInfo.js';
|
|
11
|
+
import { ISYDeviceNode } from '../ISYDeviceNode.js';
|
|
12
|
+
import { NodeFactory } from '../NodeFactory.js';
|
|
13
|
+
import { InsteonBaseDevice } from './InsteonBaseDevice.js';
|
|
14
14
|
|
|
15
|
-
export const nodeDefId =
|
|
15
|
+
export const nodeDefId = 'RelayLampSwitch';
|
|
16
16
|
|
|
17
17
|
type Commands = RelayLampSwitch.Commands;
|
|
18
18
|
type Drivers = RelayLampSwitch.Drivers;
|
|
@@ -32,11 +32,11 @@ export class RelayLampSwitchNode extends InsteonBaseDevice<Drivers, Commands> im
|
|
|
32
32
|
declare readonly nodeDefId: 'RelayLampSwitch';
|
|
33
33
|
constructor(isy: ISY, nodeInfo: NodeInfo) {
|
|
34
34
|
super(isy, nodeInfo);
|
|
35
|
-
this.drivers.ST = Driver.create('ST', this, nodeInfo.state['ST'], { uom: UnitOfMeasure.
|
|
35
|
+
this.drivers.ST = Driver.create('ST', this, nodeInfo.state['ST'], { uom: UnitOfMeasure.Boolean, label: 'Status', name: 'status' });
|
|
36
36
|
this.drivers.ERR = Driver.create('ERR', this, nodeInfo.state['ERR'], { uom: UnitOfMeasure.Index, label: 'Responding', name: 'responding' });
|
|
37
37
|
}
|
|
38
38
|
async on(value?: 0 | 100) {
|
|
39
|
-
return this.sendCommand('DON',
|
|
39
|
+
return this.sendCommand('DON', value);
|
|
40
40
|
}
|
|
41
41
|
async off() {
|
|
42
42
|
return this.sendCommand('DOF');
|
|
@@ -59,7 +59,7 @@ export class RelayLampSwitchNode extends InsteonBaseDevice<Drivers, Commands> im
|
|
|
59
59
|
async writeChanges() {
|
|
60
60
|
return this.sendCommand('WDU');
|
|
61
61
|
}
|
|
62
|
-
public get status():
|
|
62
|
+
public get status(): boolean {
|
|
63
63
|
return this.drivers.ST?.value;
|
|
64
64
|
}
|
|
65
65
|
public get responding(): Insteon.Error {
|
|
@@ -71,7 +71,7 @@ NodeFactory.register(RelayLampSwitchNode);
|
|
|
71
71
|
|
|
72
72
|
export namespace RelayLampSwitch {
|
|
73
73
|
export interface Interface extends Omit<InstanceType<typeof RelayLampSwitchNode>, keyof ISYDeviceNode<any, any, any, any>> {
|
|
74
|
-
nodeDefId:
|
|
74
|
+
nodeDefId: 'RelayLampSwitch';
|
|
75
75
|
}
|
|
76
76
|
export function is(node: ISYNode<any, any, any, any>): node is RelayLampSwitchNode {
|
|
77
77
|
return node.nodeDefId === nodeDefId;
|
|
@@ -81,51 +81,51 @@ export namespace RelayLampSwitch {
|
|
|
81
81
|
}
|
|
82
82
|
export const Node = RelayLampSwitchNode;
|
|
83
83
|
export type Commands = {
|
|
84
|
-
DON: ((value?:
|
|
85
|
-
label:
|
|
86
|
-
name:
|
|
84
|
+
DON: ((value?: 0 | 100) => Promise<boolean>) & {
|
|
85
|
+
label: 'On';
|
|
86
|
+
name: 'on';
|
|
87
87
|
};
|
|
88
88
|
DOF: (() => Promise<boolean>) & {
|
|
89
|
-
label:
|
|
90
|
-
name:
|
|
89
|
+
label: 'Off';
|
|
90
|
+
name: 'off';
|
|
91
91
|
};
|
|
92
92
|
DFOF: (() => Promise<boolean>) & {
|
|
93
|
-
label:
|
|
94
|
-
name:
|
|
93
|
+
label: 'Fast Off';
|
|
94
|
+
name: 'fastOff';
|
|
95
95
|
};
|
|
96
96
|
DFON: (() => Promise<boolean>) & {
|
|
97
|
-
label:
|
|
98
|
-
name:
|
|
97
|
+
label: 'Fast On';
|
|
98
|
+
name: 'fastOn';
|
|
99
99
|
};
|
|
100
100
|
QUERY: (() => Promise<boolean>) & {
|
|
101
|
-
label:
|
|
102
|
-
name:
|
|
101
|
+
label: 'Query';
|
|
102
|
+
name: 'query';
|
|
103
103
|
};
|
|
104
104
|
BEEP: ((value?: number) => Promise<boolean>) & {
|
|
105
|
-
label:
|
|
106
|
-
name:
|
|
105
|
+
label: 'Beep';
|
|
106
|
+
name: 'beep';
|
|
107
107
|
};
|
|
108
108
|
BL: ((value: number) => Promise<boolean>) & {
|
|
109
|
-
label:
|
|
110
|
-
name:
|
|
109
|
+
label: 'Backlight';
|
|
110
|
+
name: 'backlight';
|
|
111
111
|
};
|
|
112
112
|
WDU: (() => Promise<boolean>) & {
|
|
113
|
-
label:
|
|
114
|
-
name:
|
|
113
|
+
label: 'Write Changes';
|
|
114
|
+
name: 'writeChanges';
|
|
115
115
|
};
|
|
116
116
|
};
|
|
117
117
|
export type Drivers = {
|
|
118
118
|
ST: {
|
|
119
|
-
uom: UnitOfMeasure.
|
|
120
|
-
value:
|
|
121
|
-
label:
|
|
122
|
-
name:
|
|
119
|
+
uom: UnitOfMeasure.Boolean;
|
|
120
|
+
value: boolean;
|
|
121
|
+
label: 'Status';
|
|
122
|
+
name: 'status';
|
|
123
123
|
};
|
|
124
124
|
ERR: {
|
|
125
125
|
uom: UnitOfMeasure.Index;
|
|
126
126
|
value: Insteon.Error;
|
|
127
|
-
label:
|
|
128
|
-
name:
|
|
127
|
+
label: 'Responding';
|
|
128
|
+
name: 'responding';
|
|
129
129
|
};
|
|
130
130
|
};
|
|
131
131
|
}
|
package/src/ISYScene.ts
CHANGED
|
@@ -77,7 +77,7 @@ export class ISYScene extends ISYNode<Family.Scene, Driver.Signatures<'ST'>,Comm
|
|
|
77
77
|
get isOn() {
|
|
78
78
|
for (const device of this.members) {
|
|
79
79
|
if (device instanceof Insteon.Relay) {
|
|
80
|
-
if (device.drivers.ST?.value
|
|
80
|
+
if (device.drivers.ST?.value) {
|
|
81
81
|
return true;
|
|
82
82
|
}
|
|
83
83
|
}
|
|
@@ -12,6 +12,7 @@ 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
14
|
import { DeviceToClusterMap, MappingRegistry, type ClusterMapping, type BehaviorMapping } from '../../Model/ClusterMap.js';
|
|
15
|
+
import { server } from 'typescript';
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
type ClusterForBehavior<B extends ClusterBehavior> = B extends ClusterBehavior.Type<infer C> ? C : never;
|
|
@@ -31,9 +32,11 @@ export class ISYBridgedDeviceBehavior<N extends ISYNode<any, D, any, any>, D ext
|
|
|
31
32
|
const d = ISY.instance.nodeMap.get(this.state.address);
|
|
32
33
|
this.internal.device = d;
|
|
33
34
|
this.internal.map = MappingRegistry.getMapping(this.internal.device as unknown as ISYNode<Family, any, any, any>);
|
|
35
|
+
|
|
34
36
|
ISY.instance.logger.debug(`Initializing ${this.constructor.name} for ${this.internal.device.constructor.name} ${this.internal.device.name} with address ${address}`);
|
|
35
37
|
if (d) {
|
|
36
38
|
d.events.on('propertyChanged', this.handlePropertyChange.bind(this));
|
|
39
|
+
|
|
37
40
|
for(const f in d.drivers)
|
|
38
41
|
{
|
|
39
42
|
let evt = `${d.drivers[f].name}Changed`;
|
|
@@ -41,7 +44,8 @@ export class ISYBridgedDeviceBehavior<N extends ISYNode<any, D, any, any>, D ext
|
|
|
41
44
|
|
|
42
45
|
d.events.on(evt, (driver: string, newValue: any, oldValue: any, formattedValue: string) => obs.emit({ driver, newValue, oldValue, formattedValue }));
|
|
43
46
|
this.events[evt] = obs;
|
|
44
|
-
|
|
47
|
+
|
|
48
|
+
|
|
45
49
|
//@ts-ignore
|
|
46
50
|
//d.events.on(evt, (driver: string, newValue: any, oldValue: any, formattedValue: string) => this.events.emit(evt, { driver, newValue, oldValue, formattedValue } as unknown as any));
|
|
47
51
|
|
|
@@ -62,13 +66,17 @@ export class ISYBridgedDeviceBehavior<N extends ISYNode<any, D, any, any>, D ext
|
|
|
62
66
|
}
|
|
63
67
|
|
|
64
68
|
handlePropertyChange(driver: string, newValue: any, oldValue: any, formattedValue: string) {
|
|
69
|
+
|
|
65
70
|
this.events.propertyChanged.emit({ driver, newValue, oldValue, formattedValue });
|
|
71
|
+
|
|
72
|
+
|
|
66
73
|
}
|
|
67
74
|
|
|
68
75
|
override [Symbol.asyncDispose]() {
|
|
69
76
|
|
|
70
77
|
this.internal.device = null;
|
|
71
78
|
|
|
79
|
+
|
|
72
80
|
return super[Symbol.asyncDispose]();
|
|
73
81
|
}
|
|
74
82
|
}
|
|
@@ -15,6 +15,7 @@ import { ISY, type ISYDevice } from '../../ISY.js';
|
|
|
15
15
|
import type { DriversOf, ISYNode } from '../../ISYNode.js';
|
|
16
16
|
import { BehaviorMapping, MappingRegistry, type ClusterMapping, type DeviceToClusterMap } from '../../Model/ClusterMap.js';
|
|
17
17
|
import { ISYBridgedDeviceBehavior } from './ISYBridgedDeviceBehavior.js';
|
|
18
|
+
import { loggers } from 'winston';
|
|
18
19
|
|
|
19
20
|
// #region Type aliases (6)
|
|
20
21
|
|
|
@@ -61,28 +62,34 @@ export function ISYClusterBehavior<T extends Constructor<ClusterBehavior> & { cl
|
|
|
61
62
|
|
|
62
63
|
override async initialize(_options?: {}) {
|
|
63
64
|
await super.initialize(_options);
|
|
65
|
+
|
|
64
66
|
var behavior = (await this.agent.load(ISYBridgedDeviceBehavior)) as ISYBridgedDeviceBehavior<P>;
|
|
65
67
|
this.bridgedDeviceBehavior = behavior;
|
|
66
68
|
//var behavior = this.agent.get(ISYBridgedDeviceBehavior);
|
|
67
69
|
this._device = behavior.device as P;
|
|
68
70
|
//@ts-ignore
|
|
71
|
+
|
|
69
72
|
this.map = behavior.mapForBehavior<T>(this as unknown as T);
|
|
70
73
|
for (const key2 in this.map.attributes) {
|
|
71
74
|
let val = this.map.attributes[key2];
|
|
72
75
|
let driverObj = null;
|
|
73
76
|
if (typeof val === 'string' || typeof val === 'symbol' || typeof val === 'number') {
|
|
74
77
|
driverObj = this._device.drivers[val];
|
|
78
|
+
this.state[key2 as string] = this._device.drivers[val].value;
|
|
75
79
|
this.handlers[val] = (newValue, oldValue, formattedValue) => {
|
|
76
80
|
this.state[key2 as string] = newValue;
|
|
77
81
|
};
|
|
82
|
+
|
|
78
83
|
} else if (val.driver as DriversOf<P>) {
|
|
79
84
|
driverObj = this._device.drivers[val.driver as string];
|
|
80
85
|
|
|
81
86
|
let { driver, converter } = val;
|
|
82
|
-
const convFunc = Converter.get(converter)?.
|
|
87
|
+
const convFunc = Converter.get(converter)?.to;
|
|
88
|
+
if(!convFunc) throw new Error(`Converter ${converter} not found`);
|
|
89
|
+
this.state[key2 as string] = convFunc(this._device.drivers[driver as string].value);
|
|
83
90
|
this.handlers[driver] = (newValue, oldValue, formattedValue) => {
|
|
84
|
-
if (convFunc) this.state[key2 as string] = convFunc(newValue);
|
|
85
|
-
|
|
91
|
+
//if (convFunc) this.state[key2 as string] = convFunc(newValue);
|
|
92
|
+
this.state[key2 as string] = convFunc(newValue);
|
|
86
93
|
};
|
|
87
94
|
}
|
|
88
95
|
if (driverObj) {
|
|
@@ -5,39 +5,33 @@ import { DimmableLightRequirements } from '@project-chip/matter.js/devices/Dimma
|
|
|
5
5
|
import { OnOffLightRequirements } from '@project-chip/matter.js/devices/OnOffLightDevice';
|
|
6
6
|
import { OnOffLightSwitchDevice } from '@project-chip/matter.js/devices/OnOffLightSwitchDevice';
|
|
7
7
|
import type { MaybePromise } from '@project-chip/matter.js/util';
|
|
8
|
-
import { DriverType } from '
|
|
9
|
-
import { InsteonDimmableDevice } from '
|
|
10
|
-
import { InsteonRelayDevice } from '
|
|
11
|
-
import { MappingRegistry } from '
|
|
12
|
-
import { ClusterForBehavior, ISYClusterBehavior, type PropertyChange } from '
|
|
8
|
+
import { DriverType } from '../../../Definitions/Global/Drivers.js';
|
|
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 { Converter } from '
|
|
14
|
+
import { Converter } from '../../../Converters.js';
|
|
15
15
|
|
|
16
16
|
export class ISYOnOffBehavior extends ISYClusterBehavior(OnOffLightRequirements.OnOffServer, InsteonRelayDevice) {
|
|
17
17
|
override async initialize(_options?: {}) {
|
|
18
18
|
await super.initialize(_options);
|
|
19
|
-
this.state.onOff =
|
|
19
|
+
//this.state.onOff = this.device.status;
|
|
20
20
|
//this.state.onOff = await this.device.state;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
override on = async () => {
|
|
24
|
-
await super.on();
|
|
25
24
|
await this.device.on();
|
|
26
25
|
|
|
27
26
|
//this.device.commands.DON = true;
|
|
28
27
|
};
|
|
29
28
|
|
|
30
29
|
override async off() {
|
|
31
|
-
await super.off();
|
|
32
30
|
await this.device.off();
|
|
33
31
|
|
|
34
32
|
// this.device.drivers = false;
|
|
35
33
|
}
|
|
36
34
|
|
|
37
|
-
override toggle = async () => {
|
|
38
|
-
//this.device.state = !(await this.device.state);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
35
|
override async handlePropertyChange({ driver, newValue, oldValue, formattedValue }: PropertyChange<InsteonRelayDevice>) {
|
|
42
36
|
|
|
43
37
|
return super.handlePropertyChange({ driver, newValue, oldValue, formattedValue });
|
|
@@ -56,9 +50,10 @@ export class ISYDimmableBehavior extends ISYClusterBehavior(DimmableLightRequire
|
|
|
56
50
|
override setLevel(level: number): MaybePromise<void> {
|
|
57
51
|
level = Converter.Matter.LevelFrom0To255.LightingLevel.from(level);
|
|
58
52
|
if (level > 0) {
|
|
59
|
-
return this.device.on();
|
|
53
|
+
return this.device.on(level);
|
|
60
54
|
} else {
|
|
61
55
|
return this.device.off();
|
|
62
56
|
}
|
|
57
|
+
|
|
63
58
|
}
|
|
64
59
|
}
|
|
@@ -20,7 +20,7 @@ import { format, loggers } from 'winston';
|
|
|
20
20
|
import type { ISYDeviceNode } from '../../Devices/ISYDeviceNode.js';
|
|
21
21
|
import { InsteonDimmableDevice, InsteonKeypadButtonDevice, InsteonRelayDevice, ISY } from '../../ISY.js';
|
|
22
22
|
import { ISYBridgedDeviceBehavior } from '../Behaviors/ISYBridgedDeviceBehavior.js';
|
|
23
|
-
import { ISYDimmableBehavior, ISYOnOffBehavior } from '../Behaviors/ISYOnOffBehavior.js';
|
|
23
|
+
import { ISYDimmableBehavior, ISYOnOffBehavior } from '../Behaviors/Insteon/ISYOnOffBehavior.js';
|
|
24
24
|
import '../Mappings/Insteon.js';
|
|
25
25
|
|
|
26
26
|
// #region Interfaces (1)
|
|
@@ -19,7 +19,7 @@ const map: FamilyToClusterMap<Family.Insteon> = {
|
|
|
19
19
|
mapping: {
|
|
20
20
|
OnOff: {
|
|
21
21
|
attributes: {
|
|
22
|
-
onOff:
|
|
22
|
+
onOff: 'ST'
|
|
23
23
|
},
|
|
24
24
|
commands: { on: 'DON' }
|
|
25
25
|
}
|
|
@@ -47,9 +47,9 @@ const map: FamilyToClusterMap<Family.Insteon> = {
|
|
|
47
47
|
},
|
|
48
48
|
LevelControl: {
|
|
49
49
|
attributes: {
|
|
50
|
-
currentLevel: { driver:
|
|
50
|
+
currentLevel: { driver: 'ST', converter: 'LevelFrom0To255.LightingLevel' }
|
|
51
51
|
},
|
|
52
|
-
commands: {
|
|
52
|
+
commands: { setLevel: { command: 'DON' } }
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
}
|