@project-chip/matter-node.js-examples 0.8.2-alpha.0-20240509-f36dbf54 → 0.8.2-alpha.0-20240513-927b1bb5

Sign up to get free protection for your applications and to get access to all the features.
@@ -20,7 +20,7 @@ class RollerShade extends LiftingWindowCoveringServer {
20
20
  this.state.targetPositionLiftPercent100ths = position ?? 0;
21
21
  }
22
22
  async initialize() {
23
- this.reactTo(this.events.targetPositionLiftPercent100ths$Changed, this.writeTargetToMotor, { offline: true });
23
+ this.reactTo(this.events.targetPositionLiftPercent100ths$Changed, this.writeTargetToMotor);
24
24
  await this.readTargetFromMotor();
25
25
  if (this.targetPos === null) {
26
26
  this.targetPos = this.currentPos;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/examples/IlluminatedRollerShade.ts"],
4
- "sourcesContent": ["/**\n * @license\n * Copyright 2022-2024 Matter.js Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\n// Include this first to auto-register Crypto, Network and Time Node.js implementations\nimport \"@project-chip/matter-node.js\";\n\nimport { GoToLiftPercentageRequest, WindowCoveringServer } from \"@project-chip/matter.js/behaviors/window-covering\";\nimport { OnOffLightDevice, OnOffLightRequirements } from \"@project-chip/matter.js/devices/OnOffLightDevice\";\nimport { WindowCoveringDevice } from \"@project-chip/matter.js/devices/WindowCoveringDevice\";\nimport { ServerNode } from \"@project-chip/matter.js/node\";\n\n/**\n * This example demonstrates implementation of a \"composed\" device comprising multiple sub-devices\n *\n * Our example device, the Excelsior 1000 EZ-Nite\u2122, is a roller shade with an illuminated valance.\n */\n\nconst LiftingWindowCoveringServer = WindowCoveringServer.with(\"Lift\", \"AbsolutePosition\", \"PositionAwareLift\");\n\n/**\n * Implementation of the Matter WindowCovering cluster for the shade motor.\n *\n * TODO - some of this should probably move to WindowCoveringServer\n */\nclass RollerShade extends LiftingWindowCoveringServer {\n get currentPos() {\n return this.state.currentPositionLiftPercent100ths ?? 0;\n }\n\n get targetPos() {\n return this.state.targetPositionLiftPercent100ths ?? 0;\n }\n\n set targetPos(position: number) {\n this.state.targetPositionLiftPercent100ths = position ?? 0;\n }\n\n override async initialize() {\n this.reactTo(this.events.targetPositionLiftPercent100ths$Changed, this.writeTargetToMotor, { offline: true });\n\n await this.readTargetFromMotor();\n if (this.targetPos === null) {\n this.targetPos = this.currentPos;\n }\n }\n\n override upOrOpen() {\n // 0 = 0%, fully open\n this.targetPos = 0;\n }\n\n override downOrClose() {\n // 10000 = 100%, fully closed\n this.targetPos = 10000;\n }\n\n override stopMotion() {\n this.targetPos = this.currentPos;\n }\n\n override goToLiftPercentage(this: RollerShade, request: GoToLiftPercentageRequest) {\n this.targetPos = request.liftPercent100thsValue;\n }\n\n protected async writeTargetToMotor() {\n // For this contrived example we just log the target position and don't actually animate our fake roller shade\n console.log(\"Window covering target position is now\", `${this.targetPos / 100}%`);\n }\n\n protected async readTargetFromMotor() {\n // Our fake shade is stuck open\n this.state.currentPositionLiftPercent100ths = 0;\n }\n\n protected set currentPos(value: number) {\n this.state.currentPositionLiftPercent100ths = value;\n }\n}\n\n/**\n * Implementation of the OnOff cluster for our valance light.\n */\nclass ValanceLight extends OnOffLightRequirements.OnOffServer {\n override initialize() {\n this.reactTo(this.events.onOff$Changed, this.#stateChanged);\n }\n\n #stateChanged(value: boolean) {\n console.log(`Valance is now ${value ? \"illuminated\" : \"dark\"}`);\n }\n}\n\n/**\n * Our Matter node.\n */\nconst node = new ServerNode({\n id: \"excelsior1000\",\n\n productDescription: {},\n\n commissioning: {\n passcode: 20202021,\n discriminator: 3840,\n },\n\n basicInformation: {\n vendorName: \"Acme Corporation\",\n productName: \"Excelsior 1000 EZ-Nite\u2122\",\n vendorId: 0xfff1,\n productId: 0x8000,\n serialNumber: \"1234-12345-123\",\n },\n\n parts: [\n {\n type: WindowCoveringDevice.with(RollerShade),\n id: \"shade\",\n },\n\n {\n type: OnOffLightDevice.with(ValanceLight),\n id: \"valance\",\n },\n ],\n});\n\nawait node.run();\n"],
5
- "mappings": "AAAA;AAAA;AAAA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AC1B,YAAQ,IAAI,kBAAkB,QAAQ,gBAAgB,MAAM,EAAE;AAAA,EAClE;AACJ;AAKA,MAAM,OAAO,IAAI,WAAW;AAAA,EACxB,IAAI;AAAA,EAEJ,oBAAoB,CAAC;AAAA,EAErB,eAAe;AAAA,IACX,UAAU;AAAA,IACV,eAAe;AAAA,EACnB;AAAA,EAEA,kBAAkB;AAAA,IACd,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,UAAU;AAAA,IACV,WAAW;AAAA,IACX,cAAc;AAAA,EAClB;AAAA,EAEA,OAAO;AAAA,IACH;AAAA,MACI,MAAM,qBAAqB,KAAK,WAAW;AAAA,MAC3C,IAAI;AAAA,IACR;AAAA,IAEA;AAAA,MACI,MAAM,iBAAiB,KAAK,YAAY;AAAA,MACxC,IAAI;AAAA,IACR;AAAA,EACJ;AACJ,CAAC;AAED,MAAM,KAAK,IAAI;",
4
+ "sourcesContent": ["/**\n * @license\n * Copyright 2022-2024 Matter.js Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\n// Include this first to auto-register Crypto, Network and Time Node.js implementations\nimport \"@project-chip/matter-node.js\";\n\nimport { GoToLiftPercentageRequest, WindowCoveringServer } from \"@project-chip/matter.js/behaviors/window-covering\";\nimport { OnOffLightDevice, OnOffLightRequirements } from \"@project-chip/matter.js/devices/OnOffLightDevice\";\nimport { WindowCoveringDevice } from \"@project-chip/matter.js/devices/WindowCoveringDevice\";\nimport { ServerNode } from \"@project-chip/matter.js/node\";\n\n/**\n * This example demonstrates implementation of a \"composed\" device comprising multiple sub-devices\n *\n * Our example device, the Excelsior 1000 EZ-Nite\u2122, is a roller shade with an illuminated valance.\n */\n\nconst LiftingWindowCoveringServer = WindowCoveringServer.with(\"Lift\", \"AbsolutePosition\", \"PositionAwareLift\");\n\n/**\n * Implementation of the Matter WindowCovering cluster for the shade motor.\n *\n * TODO - some of this should probably move to WindowCoveringServer\n */\nclass RollerShade extends LiftingWindowCoveringServer {\n get currentPos() {\n return this.state.currentPositionLiftPercent100ths ?? 0;\n }\n\n get targetPos() {\n return this.state.targetPositionLiftPercent100ths ?? 0;\n }\n\n set targetPos(position: number) {\n this.state.targetPositionLiftPercent100ths = position ?? 0;\n }\n\n override async initialize() {\n this.reactTo(this.events.targetPositionLiftPercent100ths$Changed, this.writeTargetToMotor);\n\n await this.readTargetFromMotor();\n if (this.targetPos === null) {\n this.targetPos = this.currentPos;\n }\n }\n\n override upOrOpen() {\n // 0 = 0%, fully open\n this.targetPos = 0;\n }\n\n override downOrClose() {\n // 10000 = 100%, fully closed\n this.targetPos = 10000;\n }\n\n override stopMotion() {\n this.targetPos = this.currentPos;\n }\n\n override goToLiftPercentage(this: RollerShade, request: GoToLiftPercentageRequest) {\n this.targetPos = request.liftPercent100thsValue;\n }\n\n protected async writeTargetToMotor() {\n // For this contrived example we just log the target position and don't actually animate our fake roller shade\n console.log(\"Window covering target position is now\", `${this.targetPos / 100}%`);\n }\n\n protected async readTargetFromMotor() {\n // Our fake shade is stuck open\n this.state.currentPositionLiftPercent100ths = 0;\n }\n\n protected set currentPos(value: number) {\n this.state.currentPositionLiftPercent100ths = value;\n }\n}\n\n/**\n * Implementation of the OnOff cluster for our valance light.\n */\nclass ValanceLight extends OnOffLightRequirements.OnOffServer {\n override initialize() {\n this.reactTo(this.events.onOff$Changed, this.#stateChanged);\n }\n\n #stateChanged(value: boolean) {\n console.log(`Valance is now ${value ? \"illuminated\" : \"dark\"}`);\n }\n}\n\n/**\n * Our Matter node.\n */\nconst node = new ServerNode({\n id: \"excelsior1000\",\n\n productDescription: {},\n\n commissioning: {\n passcode: 20202021,\n discriminator: 3840,\n },\n\n basicInformation: {\n vendorName: \"Acme Corporation\",\n productName: \"Excelsior 1000 EZ-Nite\u2122\",\n vendorId: 0xfff1,\n productId: 0x8000,\n serialNumber: \"1234-12345-123\",\n },\n\n parts: [\n {\n type: WindowCoveringDevice.with(RollerShade),\n id: \"shade\",\n },\n\n {\n type: OnOffLightDevice.with(ValanceLight),\n id: \"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AAAA,EAC9D;AAAA,EAEA,cAAc,OAAgB;AAC1B,YAAQ,IAAI,kBAAkB,QAAQ,gBAAgB,MAAM,EAAE;AAAA,EAClE;AACJ;AAKA,MAAM,OAAO,IAAI,WAAW;AAAA,EACxB,IAAI;AAAA,EAEJ,oBAAoB,CAAC;AAAA,EAErB,eAAe;AAAA,IACX,UAAU;AAAA,IACV,eAAe;AAAA,EACnB;AAAA,EAEA,kBAAkB;AAAA,IACd,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,UAAU;AAAA,IACV,WAAW;AAAA,IACX,cAAc;AAAA,EAClB;AAAA,EAEA,OAAO;AAAA,IACH;AAAA,MACI,MAAM,qBAAqB,KAAK,WAAW;AAAA,MAC3C,IAAI;AAAA,IACR;AAAA,IAEA;AAAA,MACI,MAAM,iBAAiB,KAAK,YAAY;AAAA,MACxC,IAAI;AAAA,IACR;AAAA,EACJ;AACJ,CAAC;AAED,MAAM,KAAK,IAAI;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@project-chip/matter-node.js-examples",
3
- "version": "0.8.2-alpha.0-20240509-f36dbf54",
3
+ "version": "0.8.2-alpha.0-20240513-927b1bb5",
4
4
  "description": "CLI/Reference implementation scripts for Matter protocol for node.js",
5
5
  "keywords": [
6
6
  "iot",
@@ -64,10 +64,10 @@
64
64
  "typescript": "~5.4.5"
65
65
  },
66
66
  "dependencies": {
67
- "@project-chip/matter-node-ble.js": "0.8.2-alpha.0-20240509-f36dbf54",
68
- "@project-chip/matter-node.js": "0.8.2-alpha.0-20240509-f36dbf54",
69
- "@project-chip/matter.js": "0.8.2-alpha.0-20240509-f36dbf54",
70
- "@project-chip/matter.js-tools": "0.8.2-alpha.0-20240509-f36dbf54"
67
+ "@project-chip/matter-node-ble.js": "0.8.2-alpha.0-20240513-927b1bb5",
68
+ "@project-chip/matter-node.js": "0.8.2-alpha.0-20240513-927b1bb5",
69
+ "@project-chip/matter.js": "0.8.2-alpha.0-20240513-927b1bb5",
70
+ "@project-chip/matter.js-tools": "0.8.2-alpha.0-20240513-927b1bb5"
71
71
  },
72
72
  "engines": {
73
73
  "_comment": "For Crypto.hkdf support",
@@ -83,5 +83,5 @@
83
83
  "publishConfig": {
84
84
  "access": "public"
85
85
  },
86
- "gitHead": "a03755628533e8d316256add3b80252bb2eacf6b"
86
+ "gitHead": "b926ad590e20314be4e761c2c9916f39ca6b5d9c"
87
87
  }
@@ -39,7 +39,7 @@ class RollerShade extends LiftingWindowCoveringServer {
39
39
  }
40
40
 
41
41
  override async initialize() {
42
- this.reactTo(this.events.targetPositionLiftPercent100ths$Changed, this.writeTargetToMotor, { offline: true });
42
+ this.reactTo(this.events.targetPositionLiftPercent100ths$Changed, this.writeTargetToMotor);
43
43
 
44
44
  await this.readTargetFromMotor();
45
45
  if (this.targetPos === null) {