@riddix/hamh 2.1.0-alpha.519 → 2.1.0-alpha.521

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.
@@ -167128,9 +167128,11 @@ ${e?.toString()}`);
167128
167128
  for (const s of [...sessionManager.sessions]) {
167129
167129
  if (s.id === sessionId && !s.isClosing && s.subscriptions.size === 0) {
167130
167130
  this.log.warn(
167131
- `Force-closing stale session ${s.id} (peer ${s.peerNodeId}, no subscriptions for ${DEAD_SESSION_TIMEOUT_MS / 1e3}s)`
167131
+ `Closing stale session ${s.id} (peer ${s.peerNodeId}, no subscriptions for ${DEAD_SESSION_TIMEOUT_MS / 1e3}s)`
167132
167132
  );
167133
- s.initiateForceClose().catch(() => {
167133
+ s.initiateClose().catch(() => {
167134
+ s.initiateForceClose().catch(() => {
167135
+ });
167134
167136
  });
167135
167137
  break;
167136
167138
  }
@@ -167145,9 +167147,11 @@ ${e?.toString()}`);
167145
167147
  for (const s of sessions) {
167146
167148
  if (!s.isClosing && s.subscriptions.size === 0) {
167147
167149
  this.log.warn(
167148
- `Force-closing dead session ${s.id} (peer ${s.peerNodeId}, no subscriptions for ${DEAD_SESSION_TIMEOUT_MS / 1e3}s)`
167150
+ `Closing dead session ${s.id} (peer ${s.peerNodeId}, no subscriptions for ${DEAD_SESSION_TIMEOUT_MS / 1e3}s)`
167149
167151
  );
167150
- s.initiateForceClose().catch(() => {
167152
+ s.initiateClose().catch(() => {
167153
+ s.initiateForceClose().catch(() => {
167154
+ });
167151
167155
  });
167152
167156
  }
167153
167157
  }
@@ -171008,6 +171012,22 @@ var WindowCoveringServerBase = class _WindowCoveringServerBase extends FeaturedB
171008
171012
  );
171009
171013
  const currentTilt100ths = currentTilt != null ? currentTilt * 100 : null;
171010
171014
  const isStopped = movementStatus === MovementStatus.Stopped;
171015
+ const inferTarget = (current100ths, existing100ths) => {
171016
+ if (isStopped) return current100ths;
171017
+ if (movementStatus === MovementStatus.Opening) {
171018
+ if (existing100ths != null && current100ths != null && existing100ths < current100ths) {
171019
+ return existing100ths;
171020
+ }
171021
+ return 0;
171022
+ }
171023
+ if (movementStatus === MovementStatus.Closing) {
171024
+ if (existing100ths != null && current100ths != null && existing100ths > current100ths) {
171025
+ return existing100ths;
171026
+ }
171027
+ return 1e4;
171028
+ }
171029
+ return existing100ths ?? current100ths;
171030
+ };
171011
171031
  logger175.debug(
171012
171032
  `Cover update for ${entity.entity_id}: state=${state.state}, lift=${currentLift}%, tilt=${currentTilt}%, movement=${MovementStatus[movementStatus]}`
171013
171033
  );
@@ -171034,14 +171054,18 @@ var WindowCoveringServerBase = class _WindowCoveringServerBase extends FeaturedB
171034
171054
  ...this.features.positionAwareLift ? {
171035
171055
  currentPositionLiftPercentage: currentLift,
171036
171056
  currentPositionLiftPercent100ths: currentLift100ths,
171037
- // When stopped, target MUST equal current for controllers to show correct state
171038
- targetPositionLiftPercent100ths: isStopped ? currentLift100ths : this.state.targetPositionLiftPercent100ths ?? currentLift100ths
171057
+ targetPositionLiftPercent100ths: inferTarget(
171058
+ currentLift100ths,
171059
+ this.state.targetPositionLiftPercent100ths
171060
+ )
171039
171061
  } : {},
171040
171062
  ...this.features.positionAwareTilt ? {
171041
171063
  currentPositionTiltPercentage: currentTilt,
171042
171064
  currentPositionTiltPercent100ths: currentTilt100ths,
171043
- // When stopped, target MUST equal current for controllers to show correct state
171044
- targetPositionTiltPercent100ths: isStopped ? currentTilt100ths : this.state.targetPositionTiltPercent100ths ?? currentTilt100ths
171065
+ targetPositionTiltPercent100ths: inferTarget(
171066
+ currentTilt100ths,
171067
+ this.state.targetPositionTiltPercent100ths
171068
+ )
171045
171069
  } : {}
171046
171070
  }
171047
171071
  );
@@ -179839,9 +179863,11 @@ ${e?.toString()}`);
179839
179863
  for (const s of [...sessionManager.sessions]) {
179840
179864
  if (s.id === sessionId && !s.isClosing && s.subscriptions.size === 0) {
179841
179865
  this.log.warn(
179842
- `Force-closing stale session ${s.id} (peer ${s.peerNodeId}, no subscriptions for ${DEAD_SESSION_TIMEOUT_MS2 / 1e3}s)`
179866
+ `Closing stale session ${s.id} (peer ${s.peerNodeId}, no subscriptions for ${DEAD_SESSION_TIMEOUT_MS2 / 1e3}s)`
179843
179867
  );
179844
- s.initiateForceClose().catch(() => {
179868
+ s.initiateClose().catch(() => {
179869
+ s.initiateForceClose().catch(() => {
179870
+ });
179845
179871
  });
179846
179872
  break;
179847
179873
  }
@@ -179856,9 +179882,11 @@ ${e?.toString()}`);
179856
179882
  for (const s of sessions) {
179857
179883
  if (!s.isClosing && s.subscriptions.size === 0) {
179858
179884
  this.log.warn(
179859
- `Force-closing dead session ${s.id} (peer ${s.peerNodeId}, no subscriptions for ${DEAD_SESSION_TIMEOUT_MS2 / 1e3}s)`
179885
+ `Closing dead session ${s.id} (peer ${s.peerNodeId}, no subscriptions for ${DEAD_SESSION_TIMEOUT_MS2 / 1e3}s)`
179860
179886
  );
179861
- s.initiateForceClose().catch(() => {
179887
+ s.initiateClose().catch(() => {
179888
+ s.initiateForceClose().catch(() => {
179889
+ });
179862
179890
  });
179863
179891
  }
179864
179892
  }