@riddix/hamh 2.1.0-alpha.562 → 2.1.0-alpha.564

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.
@@ -175874,6 +175874,11 @@ var RvcRunModeServerBase = class extends RvcRunModeServer {
175874
175874
  * dispatching the HA action to prevent re-dispatch, but progress
175875
175875
  * tracking needs the original list for the entire cleaning session. */
175876
175876
  activeAreas = [];
175877
+ /** Diagnostic short-circuit reasons already logged this session.
175878
+ * updateCurrentRoomFromSensor() is called on every HA state event;
175879
+ * without this guard a failing path would flood the log. Cleared
175880
+ * when the vacuum returns to Idle. */
175881
+ loggedShortCircuits = /* @__PURE__ */ new Set();
175877
175882
  async initialize() {
175878
175883
  await super.initialize();
175879
175884
  const homeAssistant = await this.agent.load(HomeAssistantEntityBehavior);
@@ -175902,6 +175907,7 @@ var RvcRunModeServerBase = class extends RvcRunModeServer {
175902
175907
  this.trySetCurrentArea(null);
175903
175908
  this.completedAreas.clear();
175904
175909
  this.lastCurrentArea = null;
175910
+ this.loggedShortCircuits.clear();
175905
175911
  } else if (newMode === 1 /* Cleaning */) {
175906
175912
  if (this.activeAreas.length > 0 && this.lastCurrentArea === null) {
175907
175913
  this.trySetCurrentArea(this.activeAreas[0]);
@@ -175912,6 +175918,16 @@ var RvcRunModeServerBase = class extends RvcRunModeServer {
175912
175918
  this.updateCurrentRoomFromSensor();
175913
175919
  }
175914
175920
  }
175921
+ /**
175922
+ * Emit a diagnostic INFO log exactly once per cleaning session for a
175923
+ * given short-circuit reason. Prevents log flooding while still
175924
+ * surfacing the silent paths that would otherwise be invisible.
175925
+ */
175926
+ logShortCircuitOnce(reason, message) {
175927
+ if (this.loggedShortCircuits.has(reason)) return;
175928
+ this.loggedShortCircuits.add(reason);
175929
+ logger189.info(message);
175930
+ }
175915
175931
  /**
175916
175932
  * Read the currentRoomEntity sensor and update currentArea + progress
175917
175933
  * to reflect which room the vacuum is actually in right now.
@@ -175920,11 +175936,29 @@ var RvcRunModeServerBase = class extends RvcRunModeServer {
175920
175936
  try {
175921
175937
  const homeAssistant = this.agent.get(HomeAssistantEntityBehavior);
175922
175938
  const currentRoomEntityId = homeAssistant.state.mapping?.currentRoomEntity;
175923
- if (!currentRoomEntityId) return;
175939
+ if (!currentRoomEntityId) {
175940
+ this.logShortCircuitOnce(
175941
+ "no-mapping",
175942
+ "currentRoom sensor: no currentRoomEntity in mapping \u2014 auto-detect did not run or sensor not on same HA device"
175943
+ );
175944
+ return;
175945
+ }
175924
175946
  const stateProvider = this.agent.env.get(EntityStateProvider);
175925
175947
  const roomState = stateProvider.getState(currentRoomEntityId);
175926
- if (!roomState || !roomState.state) return;
175927
- if (this.activeAreas.length === 0) return;
175948
+ if (!roomState || !roomState.state) {
175949
+ this.logShortCircuitOnce(
175950
+ "no-state",
175951
+ `currentRoom sensor: no state available for ${currentRoomEntityId}`
175952
+ );
175953
+ return;
175954
+ }
175955
+ if (this.activeAreas.length === 0) {
175956
+ this.logShortCircuitOnce(
175957
+ "no-active-areas",
175958
+ `currentRoom sensor: activeAreas empty while cleaning \u2014 sensor=${currentRoomEntityId} state="${roomState.state}"`
175959
+ );
175960
+ return;
175961
+ }
175928
175962
  const serviceArea = this.agent.get(ServiceAreaBehavior);
175929
175963
  const sensorAttrs = roomState.attributes;
175930
175964
  const segmentId = sensorAttrs.segment_id ?? sensorAttrs.room_id;
@@ -177891,6 +177925,18 @@ var RvcOperationalStateServerBase = class extends RvcOperationalStateServer {
177891
177925
  this.state.operationalError = { errorStateId: ErrorState.NoError };
177892
177926
  await super.initialize();
177893
177927
  const homeAssistant = await this.agent.load(HomeAssistantEntityBehavior);
177928
+ try {
177929
+ const events = this.events;
177930
+ events.operationalError$Changed?.on(() => {
177931
+ logger195.info(
177932
+ `#287 diag[3]: operationalError$Changed fired for ${homeAssistant.entityId}`
177933
+ );
177934
+ });
177935
+ } catch (e) {
177936
+ logger195.warn(
177937
+ `#287 diag[3]: failed to attach operationalError$Changed listener: ${e instanceof Error ? e.message : String(e)}`
177938
+ );
177939
+ }
177894
177940
  this.update(homeAssistant.entity);
177895
177941
  this.reactTo(homeAssistant.onChange, this.update);
177896
177942
  }
@@ -177903,6 +177949,9 @@ var RvcOperationalStateServerBase = class extends RvcOperationalStateServer {
177903
177949
  this.agent
177904
177950
  );
177905
177951
  const previousState = this.state.operationalState;
177952
+ logger195.info(
177953
+ `#287 diag[2]: update() reactor invoked for ${entity.entity_id} \u2014 prevState=${previousState} newState=${newState} nonceBefore=${this.keepaliveNonce}`
177954
+ );
177906
177955
  this.keepaliveNonce = !this.keepaliveNonce;
177907
177956
  const errorStateId = newState === OperationalState4.Error ? ErrorState.Stuck : ErrorState.NoError;
177908
177957
  const operationalError = { errorStateId };
@@ -178799,7 +178848,7 @@ var LegacyEndpoint = class _LegacyEndpoint extends EntityEndpoint {
178799
178848
  entityId: effectiveMapping?.entityId ?? entityId,
178800
178849
  cleaningModeEntity: vacuumEntities.cleaningModeEntity
178801
178850
  };
178802
- logger200.debug(
178851
+ logger200.info(
178803
178852
  `Auto-assigned cleaningMode ${vacuumEntities.cleaningModeEntity} to ${entityId}`
178804
178853
  );
178805
178854
  }
@@ -178809,7 +178858,7 @@ var LegacyEndpoint = class _LegacyEndpoint extends EntityEndpoint {
178809
178858
  entityId: effectiveMapping?.entityId ?? entityId,
178810
178859
  suctionLevelEntity: vacuumEntities.suctionLevelEntity
178811
178860
  };
178812
- logger200.debug(
178861
+ logger200.info(
178813
178862
  `Auto-assigned suctionLevel ${vacuumEntities.suctionLevelEntity} to ${entityId}`
178814
178863
  );
178815
178864
  }
@@ -178819,7 +178868,7 @@ var LegacyEndpoint = class _LegacyEndpoint extends EntityEndpoint {
178819
178868
  entityId: effectiveMapping?.entityId ?? entityId,
178820
178869
  mopIntensityEntity: vacuumEntities.mopIntensityEntity
178821
178870
  };
178822
- logger200.debug(
178871
+ logger200.info(
178823
178872
  `Auto-assigned mopIntensity ${vacuumEntities.mopIntensityEntity} to ${entityId}`
178824
178873
  );
178825
178874
  }
@@ -178829,7 +178878,7 @@ var LegacyEndpoint = class _LegacyEndpoint extends EntityEndpoint {
178829
178878
  entityId: effectiveMapping?.entityId ?? entityId,
178830
178879
  currentRoomEntity: vacuumEntities.currentRoomEntity
178831
178880
  };
178832
- logger200.debug(
178881
+ logger200.info(
178833
178882
  `Auto-assigned currentRoom ${vacuumEntities.currentRoomEntity} to ${entityId}`
178834
178883
  );
178835
178884
  }
@@ -178844,7 +178893,7 @@ var LegacyEndpoint = class _LegacyEndpoint extends EntityEndpoint {
178844
178893
  entityId: effectiveMapping?.entityId ?? entityId,
178845
178894
  cleanAreaRooms
178846
178895
  };
178847
- logger200.debug(
178896
+ logger200.info(
178848
178897
  `Using ${cleanAreaRooms.length} HA areas via CLEAN_AREA for ${entityId}`
178849
178898
  );
178850
178899
  }
@@ -181146,6 +181195,9 @@ var ServerModeVacuumEndpoint = class _ServerModeVacuumEndpoint extends EntityEnd
181146
181195
  this.flushUpdate = debounce6(this.flushPendingUpdate.bind(this), 50);
181147
181196
  this.keepaliveTimer = setInterval(() => {
181148
181197
  if (this.lastState) {
181198
+ logger203.info(
181199
+ `#287 diag[1]: keepalive tick for ${this.entityId} \u2014 scheduling flushUpdate`
181200
+ );
181149
181201
  this.pendingMappedChange = true;
181150
181202
  this.flushUpdate(this.lastState);
181151
181203
  }