@riddix/hamh 2.1.0-alpha.586 → 2.1.0-alpha.588

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.
@@ -174258,6 +174258,9 @@ var AirQualitySensorServerImpl = class extends AirQualityServerWithFeatures {
174258
174258
  this.reactTo(homeAssistant.onChange, this.update);
174259
174259
  }
174260
174260
  update(entity) {
174261
+ if (!entity.state || !entity.state.attributes) {
174262
+ return;
174263
+ }
174261
174264
  const state = entity.state.state;
174262
174265
  const attributes7 = entity.state.attributes;
174263
174266
  const deviceClass = attributes7.device_class;
@@ -174437,6 +174440,9 @@ var StandalonePowerServer = class extends ElectricalPowerMeasurementServer {
174437
174440
  this.reactTo(homeAssistant.onChange, this.update);
174438
174441
  }
174439
174442
  update(entity) {
174443
+ if (!entity.state || !entity.state.attributes) {
174444
+ return;
174445
+ }
174440
174446
  const state = entity.state.state;
174441
174447
  if (state == null || Number.isNaN(+state)) return;
174442
174448
  const attrs = entity.state.attributes;
@@ -174492,6 +174498,9 @@ var StandaloneEnergyServer = class extends EnergyFeaturedBase {
174492
174498
  this.reactTo(homeAssistant.onChange, this.update);
174493
174499
  }
174494
174500
  update(entity) {
174501
+ if (!entity.state || !entity.state.attributes) {
174502
+ return;
174503
+ }
174495
174504
  const attrs = entity.state.attributes;
174496
174505
  if (attrs.device_class !== SensorDeviceClass.energy) return;
174497
174506
  const state = entity.state.state;
@@ -175308,6 +175317,9 @@ var TvocAirQualityServer = class extends TvocAirQualityServerBase {
175308
175317
  this.reactTo(homeAssistant.onChange, this.update);
175309
175318
  }
175310
175319
  update(entity) {
175320
+ if (!entity.state || !entity.state.attributes) {
175321
+ return;
175322
+ }
175311
175323
  const state = entity.state.state;
175312
175324
  const attributes7 = entity.state.attributes;
175313
175325
  const deviceClass = attributes7.device_class;
@@ -176067,13 +176079,25 @@ var RvcRunModeServerBase = class extends RvcRunModeServer {
176067
176079
  );
176068
176080
  if (previousMode !== newMode) {
176069
176081
  if (newMode === 0 /* Idle */) {
176070
- this.trySetCurrentArea(null);
176071
- s.completedAreas.clear();
176072
- s.lastCurrentArea = null;
176082
+ if (s.lastCurrentArea !== null) {
176083
+ s.completedAreas.add(s.lastCurrentArea);
176084
+ s.lastCurrentArea = null;
176085
+ try {
176086
+ const serviceArea = this.agent.get(ServiceAreaBehavior);
176087
+ serviceArea.state.currentArea = null;
176088
+ this.updateProgressFromTracking(serviceArea);
176089
+ } catch {
176090
+ }
176091
+ }
176073
176092
  s.loggedShortCircuits.clear();
176074
176093
  } else if (newMode === 1 /* Cleaning */) {
176075
176094
  if (s.activeAreas.length > 0 && s.lastCurrentArea === null) {
176076
- this.trySetCurrentArea(s.activeAreas[0]);
176095
+ const firstPending = s.activeAreas.find(
176096
+ (id) => !s.completedAreas.has(id)
176097
+ );
176098
+ if (firstPending !== void 0) {
176099
+ this.trySetCurrentArea(firstPending);
176100
+ }
176077
176101
  }
176078
176102
  }
176079
176103
  }
@@ -176214,6 +176238,22 @@ var RvcRunModeServerBase = class extends RvcRunModeServer {
176214
176238
  }));
176215
176239
  }
176216
176240
  }
176241
+ /**
176242
+ * Update progress entries from tracking state without any area
176243
+ * operating. Used on mid-session transitions (e.g. vacuum-then-mop
176244
+ * tool swap) where the vacuum is temporarily idle but the session
176245
+ * is not finished: completed areas stay Completed, remaining areas
176246
+ * stay Pending.
176247
+ */
176248
+ updateProgressFromTracking(serviceArea) {
176249
+ const s = getSession(this.endpoint);
176250
+ if (s.activeAreas.length === 0) return;
176251
+ const state = serviceArea.state;
176252
+ state.progress = s.activeAreas.map((id) => ({
176253
+ areaId: id,
176254
+ status: s.completedAreas.has(id) ? ServiceArea3.OperationalStatus.Completed : ServiceArea3.OperationalStatus.Pending
176255
+ }));
176256
+ }
176217
176257
  /**
176218
176258
  * Find the ServiceArea area ID that corresponds to a run mode value
176219
176259
  * by matching the mode label to the area location name.
@@ -176246,6 +176286,9 @@ var RvcRunModeServerBase = class extends RvcRunModeServer {
176246
176286
  const serviceArea = this.agent.get(ServiceAreaBehavior);
176247
176287
  if (serviceArea.state.selectedAreas?.length > 0) {
176248
176288
  s.activeAreas = [...serviceArea.state.selectedAreas];
176289
+ s.completedAreas.clear();
176290
+ s.lastCurrentArea = null;
176291
+ s.loggedShortCircuits.clear();
176249
176292
  this.trySetCurrentArea(s.activeAreas[0]);
176250
176293
  homeAssistant.callAction(this.state.config.start(void 0, this.agent));
176251
176294
  this.state.currentMode = newMode;
@@ -176259,6 +176302,9 @@ var RvcRunModeServerBase = class extends RvcRunModeServer {
176259
176302
  if (this.state.config.cleanRoom) {
176260
176303
  const areaId = this.findAreaIdForMode(newMode);
176261
176304
  s.activeAreas = areaId !== null ? [areaId] : [];
176305
+ s.completedAreas.clear();
176306
+ s.lastCurrentArea = null;
176307
+ s.loggedShortCircuits.clear();
176262
176308
  this.trySetCurrentArea(areaId);
176263
176309
  homeAssistant.callAction(
176264
176310
  this.state.config.cleanRoom(newMode, this.agent)
@@ -176276,6 +176322,9 @@ var RvcRunModeServerBase = class extends RvcRunModeServer {
176276
176322
  const serviceArea = this.agent.get(ServiceAreaBehavior);
176277
176323
  if (serviceArea.state.selectedAreas?.length > 0) {
176278
176324
  s.activeAreas = [...serviceArea.state.selectedAreas];
176325
+ s.completedAreas.clear();
176326
+ s.lastCurrentArea = null;
176327
+ s.loggedShortCircuits.clear();
176279
176328
  this.trySetCurrentArea(s.activeAreas[0]);
176280
176329
  }
176281
176330
  } catch {
@@ -176288,6 +176337,7 @@ var RvcRunModeServerBase = class extends RvcRunModeServer {
176288
176337
  s.completedAreas.clear();
176289
176338
  s.lastCurrentArea = null;
176290
176339
  s.activeAreas = [];
176340
+ s.loggedShortCircuits.clear();
176291
176341
  homeAssistant.callAction(
176292
176342
  this.state.config.returnToBase(void 0, this.agent)
176293
176343
  );