@riddix/hamh 2.1.0-alpha.448 → 2.1.0-alpha.449
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
|
@@ -166261,8 +166261,9 @@ init_home_assistant_entity_behavior();
|
|
|
166261
166261
|
init_esm();
|
|
166262
166262
|
init_home_assistant_entity_behavior();
|
|
166263
166263
|
var lastTurnOnTimestamps = /* @__PURE__ */ new Map();
|
|
166264
|
-
var
|
|
166265
|
-
var
|
|
166264
|
+
var optimisticLevelState = /* @__PURE__ */ new Map();
|
|
166265
|
+
var OPTIMISTIC_TIMEOUT_MS = 3e3;
|
|
166266
|
+
var OPTIMISTIC_TOLERANCE = 5;
|
|
166266
166267
|
function notifyLightTurnedOn(entityId) {
|
|
166267
166268
|
lastTurnOnTimestamps.set(entityId, Date.now());
|
|
166268
166269
|
}
|
|
@@ -166307,10 +166308,15 @@ var LevelControlServerBase = class extends FeaturedBase4 {
|
|
|
166307
166308
|
if (currentLevel != null) {
|
|
166308
166309
|
currentLevel = Math.min(Math.max(minLevel, currentLevel), maxLevel);
|
|
166309
166310
|
}
|
|
166310
|
-
const
|
|
166311
|
-
|
|
166312
|
-
|
|
166313
|
-
|
|
166311
|
+
const optimistic = optimisticLevelState.get(entity.entity_id);
|
|
166312
|
+
if (optimistic != null && currentLevel != null) {
|
|
166313
|
+
if (Date.now() - optimistic.timestamp > OPTIMISTIC_TIMEOUT_MS) {
|
|
166314
|
+
optimisticLevelState.delete(entity.entity_id);
|
|
166315
|
+
} else if (Math.abs(currentLevel - optimistic.expectedLevel) <= OPTIMISTIC_TOLERANCE) {
|
|
166316
|
+
optimisticLevelState.delete(entity.entity_id);
|
|
166317
|
+
} else {
|
|
166318
|
+
currentLevel = null;
|
|
166319
|
+
}
|
|
166314
166320
|
}
|
|
166315
166321
|
applyPatchState(this.state, {
|
|
166316
166322
|
minLevel,
|
|
@@ -166379,7 +166385,10 @@ var LevelControlServerBase = class extends FeaturedBase4 {
|
|
|
166379
166385
|
};
|
|
166380
166386
|
}
|
|
166381
166387
|
this.state.currentLevel = level;
|
|
166382
|
-
|
|
166388
|
+
optimisticLevelState.set(entityId, {
|
|
166389
|
+
expectedLevel: level,
|
|
166390
|
+
timestamp: Date.now()
|
|
166391
|
+
});
|
|
166383
166392
|
homeAssistant.callAction(action);
|
|
166384
166393
|
}
|
|
166385
166394
|
};
|
|
@@ -169468,8 +169477,9 @@ init_nodejs();
|
|
|
169468
169477
|
// src/matter/behaviors/color-control-server.ts
|
|
169469
169478
|
init_home_assistant_entity_behavior();
|
|
169470
169479
|
var logger170 = Logger.get("ColorControlServer");
|
|
169471
|
-
var
|
|
169472
|
-
var
|
|
169480
|
+
var optimisticColorState = /* @__PURE__ */ new Map();
|
|
169481
|
+
var OPTIMISTIC_TIMEOUT_MS2 = 3e3;
|
|
169482
|
+
var OPTIMISTIC_TOLERANCE2 = 5;
|
|
169473
169483
|
var pendingColorStaging = /* @__PURE__ */ new Map();
|
|
169474
169484
|
function consumePendingColorStaging(entityId) {
|
|
169475
169485
|
const data = pendingColorStaging.get(entityId);
|
|
@@ -169554,8 +169564,29 @@ var ColorControlServerBase = class extends FeaturedBase7 {
|
|
|
169554
169564
|
const newColorMode = this.getColorModeFromFeatures(
|
|
169555
169565
|
config10.getCurrentMode(entity.state, this.agent)
|
|
169556
169566
|
);
|
|
169557
|
-
const
|
|
169558
|
-
|
|
169567
|
+
const optimistic = optimisticColorState.get(entity.entity_id);
|
|
169568
|
+
let skipColorTemp = false;
|
|
169569
|
+
let skipHueSat = false;
|
|
169570
|
+
if (optimistic != null) {
|
|
169571
|
+
if (Date.now() - optimistic.timestamp > OPTIMISTIC_TIMEOUT_MS2) {
|
|
169572
|
+
optimisticColorState.delete(entity.entity_id);
|
|
169573
|
+
} else {
|
|
169574
|
+
if (optimistic.colorTemperatureMireds != null && currentMireds != null) {
|
|
169575
|
+
if (Math.abs(currentMireds - optimistic.colorTemperatureMireds) <= OPTIMISTIC_TOLERANCE2) {
|
|
169576
|
+
optimisticColorState.delete(entity.entity_id);
|
|
169577
|
+
} else {
|
|
169578
|
+
skipColorTemp = true;
|
|
169579
|
+
}
|
|
169580
|
+
}
|
|
169581
|
+
if (optimistic.currentHue != null && optimistic.currentSaturation != null) {
|
|
169582
|
+
if (Math.abs(hue - optimistic.currentHue) <= OPTIMISTIC_TOLERANCE2 && Math.abs(saturation - optimistic.currentSaturation) <= OPTIMISTIC_TOLERANCE2) {
|
|
169583
|
+
optimisticColorState.delete(entity.entity_id);
|
|
169584
|
+
} else {
|
|
169585
|
+
skipHueSat = true;
|
|
169586
|
+
}
|
|
169587
|
+
}
|
|
169588
|
+
}
|
|
169589
|
+
}
|
|
169559
169590
|
if (this.features.colorTemperature) {
|
|
169560
169591
|
const existingMireds = this.state.colorTemperatureMireds;
|
|
169561
169592
|
if (existingMireds != null) {
|
|
@@ -169580,12 +169611,12 @@ var ColorControlServerBase = class extends FeaturedBase7 {
|
|
|
169580
169611
|
applyPatchState(this.state, {
|
|
169581
169612
|
coupleColorTempToLevelMinMireds: minMireds,
|
|
169582
169613
|
startUpColorTemperatureMireds: startUpMireds,
|
|
169583
|
-
...
|
|
169614
|
+
...skipColorTemp ? {} : { colorTemperatureMireds: effectiveMireds }
|
|
169584
169615
|
});
|
|
169585
169616
|
}
|
|
169586
169617
|
applyPatchState(this.state, {
|
|
169587
|
-
...
|
|
169588
|
-
...this.features.hueSaturation && !
|
|
169618
|
+
...skipColorTemp && skipHueSat ? {} : { colorMode: newColorMode },
|
|
169619
|
+
...this.features.hueSaturation && !skipHueSat ? {
|
|
169589
169620
|
currentHue: hue,
|
|
169590
169621
|
currentSaturation: saturation
|
|
169591
169622
|
} : {}
|
|
@@ -169612,7 +169643,10 @@ var ColorControlServerBase = class extends FeaturedBase7 {
|
|
|
169612
169643
|
colorTemperatureMireds: targetMireds,
|
|
169613
169644
|
colorMode: ColorControl3.ColorMode.ColorTemperatureMireds
|
|
169614
169645
|
});
|
|
169615
|
-
|
|
169646
|
+
optimisticColorState.set(homeAssistant.entityId, {
|
|
169647
|
+
colorTemperatureMireds: targetMireds,
|
|
169648
|
+
timestamp: Date.now()
|
|
169649
|
+
});
|
|
169616
169650
|
if (this.isLightOff()) {
|
|
169617
169651
|
pendingColorStaging.set(homeAssistant.entityId, action.data ?? {});
|
|
169618
169652
|
return;
|
|
@@ -169647,7 +169681,11 @@ var ColorControlServerBase = class extends FeaturedBase7 {
|
|
|
169647
169681
|
currentSaturation: targetSaturation,
|
|
169648
169682
|
colorMode: ColorControl3.ColorMode.CurrentHueAndCurrentSaturation
|
|
169649
169683
|
});
|
|
169650
|
-
|
|
169684
|
+
optimisticColorState.set(homeAssistant.entityId, {
|
|
169685
|
+
currentHue: targetHue,
|
|
169686
|
+
currentSaturation: targetSaturation,
|
|
169687
|
+
timestamp: Date.now()
|
|
169688
|
+
});
|
|
169651
169689
|
if (this.isLightOff()) {
|
|
169652
169690
|
pendingColorStaging.set(homeAssistant.entityId, action.data ?? {});
|
|
169653
169691
|
return;
|
|
@@ -170963,8 +171001,9 @@ init_home_assistant_entity_behavior();
|
|
|
170963
171001
|
init_esm();
|
|
170964
171002
|
init_home_assistant_entity_behavior();
|
|
170965
171003
|
var logger175 = Logger.get("SpeakerLevelControlServer");
|
|
170966
|
-
var
|
|
170967
|
-
var
|
|
171004
|
+
var optimisticLevelState2 = /* @__PURE__ */ new Map();
|
|
171005
|
+
var OPTIMISTIC_TIMEOUT_MS3 = 3e3;
|
|
171006
|
+
var OPTIMISTIC_TOLERANCE3 = 5;
|
|
170968
171007
|
var FeaturedBase9 = LevelControlServer.with("OnOff");
|
|
170969
171008
|
var SpeakerLevelControlServerBase = class extends FeaturedBase9 {
|
|
170970
171009
|
async initialize() {
|
|
@@ -171000,10 +171039,15 @@ var SpeakerLevelControlServerBase = class extends FeaturedBase9 {
|
|
|
171000
171039
|
logger175.debug(
|
|
171001
171040
|
`[${entityId}] Volume update: HA=${currentLevelPercent != null ? Math.round(currentLevelPercent * 100) : "null"}% -> currentLevel=${currentLevel}`
|
|
171002
171041
|
);
|
|
171003
|
-
const
|
|
171004
|
-
|
|
171005
|
-
|
|
171006
|
-
|
|
171042
|
+
const optimistic = optimisticLevelState2.get(entity.entity_id);
|
|
171043
|
+
if (optimistic != null && currentLevel != null) {
|
|
171044
|
+
if (Date.now() - optimistic.timestamp > OPTIMISTIC_TIMEOUT_MS3) {
|
|
171045
|
+
optimisticLevelState2.delete(entity.entity_id);
|
|
171046
|
+
} else if (Math.abs(currentLevel - optimistic.expectedLevel) <= OPTIMISTIC_TOLERANCE3) {
|
|
171047
|
+
optimisticLevelState2.delete(entity.entity_id);
|
|
171048
|
+
} else {
|
|
171049
|
+
currentLevel = null;
|
|
171050
|
+
}
|
|
171007
171051
|
}
|
|
171008
171052
|
applyPatchState(this.state, {
|
|
171009
171053
|
minLevel,
|
|
@@ -171051,7 +171095,10 @@ var SpeakerLevelControlServerBase = class extends FeaturedBase9 {
|
|
|
171051
171095
|
return;
|
|
171052
171096
|
}
|
|
171053
171097
|
this.state.currentLevel = level;
|
|
171054
|
-
|
|
171098
|
+
optimisticLevelState2.set(entityId, {
|
|
171099
|
+
expectedLevel: level,
|
|
171100
|
+
timestamp: Date.now()
|
|
171101
|
+
});
|
|
171055
171102
|
homeAssistant.callAction(
|
|
171056
171103
|
config10.moveToLevelPercent(levelPercent, this.agent)
|
|
171057
171104
|
);
|