@riddix/hamh 2.1.0-alpha.808 → 2.1.0-alpha.810
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
|
@@ -154537,19 +154537,27 @@ var FeaturedBase6 = WindowCoveringServer.with(
|
|
|
154537
154537
|
"Tilt",
|
|
154538
154538
|
"PositionAwareTilt"
|
|
154539
154539
|
);
|
|
154540
|
+
var coverDebounce = /* @__PURE__ */ new WeakMap();
|
|
154541
|
+
function getCoverDebounce(endpoint) {
|
|
154542
|
+
let st = coverDebounce.get(endpoint);
|
|
154543
|
+
if (!st) {
|
|
154544
|
+
st = {
|
|
154545
|
+
liftTimer: null,
|
|
154546
|
+
tiltTimer: null,
|
|
154547
|
+
pendingLift: null,
|
|
154548
|
+
pendingTilt: null,
|
|
154549
|
+
lastLiftCommandTime: 0,
|
|
154550
|
+
lastTiltCommandTime: 0
|
|
154551
|
+
};
|
|
154552
|
+
coverDebounce.set(endpoint, st);
|
|
154553
|
+
}
|
|
154554
|
+
return st;
|
|
154555
|
+
}
|
|
154540
154556
|
var WindowCoveringServerBase = class _WindowCoveringServerBase extends FeaturedBase6 {
|
|
154541
|
-
|
|
154542
|
-
|
|
154543
|
-
// Track when the last command was received to implement two-phase debounce
|
|
154544
|
-
lastLiftCommandTime = 0;
|
|
154545
|
-
lastTiltCommandTime = 0;
|
|
154546
|
-
// Track lift direction to skip redundant tilt on downOrClose / upOrOpen (#246)
|
|
154557
|
+
// Written and read within one synchronous command (upOrOpen fires lift then
|
|
154558
|
+
// tilt on the same instance), so these stay as instance fields (#246).
|
|
154547
154559
|
lastLiftMovementMs = 0;
|
|
154548
154560
|
lastLiftMovementDirection = null;
|
|
154549
|
-
// Store everything needed for debounced HA calls - entityId and actions service
|
|
154550
|
-
// must be captured before setTimeout because agent context expires after command handler
|
|
154551
|
-
pendingLiftAction = null;
|
|
154552
|
-
pendingTiltAction = null;
|
|
154553
154561
|
// Two-phase debounce: longer for first command (quick swipe sends initial step value),
|
|
154554
154562
|
// shorter for subsequent commands during drag
|
|
154555
154563
|
static DEBOUNCE_INITIAL_MS = 400;
|
|
@@ -154568,16 +154576,18 @@ var WindowCoveringServerBase = class _WindowCoveringServerBase extends FeaturedB
|
|
|
154568
154576
|
return null;
|
|
154569
154577
|
}
|
|
154570
154578
|
async [Symbol.asyncDispose]() {
|
|
154571
|
-
|
|
154572
|
-
|
|
154573
|
-
|
|
154574
|
-
|
|
154575
|
-
|
|
154576
|
-
|
|
154577
|
-
|
|
154579
|
+
const st = coverDebounce.get(this.endpoint);
|
|
154580
|
+
if (st) {
|
|
154581
|
+
if (st.liftTimer) {
|
|
154582
|
+
clearTimeout(st.liftTimer);
|
|
154583
|
+
}
|
|
154584
|
+
if (st.tiltTimer) {
|
|
154585
|
+
clearTimeout(st.tiltTimer);
|
|
154586
|
+
}
|
|
154587
|
+
st.pendingLift = null;
|
|
154588
|
+
st.pendingTilt = null;
|
|
154589
|
+
coverDebounce.delete(this.endpoint);
|
|
154578
154590
|
}
|
|
154579
|
-
this.pendingLiftAction = null;
|
|
154580
|
-
this.pendingTiltAction = null;
|
|
154581
154591
|
await super[Symbol.asyncDispose]();
|
|
154582
154592
|
}
|
|
154583
154593
|
async initialize() {
|
|
@@ -154767,28 +154777,29 @@ var WindowCoveringServerBase = class _WindowCoveringServerBase extends FeaturedB
|
|
|
154767
154777
|
const action = config11.setLiftPosition(targetPosition, this.agent);
|
|
154768
154778
|
const entityId = homeAssistant.entityId;
|
|
154769
154779
|
const actions = this.env.get(HomeAssistantActions);
|
|
154770
|
-
|
|
154780
|
+
const st = getCoverDebounce(this.endpoint);
|
|
154781
|
+
st.pendingLift = { action, entityId, actions };
|
|
154771
154782
|
const now = Date.now();
|
|
154772
|
-
const timeSinceLastCommand = now -
|
|
154773
|
-
|
|
154783
|
+
const timeSinceLastCommand = now - st.lastLiftCommandTime;
|
|
154784
|
+
st.lastLiftCommandTime = now;
|
|
154774
154785
|
const isFirstInSequence = timeSinceLastCommand > _WindowCoveringServerBase.COMMAND_SEQUENCE_THRESHOLD_MS;
|
|
154775
154786
|
const overrideMs = this.resolveDebounceOverride(homeAssistant);
|
|
154776
154787
|
const debounceMs = overrideMs != null ? overrideMs : isFirstInSequence ? _WindowCoveringServerBase.DEBOUNCE_INITIAL_MS : _WindowCoveringServerBase.DEBOUNCE_SUBSEQUENT_MS;
|
|
154777
154788
|
logger206.debug(
|
|
154778
154789
|
`Lift command: target=${targetPosition}%, debounce=${debounceMs}ms (${overrideMs != null ? "override" : isFirstInSequence ? "initial" : "subsequent"})`
|
|
154779
154790
|
);
|
|
154780
|
-
if (
|
|
154781
|
-
clearTimeout(
|
|
154791
|
+
if (st.liftTimer) {
|
|
154792
|
+
clearTimeout(st.liftTimer);
|
|
154782
154793
|
}
|
|
154783
|
-
|
|
154784
|
-
|
|
154785
|
-
if (
|
|
154794
|
+
st.liftTimer = setTimeout(() => {
|
|
154795
|
+
st.liftTimer = null;
|
|
154796
|
+
if (st.pendingLift) {
|
|
154786
154797
|
const {
|
|
154787
154798
|
action: pendingAction,
|
|
154788
154799
|
entityId: eid,
|
|
154789
154800
|
actions: act
|
|
154790
|
-
} =
|
|
154791
|
-
|
|
154801
|
+
} = st.pendingLift;
|
|
154802
|
+
st.pendingLift = null;
|
|
154792
154803
|
act.call(pendingAction, eid);
|
|
154793
154804
|
}
|
|
154794
154805
|
}, debounceMs);
|
|
@@ -154817,28 +154828,29 @@ var WindowCoveringServerBase = class _WindowCoveringServerBase extends FeaturedB
|
|
|
154817
154828
|
const action = config11.setTiltPosition(targetPosition, this.agent);
|
|
154818
154829
|
const entityId = homeAssistant.entityId;
|
|
154819
154830
|
const actions = this.env.get(HomeAssistantActions);
|
|
154820
|
-
|
|
154831
|
+
const st = getCoverDebounce(this.endpoint);
|
|
154832
|
+
st.pendingTilt = { action, entityId, actions };
|
|
154821
154833
|
const now = Date.now();
|
|
154822
|
-
const timeSinceLastCommand = now -
|
|
154823
|
-
|
|
154834
|
+
const timeSinceLastCommand = now - st.lastTiltCommandTime;
|
|
154835
|
+
st.lastTiltCommandTime = now;
|
|
154824
154836
|
const isFirstInSequence = timeSinceLastCommand > _WindowCoveringServerBase.COMMAND_SEQUENCE_THRESHOLD_MS;
|
|
154825
154837
|
const overrideMs = this.resolveDebounceOverride(homeAssistant);
|
|
154826
154838
|
const debounceMs = overrideMs != null ? overrideMs : isFirstInSequence ? _WindowCoveringServerBase.DEBOUNCE_INITIAL_MS : _WindowCoveringServerBase.DEBOUNCE_SUBSEQUENT_MS;
|
|
154827
154839
|
logger206.debug(
|
|
154828
154840
|
`Tilt command: target=${targetPosition}%, debounce=${debounceMs}ms (${overrideMs != null ? "override" : isFirstInSequence ? "initial" : "subsequent"})`
|
|
154829
154841
|
);
|
|
154830
|
-
if (
|
|
154831
|
-
clearTimeout(
|
|
154842
|
+
if (st.tiltTimer) {
|
|
154843
|
+
clearTimeout(st.tiltTimer);
|
|
154832
154844
|
}
|
|
154833
|
-
|
|
154834
|
-
|
|
154835
|
-
if (
|
|
154845
|
+
st.tiltTimer = setTimeout(() => {
|
|
154846
|
+
st.tiltTimer = null;
|
|
154847
|
+
if (st.pendingTilt) {
|
|
154836
154848
|
const {
|
|
154837
154849
|
action: pendingAction,
|
|
154838
154850
|
entityId: eid,
|
|
154839
154851
|
actions: act
|
|
154840
|
-
} =
|
|
154841
|
-
|
|
154852
|
+
} = st.pendingTilt;
|
|
154853
|
+
st.pendingTilt = null;
|
|
154842
154854
|
act.call(pendingAction, eid);
|
|
154843
154855
|
}
|
|
154844
154856
|
}, debounceMs);
|