@riddix/hamh 2.1.0-alpha.450 → 2.1.0-alpha.451
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
|
@@ -166407,6 +166407,8 @@ function LevelControlServer2(config10) {
|
|
|
166407
166407
|
|
|
166408
166408
|
// src/matter/behaviors/on-off-server.ts
|
|
166409
166409
|
var logger159 = Logger.get("OnOffServer");
|
|
166410
|
+
var optimisticOnOffState = /* @__PURE__ */ new Map();
|
|
166411
|
+
var OPTIMISTIC_TIMEOUT_MS2 = 3e3;
|
|
166410
166412
|
var OnOffServerBase = class extends OnOffServer {
|
|
166411
166413
|
async initialize() {
|
|
166412
166414
|
await super.initialize();
|
|
@@ -166415,9 +166417,19 @@ var OnOffServerBase = class extends OnOffServer {
|
|
|
166415
166417
|
this.reactTo(homeAssistant.onChange, this.update);
|
|
166416
166418
|
}
|
|
166417
166419
|
update({ state }) {
|
|
166418
|
-
|
|
166419
|
-
|
|
166420
|
-
|
|
166420
|
+
const onOff = this.isOn(state);
|
|
166421
|
+
const entityId = this.agent.get(HomeAssistantEntityBehavior).entity.entity_id;
|
|
166422
|
+
const optimistic = optimisticOnOffState.get(entityId);
|
|
166423
|
+
if (optimistic != null) {
|
|
166424
|
+
if (Date.now() - optimistic.timestamp > OPTIMISTIC_TIMEOUT_MS2) {
|
|
166425
|
+
optimisticOnOffState.delete(entityId);
|
|
166426
|
+
} else if (onOff === optimistic.expectedOnOff) {
|
|
166427
|
+
optimisticOnOffState.delete(entityId);
|
|
166428
|
+
} else {
|
|
166429
|
+
return;
|
|
166430
|
+
}
|
|
166431
|
+
}
|
|
166432
|
+
applyPatchState(this.state, { onOff });
|
|
166421
166433
|
}
|
|
166422
166434
|
isOn(entity) {
|
|
166423
166435
|
return this.state.config?.isOn?.(entity, this.agent) ?? (this.agent.get(HomeAssistantEntityBehavior).isAvailable && entity.state !== "off");
|
|
@@ -166435,6 +166447,10 @@ var OnOffServerBase = class extends OnOffServer {
|
|
|
166435
166447
|
logger159.info(`[${homeAssistant.entityId}] Turning ON -> ${action.action}`);
|
|
166436
166448
|
notifyLightTurnedOn(homeAssistant.entityId);
|
|
166437
166449
|
applyPatchState(this.state, { onOff: true });
|
|
166450
|
+
optimisticOnOffState.set(homeAssistant.entityId, {
|
|
166451
|
+
expectedOnOff: true,
|
|
166452
|
+
timestamp: Date.now()
|
|
166453
|
+
});
|
|
166438
166454
|
homeAssistant.callAction(action);
|
|
166439
166455
|
if (turnOff === null) {
|
|
166440
166456
|
setTimeout(this.callback(this.autoReset), 1e3);
|
|
@@ -166452,6 +166468,10 @@ var OnOffServerBase = class extends OnOffServer {
|
|
|
166452
166468
|
};
|
|
166453
166469
|
logger159.info(`[${homeAssistant.entityId}] Turning OFF -> ${action.action}`);
|
|
166454
166470
|
applyPatchState(this.state, { onOff: false });
|
|
166471
|
+
optimisticOnOffState.set(homeAssistant.entityId, {
|
|
166472
|
+
expectedOnOff: false,
|
|
166473
|
+
timestamp: Date.now()
|
|
166474
|
+
});
|
|
166455
166475
|
homeAssistant.callAction(action);
|
|
166456
166476
|
}
|
|
166457
166477
|
autoReset() {
|
|
@@ -169488,7 +169508,7 @@ init_nodejs();
|
|
|
169488
169508
|
init_home_assistant_entity_behavior();
|
|
169489
169509
|
var logger170 = Logger.get("ColorControlServer");
|
|
169490
169510
|
var optimisticColorState = /* @__PURE__ */ new Map();
|
|
169491
|
-
var
|
|
169511
|
+
var OPTIMISTIC_TIMEOUT_MS3 = 3e3;
|
|
169492
169512
|
var OPTIMISTIC_TOLERANCE2 = 5;
|
|
169493
169513
|
var pendingColorStaging = /* @__PURE__ */ new Map();
|
|
169494
169514
|
function consumePendingColorStaging(entityId) {
|
|
@@ -169578,7 +169598,7 @@ var ColorControlServerBase = class extends FeaturedBase7 {
|
|
|
169578
169598
|
let skipColorTemp = false;
|
|
169579
169599
|
let skipHueSat = false;
|
|
169580
169600
|
if (optimistic != null) {
|
|
169581
|
-
if (Date.now() - optimistic.timestamp >
|
|
169601
|
+
if (Date.now() - optimistic.timestamp > OPTIMISTIC_TIMEOUT_MS3) {
|
|
169582
169602
|
optimisticColorState.delete(entity.entity_id);
|
|
169583
169603
|
} else {
|
|
169584
169604
|
if (optimistic.colorTemperatureMireds != null && currentMireds != null) {
|
|
@@ -171012,7 +171032,7 @@ init_esm();
|
|
|
171012
171032
|
init_home_assistant_entity_behavior();
|
|
171013
171033
|
var logger175 = Logger.get("SpeakerLevelControlServer");
|
|
171014
171034
|
var optimisticLevelState2 = /* @__PURE__ */ new Map();
|
|
171015
|
-
var
|
|
171035
|
+
var OPTIMISTIC_TIMEOUT_MS4 = 3e3;
|
|
171016
171036
|
var OPTIMISTIC_TOLERANCE3 = 5;
|
|
171017
171037
|
var FeaturedBase9 = LevelControlServer.with("OnOff");
|
|
171018
171038
|
var SpeakerLevelControlServerBase = class extends FeaturedBase9 {
|
|
@@ -171051,7 +171071,7 @@ var SpeakerLevelControlServerBase = class extends FeaturedBase9 {
|
|
|
171051
171071
|
);
|
|
171052
171072
|
const optimistic = optimisticLevelState2.get(entity.entity_id);
|
|
171053
171073
|
if (optimistic != null && currentLevel != null) {
|
|
171054
|
-
if (Date.now() - optimistic.timestamp >
|
|
171074
|
+
if (Date.now() - optimistic.timestamp > OPTIMISTIC_TIMEOUT_MS4) {
|
|
171055
171075
|
optimisticLevelState2.delete(entity.entity_id);
|
|
171056
171076
|
} else if (Math.abs(currentLevel - optimistic.expectedLevel) <= OPTIMISTIC_TOLERANCE3) {
|
|
171057
171077
|
optimisticLevelState2.delete(entity.entity_id);
|