@riddix/hamh 2.1.0-alpha.760 → 2.1.0-alpha.762

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/README.md CHANGED
@@ -524,6 +524,7 @@ Newest first.
524
524
 
525
525
  | Contributor | Contributions |
526
526
  |-------------|---------------|
527
+ | [@qbattersby](https://github.com/qbattersby) | 🤖 **Code Contributor** - LevelControl transitionTime patch for matter.js 0.17, so Google Home can dim already-on lights ([#383](https://github.com/RiDDiX/home-assistant-matter-hub/pull/383)) |
527
528
  | [@Yllelder](https://github.com/Yllelder) | 🌐 **Translator** - Spanish translation ([#314](https://github.com/RiDDiX/home-assistant-matter-hub/pull/314)) |
528
529
  | [@MStankiewiczOfficial](https://github.com/MStankiewiczOfficial) | 🌐 **Translator** - Polish translation ([#288](https://github.com/RiDDiX/home-assistant-matter-hub/pull/288), [#329](https://github.com/RiDDiX/home-assistant-matter-hub/pull/329)) |
529
530
  | [@aetasoul](https://github.com/aetasoul) | 🤖 **Code Contributor** - Immediate force sync on startup to beat stale Alexa queues ([#282](https://github.com/RiDDiX/home-assistant-matter-hub/pull/282)) |
@@ -7,8 +7,13 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
7
7
  if (typeof require !== "undefined") return require.apply(this, arguments);
8
8
  throw Error('Dynamic require of "' + x + '" is not supported');
9
9
  });
10
- var __esm = (fn, res) => function __init() {
11
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
+ var __esm = (fn, res, err) => function __init() {
11
+ if (err) throw err[0];
12
+ try {
13
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
14
+ } catch (e) {
15
+ throw err = [e], e;
16
+ }
12
17
  };
13
18
  var __export = (target, all) => {
14
19
  for (var name in all)
@@ -166311,16 +166316,58 @@ init_nodejs();
166311
166316
 
166312
166317
  // src/matter/patches/patch-level-control-tlv.ts
166313
166318
  var logger233 = Logger.get("PatchLevelControlTlv");
166319
+ var optionalFieldModels = /* @__PURE__ */ new WeakSet();
166320
+ var fieldModelMandatoryGetterPatched = false;
166314
166321
  function patchLevelControlTlv() {
166315
166322
  let patched = 0;
166323
+ const patchErrors = [];
166324
+ const markOptional = (field2) => {
166325
+ if (!field2) {
166326
+ return false;
166327
+ }
166328
+ try {
166329
+ if (typeof field2.patch === "function") {
166330
+ field2.patch({ conformance: "O" });
166331
+ }
166332
+ } catch (error) {
166333
+ patchErrors.push(formatPatchError("patch", error));
166334
+ }
166335
+ try {
166336
+ field2.optional = true;
166337
+ } catch (error) {
166338
+ patchErrors.push(formatPatchError("optional", error));
166339
+ }
166340
+ try {
166341
+ Object.defineProperty(field2, "mandatory", {
166342
+ configurable: true,
166343
+ value: false,
166344
+ writable: true
166345
+ });
166346
+ } catch (error) {
166347
+ patchErrors.push(formatPatchError("mandatory", error));
166348
+ }
166349
+ return field2.mandatory === false || forceOptionalViaPrototype(field2);
166350
+ };
166316
166351
  const moveToLevelFields = LevelControl3.MoveToLevelRequest.fieldDefinitions;
166317
- if (moveToLevelFields?.transitionTime) {
166318
- moveToLevelFields.transitionTime.optional = true;
166352
+ if (markOptional(moveToLevelFields?.transitionTime)) {
166319
166353
  patched++;
166320
166354
  }
166321
166355
  const stepFields = LevelControl3.StepRequest.fieldDefinitions;
166322
- if (stepFields?.transitionTime) {
166323
- stepFields.transitionTime.optional = true;
166356
+ if (markOptional(stepFields?.transitionTime)) {
166357
+ patched++;
166358
+ }
166359
+ const moveToLevelSchemaField = findTransitionTimeField(
166360
+ LevelControl3.commands.moveToLevel.schema.children,
166361
+ 1
166362
+ );
166363
+ if (markOptional(moveToLevelSchemaField)) {
166364
+ patched++;
166365
+ }
166366
+ const stepSchemaField = findTransitionTimeField(
166367
+ LevelControl3.commands.step.schema.children,
166368
+ 2
166369
+ );
166370
+ if (markOptional(stepSchemaField)) {
166324
166371
  patched++;
166325
166372
  }
166326
166373
  if (patched > 0) {
@@ -166329,10 +166376,62 @@ function patchLevelControlTlv() {
166329
166376
  );
166330
166377
  } else {
166331
166378
  logger233.warn(
166332
- "Failed to patch LevelControl TLV schemas, field definitions not found. Google Home brightness adjustment may not work."
166379
+ "Failed to patch LevelControl TLV schemas, field definitions not found. Google Home brightness adjustment may not work.",
166380
+ {
166381
+ moveToLevel: describeFields(
166382
+ LevelControl3.commands.moveToLevel.schema.children
166383
+ ),
166384
+ patchErrors,
166385
+ step: describeFields(
166386
+ LevelControl3.commands.step.schema.children
166387
+ )
166388
+ }
166333
166389
  );
166334
166390
  }
166335
166391
  }
166392
+ function findTransitionTimeField(fields, fallbackIndex) {
166393
+ return fields?.find(
166394
+ (field2) => field2.name === "TransitionTime" || field2.propertyName === "transitionTime"
166395
+ ) ?? fields?.[fallbackIndex];
166396
+ }
166397
+ function forceOptionalViaPrototype(field2) {
166398
+ optionalFieldModels.add(field2);
166399
+ if (!fieldModelMandatoryGetterPatched) {
166400
+ let proto = Object.getPrototypeOf(field2);
166401
+ while (proto) {
166402
+ const descriptor = Object.getOwnPropertyDescriptor(proto, "mandatory");
166403
+ if (descriptor?.get && descriptor.configurable) {
166404
+ const original = descriptor.get;
166405
+ Object.defineProperty(proto, "mandatory", {
166406
+ configurable: true,
166407
+ get() {
166408
+ if (optionalFieldModels.has(this)) {
166409
+ return false;
166410
+ }
166411
+ return original.call(this);
166412
+ }
166413
+ });
166414
+ fieldModelMandatoryGetterPatched = true;
166415
+ break;
166416
+ }
166417
+ proto = Object.getPrototypeOf(proto);
166418
+ }
166419
+ }
166420
+ return field2.mandatory === false;
166421
+ }
166422
+ function describeFields(fields) {
166423
+ return fields?.map((field2, index) => ({
166424
+ hasPatch: typeof field2.patch === "function",
166425
+ index,
166426
+ mandatory: field2.mandatory,
166427
+ name: field2.name,
166428
+ optional: field2.optional,
166429
+ propertyName: field2.propertyName
166430
+ }));
166431
+ }
166432
+ function formatPatchError(action, error) {
166433
+ return `${action}:${error instanceof Error ? error.message : String(error)}`;
166434
+ }
166336
166435
 
166337
166436
  // src/commands/start/start-handler.ts
166338
166437
  function extractErrorMessage(error) {