matterbridge-example-accessory-platform 1.0.15 → 1.0.17
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/platform.d.ts.map +1 -1
- package/dist/platform.js +15 -24
- package/dist/platform.js.map +1 -1
- package/link-matterbridge-script.js +1 -15
- package/npm-shrinkwrap.json +5705 -0
- package/package.json +19 -19
package/dist/platform.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,6BAA6B,EAAe,cAAc,EAA+B,MAAM,cAAc,CAAC;AACzJ,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,6BAA6B,EAAe,cAAc,EAA+B,MAAM,cAAc,CAAC;AACzJ,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGjD,qBAAa,oCAAqC,SAAQ,6BAA6B;IACrF,KAAK,EAAE,kBAAkB,GAAG,SAAS,CAAC;IACtC,aAAa,EAAE,MAAM,CAAC,OAAO,GAAG,SAAS,CAAC;gBAE9B,YAAY,EAAE,YAAY,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,cAAc;IAKhE,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM;IAiDvB,WAAW;IA2BX,UAAU,CAAC,MAAM,CAAC,EAAE,MAAM;CAK1C"}
|
package/dist/platform.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { MatterbridgeDevice, MatterbridgeAccessoryPlatform, DeviceTypes, WindowCovering, powerSource } from 'matterbridge';
|
|
2
|
+
import os from 'os';
|
|
2
3
|
export class ExampleMatterbridgeAccessoryPlatform extends MatterbridgeAccessoryPlatform {
|
|
3
4
|
cover;
|
|
4
5
|
coverInterval;
|
|
@@ -10,7 +11,7 @@ export class ExampleMatterbridgeAccessoryPlatform extends MatterbridgeAccessoryP
|
|
|
10
11
|
this.log.info('onStart called with reason:', reason ?? 'none');
|
|
11
12
|
this.cover = new MatterbridgeDevice(DeviceTypes.WINDOW_COVERING);
|
|
12
13
|
this.cover.createDefaultIdentifyClusterServer();
|
|
13
|
-
this.cover.createDefaultBasicInformationClusterServer('
|
|
14
|
+
this.cover.createDefaultBasicInformationClusterServer('Cover device', `0x59108853_${os.hostname()}`, 0xfff1, 'Matterbridge', 0x0001, 'Matterbridge Cover');
|
|
14
15
|
this.cover.createDefaultWindowCoveringClusterServer(10000);
|
|
15
16
|
this.cover.addDeviceType(powerSource);
|
|
16
17
|
this.cover.createDefaultPowerSourceWiredClusterServer();
|
|
@@ -19,37 +20,27 @@ export class ExampleMatterbridgeAccessoryPlatform extends MatterbridgeAccessoryP
|
|
|
19
20
|
this.log.info(`Command identify called identifyTime:${identifyTime}`);
|
|
20
21
|
});
|
|
21
22
|
this.cover.addCommandHandler('stopMotion', async ({ attributes: { currentPositionLiftPercent100ths, targetPositionLiftPercent100ths, operationalStatus } }) => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
this.
|
|
31
|
-
this.log.
|
|
32
|
-
this.log.debug(`Command stopMotion called. Attributes: operationalStatus: ${operationalStatus?.getLocal().lift}`);
|
|
23
|
+
this.cover?.setWindowCoveringTargetAsCurrentAndStopped();
|
|
24
|
+
this.cover?.log.info(`Command stopMotion called: current ${currentPositionLiftPercent100ths?.getLocal()} target ${targetPositionLiftPercent100ths?.getLocal()} status ${operationalStatus?.getLocal().lift}`);
|
|
25
|
+
});
|
|
26
|
+
this.cover.addCommandHandler('upOrOpen', async ({ attributes: { currentPositionLiftPercent100ths, targetPositionLiftPercent100ths, operationalStatus } }) => {
|
|
27
|
+
this.cover?.setWindowCoveringCurrentTargetStatus(0, 0, WindowCovering.MovementStatus.Stopped);
|
|
28
|
+
this.cover?.log.info(`Command upOrOpen called: current ${currentPositionLiftPercent100ths?.getLocal()} target ${targetPositionLiftPercent100ths?.getLocal()} status ${operationalStatus?.getLocal().lift}`);
|
|
29
|
+
});
|
|
30
|
+
this.cover.addCommandHandler('downOrClose', async ({ attributes: { currentPositionLiftPercent100ths, targetPositionLiftPercent100ths, operationalStatus } }) => {
|
|
31
|
+
this.cover?.setWindowCoveringCurrentTargetStatus(10000, 10000, WindowCovering.MovementStatus.Stopped);
|
|
32
|
+
this.cover?.log.info(`Command downOrClose called: current ${currentPositionLiftPercent100ths?.getLocal()} target ${targetPositionLiftPercent100ths?.getLocal()} status ${operationalStatus?.getLocal().lift}`);
|
|
33
33
|
});
|
|
34
34
|
this.cover.addCommandHandler('goToLiftPercentage', async ({ request: { liftPercent100thsValue }, attributes: { currentPositionLiftPercent100ths, targetPositionLiftPercent100ths, operationalStatus } }) => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
operationalStatus.setLocal({
|
|
38
|
-
global: WindowCovering.MovementStatus.Stopped,
|
|
39
|
-
lift: WindowCovering.MovementStatus.Stopped,
|
|
40
|
-
tilt: WindowCovering.MovementStatus.Stopped,
|
|
41
|
-
});
|
|
42
|
-
this.log.info(`Command goToLiftPercentage called. Request: liftPercent100thsValue: ${liftPercent100thsValue} `);
|
|
43
|
-
this.log.debug(`Command goToLiftPercentage called. Attributes: currentPositionLiftPercent100ths: ${currentPositionLiftPercent100ths?.getLocal()}`);
|
|
44
|
-
this.log.debug(`Command goToLiftPercentage called. Attributes: targetPositionLiftPercent100ths: ${targetPositionLiftPercent100ths?.getLocal()}`);
|
|
45
|
-
this.log.debug(`Command goToLiftPercentage called. Attributes: operationalStatus: ${operationalStatus?.getLocal().lift}`);
|
|
35
|
+
this.cover?.setWindowCoveringCurrentTargetStatus(liftPercent100thsValue, liftPercent100thsValue, WindowCovering.MovementStatus.Stopped);
|
|
36
|
+
this.cover?.log.info(`Command goToLiftPercentage ${liftPercent100thsValue} called: current ${currentPositionLiftPercent100ths?.getLocal()} target ${targetPositionLiftPercent100ths?.getLocal()} status ${operationalStatus?.getLocal().lift}`);
|
|
46
37
|
});
|
|
47
38
|
}
|
|
48
39
|
async onConfigure() {
|
|
49
40
|
this.log.info('onConfigure called');
|
|
50
41
|
// Set cover to target = current position and status to stopped (current position is persisted in the cluster)
|
|
51
42
|
this.cover?.setWindowCoveringTargetAsCurrentAndStopped();
|
|
52
|
-
this.log.
|
|
43
|
+
this.log.info('Set cover initial targetPositionLiftPercent100ths = currentPositionLiftPercent100ths and operationalStatus to Stopped.');
|
|
53
44
|
this.coverInterval = setInterval(() => {
|
|
54
45
|
if (!this.cover)
|
|
55
46
|
return;
|
package/dist/platform.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,kBAAkB,EAAE,6BAA6B,EAAE,WAAW,EAAkB,cAAc,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,kBAAkB,EAAE,6BAA6B,EAAE,WAAW,EAAkB,cAAc,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEzJ,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,MAAM,OAAO,oCAAqC,SAAQ,6BAA6B;IACrF,KAAK,CAAiC;IACtC,aAAa,CAA6B;IAE1C,YAAY,YAA0B,EAAE,GAAe,EAAE,MAAsB;QAC7E,KAAK,CAAC,YAAY,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;QACjC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,wBAAwB,EAAE,IAAI,CAAC,MAAM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C;gBACpE,YAAY,CAAC,6BAA6B,CAAC;oBACzC,MAAM,EAAE,cAAc,CAAC,cAAc,CAAC,OAAO;oBAC7C,IAAI,EAAE,cAAc,CAAC,cAAc,CAAC,OAAO;oBAC3C,IAAI,EAAE,cAAc,CAAC,cAAc,CAAC,OAAO;iBAC5C,CAAC,CAAC;gBACH,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,iCAAiC,QAAQ,EAAE,CAAC,CAAC;YAC7D,CAAC;QACH,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IAChB,CAAC;IAEQ,KAAK,CAAC,UAAU,CAAC,MAAe;QACvC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,gCAAgC,EAAE,MAAM,IAAI,MAAM,CAAC,CAAC;QAClE,aAAa,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAClC,IAAI,IAAI,CAAC,MAAM,CAAC,oBAAoB,KAAK,IAAI;YAAE,MAAM,IAAI,CAAC,oBAAoB,EAAE,CAAC;IACnF,CAAC;CACF"}
|
|
@@ -1,15 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { exec } from 'child_process';
|
|
3
|
-
|
|
4
|
-
const command = process.platform === 'win32' ? 'npm link matterbridge' : 'sudo npm link matterbridge';
|
|
5
|
-
|
|
6
|
-
exec(command, (error, stdout, stderr) => {
|
|
7
|
-
if (error) {
|
|
8
|
-
console.error(`exec error: ${error}`);
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
console.log(`stdout: ${stdout}`);
|
|
12
|
-
if (stderr) {
|
|
13
|
-
console.error(`stderr: ${stderr}`);
|
|
14
|
-
}
|
|
15
|
-
});
|
|
1
|
+
// Nothing to do in production, just a script to link the matterbridge package in development
|