@riddix/hamh 2.1.0-alpha.488 → 2.1.0-alpha.489

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.
@@ -177776,6 +177776,7 @@ var LegacyEndpoint = class _LegacyEndpoint extends EntityEndpoint {
177776
177776
  this.flushUpdate = debounce4(this.flushPendingUpdate.bind(this), 50);
177777
177777
  }
177778
177778
  lastState;
177779
+ pendingMappedChange = false;
177779
177780
  flushUpdate;
177780
177781
  async delete() {
177781
177782
  this.flushUpdate.clear();
@@ -177788,6 +177789,7 @@ var LegacyEndpoint = class _LegacyEndpoint extends EntityEndpoint {
177788
177789
  return;
177789
177790
  }
177790
177791
  if (mappedChanged) {
177792
+ this.pendingMappedChange = true;
177791
177793
  logger198.debug(
177792
177794
  `Mapped entity change detected for ${this.entityId}, forcing update`
177793
177795
  );
@@ -177806,8 +177808,13 @@ var LegacyEndpoint = class _LegacyEndpoint extends EntityEndpoint {
177806
177808
  }
177807
177809
  try {
177808
177810
  const current = this.stateOf(HomeAssistantEntityBehavior).entity;
177811
+ let effectiveState = state;
177812
+ if (this.pendingMappedChange) {
177813
+ this.pendingMappedChange = false;
177814
+ effectiveState = { ...state, last_updated: (/* @__PURE__ */ new Date()).toISOString() };
177815
+ }
177809
177816
  await this.setStateOf(HomeAssistantEntityBehavior, {
177810
- entity: { ...current, state }
177817
+ entity: { ...current, state: effectiveState }
177811
177818
  });
177812
177819
  } catch (error) {
177813
177820
  const errorMessage = error instanceof Error ? error.message : String(error);
@@ -179643,6 +179650,7 @@ var ServerModeVacuumEndpoint = class _ServerModeVacuumEndpoint extends EntityEnd
179643
179650
  );
179644
179651
  }
179645
179652
  lastState;
179653
+ pendingMappedChange = false;
179646
179654
  flushUpdate;
179647
179655
  constructor(type, entityId, customName, mappedEntityIds) {
179648
179656
  super(type, entityId, customName, mappedEntityIds);
@@ -179659,6 +179667,7 @@ var ServerModeVacuumEndpoint = class _ServerModeVacuumEndpoint extends EntityEnd
179659
179667
  return;
179660
179668
  }
179661
179669
  if (mappedChanged) {
179670
+ this.pendingMappedChange = true;
179662
179671
  logger201.debug(
179663
179672
  `Mapped entity change detected for ${this.entityId}, forcing update`
179664
179673
  );
@@ -179677,8 +179686,13 @@ var ServerModeVacuumEndpoint = class _ServerModeVacuumEndpoint extends EntityEnd
179677
179686
  }
179678
179687
  try {
179679
179688
  const current = this.stateOf(HomeAssistantEntityBehavior).entity;
179689
+ let effectiveState = state;
179690
+ if (this.pendingMappedChange) {
179691
+ this.pendingMappedChange = false;
179692
+ effectiveState = { ...state, last_updated: (/* @__PURE__ */ new Date()).toISOString() };
179693
+ }
179680
179694
  await this.setStateOf(HomeAssistantEntityBehavior, {
179681
- entity: { ...current, state }
179695
+ entity: { ...current, state: effectiveState }
179682
179696
  });
179683
179697
  } catch (error) {
179684
179698
  if (error instanceof TransactionDestroyedError || error instanceof DestroyedDependencyError) {