matterbridge-example-accessory-platform 1.0.17 → 1.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +35 -35
- package/dist/platform.js.map +1 -1
- package/npm-shrinkwrap.json +22 -5664
- package/package.json +8 -23
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,
|
|
1
|
+
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,kBAAkB,EAElB,6BAA6B,EAE7B,cAAc,EAMf,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,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;IAahE,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM;IA8DvB,WAAW;IAkBX,UAAU,CAAC,MAAM,CAAC,EAAE,MAAM;CAK1C"}
|
package/dist/platform.js
CHANGED
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
import { MatterbridgeDevice,
|
|
2
|
-
|
|
1
|
+
import { MatterbridgeDevice,
|
|
2
|
+
// MatterbridgeEndpoint as MatterbridgeDevice,
|
|
3
|
+
MatterbridgeAccessoryPlatform, DeviceTypes, WindowCovering, powerSource, WindowCoveringCluster, } from 'matterbridge';
|
|
4
|
+
import { isValidNumber } from 'matterbridge/utils';
|
|
3
5
|
export class ExampleMatterbridgeAccessoryPlatform extends MatterbridgeAccessoryPlatform {
|
|
4
6
|
cover;
|
|
5
7
|
coverInterval;
|
|
6
8
|
constructor(matterbridge, log, config) {
|
|
7
9
|
super(matterbridge, log, config);
|
|
10
|
+
// Verify that Matterbridge is the correct version
|
|
11
|
+
if (this.verifyMatterbridgeVersion === undefined || typeof this.verifyMatterbridgeVersion !== 'function' || !this.verifyMatterbridgeVersion('1.6.0')) {
|
|
12
|
+
throw new Error(`This plugin requires Matterbridge version >= "1.6.0". Please update Matterbridge from ${this.matterbridge.matterbridgeVersion} to the latest version in the frontend."`);
|
|
13
|
+
}
|
|
8
14
|
this.log.info('Initializing platform:', this.config.name);
|
|
9
15
|
}
|
|
10
16
|
async onStart(reason) {
|
|
11
17
|
this.log.info('onStart called with reason:', reason ?? 'none');
|
|
12
|
-
this.cover = new MatterbridgeDevice(DeviceTypes.WINDOW_COVERING);
|
|
18
|
+
this.cover = new MatterbridgeDevice(DeviceTypes.WINDOW_COVERING, { uniqueStorageKey: 'Cover example device' }, this.config.debug);
|
|
13
19
|
this.cover.createDefaultIdentifyClusterServer();
|
|
14
|
-
this.cover.createDefaultBasicInformationClusterServer('Cover device', `
|
|
20
|
+
this.cover.createDefaultBasicInformationClusterServer('Cover example device', `0x59108853594}`, 0xfff1, 'Matterbridge', 0x0001, 'Matterbridge Cover');
|
|
15
21
|
this.cover.createDefaultWindowCoveringClusterServer(10000);
|
|
16
22
|
this.cover.addDeviceType(powerSource);
|
|
17
23
|
this.cover.createDefaultPowerSourceWiredClusterServer();
|
|
18
24
|
await this.registerDevice(this.cover);
|
|
25
|
+
this.cover.subscribeAttribute(WindowCoveringCluster.id, 'mode', (newValue, oldValue) => {
|
|
26
|
+
this.log.info(`Attribute mode changed from ${oldValue} to ${newValue}. Reverse: ${newValue.motorDirectionReversed}. Calibration: ${newValue.calibrationMode}. Maintenance: ${newValue.maintenanceMode}. LED: ${newValue.ledFeedback}`);
|
|
27
|
+
}, this.log);
|
|
19
28
|
this.cover.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
|
20
29
|
this.log.info(`Command identify called identifyTime:${identifyTime}`);
|
|
21
30
|
});
|
|
22
|
-
this.cover.addCommandHandler('stopMotion', async (
|
|
23
|
-
this.cover?.setWindowCoveringTargetAsCurrentAndStopped();
|
|
24
|
-
this.cover?.log.info(`Command stopMotion called
|
|
31
|
+
this.cover.addCommandHandler('stopMotion', async () => {
|
|
32
|
+
await this.cover?.setWindowCoveringTargetAsCurrentAndStopped();
|
|
33
|
+
this.cover?.log.info(`Command stopMotion called`);
|
|
25
34
|
});
|
|
26
|
-
this.cover.addCommandHandler('upOrOpen', async (
|
|
27
|
-
this.cover?.setWindowCoveringCurrentTargetStatus(0, 0, WindowCovering.MovementStatus.Stopped);
|
|
28
|
-
this.cover?.log.info(`Command upOrOpen called
|
|
35
|
+
this.cover.addCommandHandler('upOrOpen', async () => {
|
|
36
|
+
await this.cover?.setWindowCoveringCurrentTargetStatus(0, 0, WindowCovering.MovementStatus.Stopped);
|
|
37
|
+
this.cover?.log.info(`Command upOrOpen called`);
|
|
29
38
|
});
|
|
30
|
-
this.cover.addCommandHandler('downOrClose', async (
|
|
31
|
-
this.cover?.setWindowCoveringCurrentTargetStatus(10000, 10000, WindowCovering.MovementStatus.Stopped);
|
|
32
|
-
this.cover?.log.info(`Command downOrClose called
|
|
39
|
+
this.cover.addCommandHandler('downOrClose', async () => {
|
|
40
|
+
await this.cover?.setWindowCoveringCurrentTargetStatus(10000, 10000, WindowCovering.MovementStatus.Stopped);
|
|
41
|
+
this.cover?.log.info(`Command downOrClose called`);
|
|
33
42
|
});
|
|
34
|
-
this.cover.addCommandHandler('goToLiftPercentage', async ({ request: { liftPercent100thsValue }
|
|
35
|
-
this.cover?.setWindowCoveringCurrentTargetStatus(liftPercent100thsValue, liftPercent100thsValue, WindowCovering.MovementStatus.Stopped);
|
|
36
|
-
this.cover?.log.info(`Command goToLiftPercentage ${liftPercent100thsValue} called
|
|
43
|
+
this.cover.addCommandHandler('goToLiftPercentage', async ({ request: { liftPercent100thsValue } }) => {
|
|
44
|
+
await this.cover?.setWindowCoveringCurrentTargetStatus(liftPercent100thsValue, liftPercent100thsValue, WindowCovering.MovementStatus.Stopped);
|
|
45
|
+
this.cover?.log.info(`Command goToLiftPercentage ${liftPercent100thsValue} called`);
|
|
37
46
|
});
|
|
38
47
|
}
|
|
39
48
|
async onConfigure() {
|
|
40
49
|
this.log.info('onConfigure called');
|
|
41
|
-
|
|
42
|
-
this.cover?.setWindowCoveringTargetAsCurrentAndStopped();
|
|
50
|
+
await this.cover?.setWindowCoveringTargetAsCurrentAndStopped();
|
|
43
51
|
this.log.info('Set cover initial targetPositionLiftPercent100ths = currentPositionLiftPercent100ths and operationalStatus to Stopped.');
|
|
44
|
-
|
|
52
|
+
// Matter: 0 Fully open 10000 fully closed
|
|
53
|
+
this.coverInterval = setInterval(async () => {
|
|
45
54
|
if (!this.cover)
|
|
46
55
|
return;
|
|
47
|
-
|
|
48
|
-
if (
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
coverCluster.setTargetPositionLiftPercent100thsAttribute(position);
|
|
55
|
-
coverCluster.setCurrentPositionLiftPercent100thsAttribute(position);
|
|
56
|
-
coverCluster.setOperationalStatusAttribute({
|
|
57
|
-
global: WindowCovering.MovementStatus.Stopped,
|
|
58
|
-
lift: WindowCovering.MovementStatus.Stopped,
|
|
59
|
-
tilt: WindowCovering.MovementStatus.Stopped,
|
|
60
|
-
});
|
|
61
|
-
this.log.info(`Set liftPercent100thsValue to ${position}`);
|
|
62
|
-
}
|
|
56
|
+
let position = this.cover.getAttribute(WindowCoveringCluster.id, 'currentPositionLiftPercent100ths', this.log);
|
|
57
|
+
if (!isValidNumber(position, 0, 10000))
|
|
58
|
+
return;
|
|
59
|
+
position = position + 1000;
|
|
60
|
+
position = position > 10000 ? 0 : position;
|
|
61
|
+
await this.cover.setWindowCoveringCurrentTargetStatus(position, position, WindowCovering.MovementStatus.Stopped);
|
|
62
|
+
this.log.info(`Set liftPercent100thsValue to ${position}`);
|
|
63
63
|
}, 60 * 1000);
|
|
64
64
|
}
|
|
65
65
|
async onShutdown(reason) {
|
package/dist/platform.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,kBAAkB;AAClB,8CAA8C;AAC9C,6BAA6B,EAC7B,WAAW,EAEX,cAAc,EACd,WAAW,EACX,qBAAqB,GAGtB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD,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;QAEjC,kDAAkD;QAClD,IAAI,IAAI,CAAC,yBAAyB,KAAK,SAAS,IAAI,OAAO,IAAI,CAAC,yBAAyB,KAAK,UAAU,IAAI,CAAC,IAAI,CAAC,yBAAyB,CAAC,OAAO,CAAC,EAAE,CAAC;YACrJ,MAAM,IAAI,KAAK,CACb,yFAAyF,IAAI,CAAC,YAAY,CAAC,mBAAmB,0CAA0C,CACzK,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,wBAAwB,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC5D,CAAC;IAEQ,KAAK,CAAC,OAAO,CAAC,MAAe;QACpC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,6BAA6B,EAAE,MAAM,IAAI,MAAM,CAAC,CAAC;QAE/D,IAAI,CAAC,KAAK,GAAG,IAAI,kBAAkB,CAAC,WAAW,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