@riddix/hamh 2.1.0-alpha.671 → 2.1.0-alpha.673
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/backend/cli.js
CHANGED
|
@@ -172325,6 +172325,18 @@ var WindowCoveringServerBase = class _WindowCoveringServerBase extends FeaturedB
|
|
|
172325
172325
|
static DEBOUNCE_INITIAL_MS = 400;
|
|
172326
172326
|
static DEBOUNCE_SUBSEQUENT_MS = 150;
|
|
172327
172327
|
static COMMAND_SEQUENCE_THRESHOLD_MS = 600;
|
|
172328
|
+
// Apple's HomeKit only forwards one attribute per multi-attribute Matter
|
|
172329
|
+
// report — target goes out in its own transaction (#328).
|
|
172330
|
+
deferredTargetTimer = null;
|
|
172331
|
+
deferredTargetLift = void 0;
|
|
172332
|
+
deferredTargetTilt = void 0;
|
|
172333
|
+
deferredTargetEntityId = null;
|
|
172334
|
+
// Must clear matter.js's 50ms subscription send window.
|
|
172335
|
+
static DEFERRED_TARGET_DELAY_MS = 100;
|
|
172336
|
+
// Hold back current updates for a short window after motion starts so
|
|
172337
|
+
// state and target reach Apple Home before any position update (#328).
|
|
172338
|
+
motionStartedAt = 0;
|
|
172339
|
+
static MOTION_START_CURRENT_GUARD_MS = 250;
|
|
172328
172340
|
// Per-entity override wins over per-bridge flag; both must be > 0 to count.
|
|
172329
172341
|
resolveDebounceOverride(homeAssistant) {
|
|
172330
172342
|
const fromEntity = homeAssistant.state.mapping?.coverSliderDebounceMs;
|
|
@@ -172346,8 +172358,16 @@ var WindowCoveringServerBase = class _WindowCoveringServerBase extends FeaturedB
|
|
|
172346
172358
|
clearTimeout(this.tiltDebounceTimer);
|
|
172347
172359
|
this.tiltDebounceTimer = null;
|
|
172348
172360
|
}
|
|
172361
|
+
if (this.deferredTargetTimer) {
|
|
172362
|
+
clearTimeout(this.deferredTargetTimer);
|
|
172363
|
+
this.deferredTargetTimer = null;
|
|
172364
|
+
}
|
|
172349
172365
|
this.pendingLiftAction = null;
|
|
172350
172366
|
this.pendingTiltAction = null;
|
|
172367
|
+
this.deferredTargetLift = void 0;
|
|
172368
|
+
this.deferredTargetTilt = void 0;
|
|
172369
|
+
this.deferredTargetEntityId = null;
|
|
172370
|
+
this.motionStartedAt = 0;
|
|
172351
172371
|
await super[Symbol.asyncDispose]();
|
|
172352
172372
|
}
|
|
172353
172373
|
async initialize() {
|
|
@@ -172421,40 +172441,83 @@ var WindowCoveringServerBase = class _WindowCoveringServerBase extends FeaturedB
|
|
|
172421
172441
|
const overrideEndProduct = config10.getEndProductType?.(state, this.agent);
|
|
172422
172442
|
const previousStatus = this.state.operationalStatus?.global;
|
|
172423
172443
|
const startedMoving = !isStopped && previousStatus === MovementStatus.Stopped;
|
|
172444
|
+
if (startedMoving) {
|
|
172445
|
+
this.motionStartedAt = Date.now();
|
|
172446
|
+
} else if (isStopped) {
|
|
172447
|
+
this.motionStartedAt = 0;
|
|
172448
|
+
}
|
|
172449
|
+
const inMotionStartGuard = !isStopped && this.motionStartedAt > 0 && Date.now() - this.motionStartedAt < _WindowCoveringServerBase.MOTION_START_CURRENT_GUARD_MS;
|
|
172450
|
+
const skipCurrent = startedMoving || inMotionStartGuard;
|
|
172451
|
+
const liftTarget100ths = this.features.positionAwareLift ? inferTarget(
|
|
172452
|
+
currentLift100ths,
|
|
172453
|
+
this.state.targetPositionLiftPercent100ths
|
|
172454
|
+
) : void 0;
|
|
172455
|
+
const tiltTarget100ths = this.features.positionAwareTilt ? inferTarget(
|
|
172456
|
+
currentTilt100ths,
|
|
172457
|
+
this.state.targetPositionTiltPercent100ths
|
|
172458
|
+
) : void 0;
|
|
172424
172459
|
const appliedPatch = applyPatchState(
|
|
172425
172460
|
this.state,
|
|
172426
172461
|
{
|
|
172427
172462
|
type: overrideType ?? (this.features.lift && this.features.tilt ? WindowCovering3.WindowCoveringType.TiltBlindLift : this.features.tilt ? WindowCovering3.WindowCoveringType.TiltBlindTiltOnly : WindowCovering3.WindowCoveringType.Rollershade),
|
|
172428
172463
|
endProductType: overrideEndProduct ?? (this.features.lift && this.features.tilt ? WindowCovering3.EndProductType.SheerShade : this.features.tilt ? WindowCovering3.EndProductType.TiltOnlyInteriorBlind : WindowCovering3.EndProductType.RollerShade),
|
|
172429
|
-
// Target before operationalStatus so the wire order matches the
|
|
172430
|
-
// certified Eve MotionBlinds (state, target, current). Patch insertion
|
|
172431
|
-
// order propagates into matter.js's changeList via for-in over values
|
|
172432
|
-
// (Datasource.js:414), then through attrsChanged.emit (#328).
|
|
172433
|
-
...this.features.positionAwareLift ? {
|
|
172434
|
-
targetPositionLiftPercent100ths: inferTarget(
|
|
172435
|
-
currentLift100ths,
|
|
172436
|
-
this.state.targetPositionLiftPercent100ths
|
|
172437
|
-
)
|
|
172438
|
-
} : {},
|
|
172439
|
-
...this.features.positionAwareTilt ? {
|
|
172440
|
-
targetPositionTiltPercent100ths: inferTarget(
|
|
172441
|
-
currentTilt100ths,
|
|
172442
|
-
this.state.targetPositionTiltPercent100ths
|
|
172443
|
-
)
|
|
172444
|
-
} : {},
|
|
172445
172464
|
operationalStatus: {
|
|
172446
172465
|
global: movementStatus,
|
|
172447
172466
|
...this.features.lift ? { lift: movementStatus } : {},
|
|
172448
172467
|
...this.features.tilt ? { tilt: movementStatus } : {}
|
|
172449
172468
|
},
|
|
172450
|
-
...this.features.positionAwareLift && !
|
|
172469
|
+
...this.features.positionAwareLift && !skipCurrent ? {
|
|
172451
172470
|
currentPositionLiftPercent100ths: currentLift100ths
|
|
172452
172471
|
} : {},
|
|
172453
|
-
...this.features.positionAwareTilt && !
|
|
172472
|
+
...this.features.positionAwareTilt && !skipCurrent ? {
|
|
172454
172473
|
currentPositionTiltPercent100ths: currentTilt100ths
|
|
172455
172474
|
} : {}
|
|
172456
172475
|
}
|
|
172457
172476
|
);
|
|
172477
|
+
const endpoint = this.endpoint;
|
|
172478
|
+
this.deferredTargetLift = liftTarget100ths;
|
|
172479
|
+
this.deferredTargetTilt = tiltTarget100ths;
|
|
172480
|
+
this.deferredTargetEntityId = entity.entity_id;
|
|
172481
|
+
if (this.deferredTargetTimer) {
|
|
172482
|
+
clearTimeout(this.deferredTargetTimer);
|
|
172483
|
+
}
|
|
172484
|
+
this.deferredTargetTimer = setTimeout(() => {
|
|
172485
|
+
this.deferredTargetTimer = null;
|
|
172486
|
+
const lift = this.deferredTargetLift;
|
|
172487
|
+
const tilt = this.deferredTargetTilt;
|
|
172488
|
+
const eid = this.deferredTargetEntityId;
|
|
172489
|
+
this.deferredTargetLift = void 0;
|
|
172490
|
+
this.deferredTargetTilt = void 0;
|
|
172491
|
+
this.deferredTargetEntityId = null;
|
|
172492
|
+
if (lift === void 0 && tilt === void 0) {
|
|
172493
|
+
return;
|
|
172494
|
+
}
|
|
172495
|
+
Promise.resolve(
|
|
172496
|
+
endpoint.act((agent) => {
|
|
172497
|
+
const beh = agent.get(_WindowCoveringServerBase);
|
|
172498
|
+
const written = {};
|
|
172499
|
+
if (lift !== void 0 && beh.features.positionAwareLift) {
|
|
172500
|
+
beh.state.targetPositionLiftPercent100ths = lift;
|
|
172501
|
+
written.targetPositionLiftPercent100ths = lift;
|
|
172502
|
+
}
|
|
172503
|
+
if (tilt !== void 0 && beh.features.positionAwareTilt) {
|
|
172504
|
+
beh.state.targetPositionTiltPercent100ths = tilt;
|
|
172505
|
+
written.targetPositionTiltPercent100ths = tilt;
|
|
172506
|
+
}
|
|
172507
|
+
if (Object.keys(written).length > 0) {
|
|
172508
|
+
logger179.debug(
|
|
172509
|
+
`Cover ${eid ?? "?"} deferred target: ${JSON.stringify(written)}`
|
|
172510
|
+
);
|
|
172511
|
+
}
|
|
172512
|
+
})
|
|
172513
|
+
).catch((e) => {
|
|
172514
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
172515
|
+
if (msg.includes("Endpoint storage inaccessible") || msg.includes("destroyed")) {
|
|
172516
|
+
return;
|
|
172517
|
+
}
|
|
172518
|
+
logger179.debug(`Cover ${eid ?? "?"} deferred target failed: ${msg}`);
|
|
172519
|
+
});
|
|
172520
|
+
}, _WindowCoveringServerBase.DEFERRED_TARGET_DELAY_MS);
|
|
172458
172521
|
if (Object.keys(appliedPatch).length > 0) {
|
|
172459
172522
|
const hasOperationalChange = "operationalStatus" in appliedPatch;
|
|
172460
172523
|
const log = hasOperationalChange ? logger179.info : logger179.debug;
|