@riddix/hamh 2.1.0-alpha.558 → 2.1.0-alpha.559
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
|
@@ -181105,30 +181105,34 @@ var ServerModeVacuumEndpoint = class _ServerModeVacuumEndpoint extends EntityEnd
|
|
|
181105
181105
|
}
|
|
181106
181106
|
lastState;
|
|
181107
181107
|
pendingMappedChange = false;
|
|
181108
|
-
/** Timestamp of the last non-empty state push to matter.js */
|
|
181109
|
-
lastNonEmptyPush = Date.now();
|
|
181110
181108
|
flushUpdate;
|
|
181109
|
+
/** Periodic keepalive timer that re-pushes the last known state so
|
|
181110
|
+
* Apple Home (iOS) doesn't show "Updating..." due to stale
|
|
181111
|
+
* subscription data when the vacuum is idle and no HA events fire. */
|
|
181112
|
+
keepaliveTimer;
|
|
181111
181113
|
constructor(type, entityId, customName, mappedEntityIds) {
|
|
181112
181114
|
super(type, entityId, customName, mappedEntityIds);
|
|
181113
181115
|
this.flushUpdate = debounce6(this.flushPendingUpdate.bind(this), 50);
|
|
181116
|
+
this.keepaliveTimer = setInterval(() => {
|
|
181117
|
+
if (this.lastState) {
|
|
181118
|
+
this.pendingMappedChange = true;
|
|
181119
|
+
this.flushUpdate(this.lastState);
|
|
181120
|
+
}
|
|
181121
|
+
}, 55e3);
|
|
181114
181122
|
}
|
|
181115
181123
|
async delete() {
|
|
181124
|
+
if (this.keepaliveTimer) {
|
|
181125
|
+
clearInterval(this.keepaliveTimer);
|
|
181126
|
+
this.keepaliveTimer = void 0;
|
|
181127
|
+
}
|
|
181116
181128
|
this.flushUpdate.clear();
|
|
181117
181129
|
await super.delete();
|
|
181118
181130
|
}
|
|
181119
181131
|
async updateStates(states) {
|
|
181120
181132
|
const state = states[this.entityId] ?? {};
|
|
181121
181133
|
const mappedChanged = this.hasMappedEntityChanged(states);
|
|
181122
|
-
|
|
181123
|
-
|
|
181124
|
-
const now = Date.now();
|
|
181125
|
-
if (now - this.lastNonEmptyPush < 6e4) {
|
|
181126
|
-
return;
|
|
181127
|
-
}
|
|
181128
|
-
this.lastNonEmptyPush = now;
|
|
181129
|
-
this.pendingMappedChange = true;
|
|
181130
|
-
} else {
|
|
181131
|
-
this.lastNonEmptyPush = Date.now();
|
|
181134
|
+
if (!mappedChanged && state.state === this.lastState?.state && JSON.stringify(state.attributes) === JSON.stringify(this.lastState?.attributes)) {
|
|
181135
|
+
return;
|
|
181132
181136
|
}
|
|
181133
181137
|
if (mappedChanged) {
|
|
181134
181138
|
this.pendingMappedChange = true;
|