@riddix/hamh 2.1.0-alpha.439 → 2.1.0-alpha.441
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
|
@@ -165933,12 +165933,8 @@ var FanControlServerBase = class extends FeaturedBase3 {
|
|
|
165933
165933
|
return;
|
|
165934
165934
|
}
|
|
165935
165935
|
this.agent.asLocalActor(() => {
|
|
165936
|
-
const
|
|
165937
|
-
this.
|
|
165938
|
-
percentSetting,
|
|
165939
|
-
this.state.percentSetting,
|
|
165940
|
-
context
|
|
165941
|
-
);
|
|
165936
|
+
const percentage = Math.floor(speed / this.state.speedMax * 100);
|
|
165937
|
+
this.applyPercentageAction(percentage);
|
|
165942
165938
|
});
|
|
165943
165939
|
}
|
|
165944
165940
|
targetFanModeChanged(fanMode, _oldValue, context) {
|
|
@@ -165951,16 +165947,12 @@ var FanControlServerBase = class extends FeaturedBase3 {
|
|
|
165951
165947
|
return;
|
|
165952
165948
|
}
|
|
165953
165949
|
const targetFanMode = FanMode.create(fanMode, this.state.fanModeSequence);
|
|
165954
|
-
const config10 = this.state.config;
|
|
165955
165950
|
if (targetFanMode.mode === FanControl3.FanMode.Auto) {
|
|
165956
|
-
homeAssistant.callAction(
|
|
165957
|
-
|
|
165958
|
-
const percentage = targetFanMode.speedPercent();
|
|
165959
|
-
this.targetPercentSettingChanged(
|
|
165960
|
-
percentage,
|
|
165961
|
-
this.state.percentSetting,
|
|
165962
|
-
context
|
|
165951
|
+
homeAssistant.callAction(
|
|
165952
|
+
this.state.config.setAutoMode(void 0, this.agent)
|
|
165963
165953
|
);
|
|
165954
|
+
} else {
|
|
165955
|
+
this.applyPercentageAction(targetFanMode.speedPercent());
|
|
165964
165956
|
}
|
|
165965
165957
|
});
|
|
165966
165958
|
}
|
|
@@ -165972,45 +165964,48 @@ var FanControlServerBase = class extends FeaturedBase3 {
|
|
|
165972
165964
|
return;
|
|
165973
165965
|
}
|
|
165974
165966
|
this.agent.asLocalActor(() => {
|
|
165975
|
-
|
|
165976
|
-
|
|
165977
|
-
|
|
165978
|
-
|
|
165979
|
-
|
|
165980
|
-
|
|
165967
|
+
this.applyPercentageAction(percentage);
|
|
165968
|
+
});
|
|
165969
|
+
}
|
|
165970
|
+
applyPercentageAction(percentage) {
|
|
165971
|
+
const homeAssistant = this.agent.get(HomeAssistantEntityBehavior);
|
|
165972
|
+
if (!homeAssistant.isAvailable) {
|
|
165973
|
+
return;
|
|
165974
|
+
}
|
|
165975
|
+
const config10 = this.state.config;
|
|
165976
|
+
const supportsPercentage = config10.supportsPercentage(
|
|
165977
|
+
homeAssistant.entity.state,
|
|
165978
|
+
this.agent
|
|
165979
|
+
);
|
|
165980
|
+
if (percentage === 0) {
|
|
165981
|
+
homeAssistant.callAction(config10.turnOff(void 0, this.agent));
|
|
165982
|
+
} else if (supportsPercentage) {
|
|
165983
|
+
const stepSize = config10.getStepSize(
|
|
165981
165984
|
homeAssistant.entity.state,
|
|
165982
165985
|
this.agent
|
|
165983
165986
|
);
|
|
165984
|
-
|
|
165985
|
-
|
|
165986
|
-
|
|
165987
|
-
|
|
165988
|
-
|
|
165989
|
-
|
|
165990
|
-
|
|
165991
|
-
|
|
165992
|
-
|
|
165993
|
-
|
|
165994
|
-
|
|
165987
|
+
const roundedPercentage = stepSize && stepSize > 0 ? Math.round(percentage / stepSize) * stepSize : percentage;
|
|
165988
|
+
const clampedPercentage = Math.max(
|
|
165989
|
+
stepSize ?? 1,
|
|
165990
|
+
Math.min(100, roundedPercentage)
|
|
165991
|
+
);
|
|
165992
|
+
homeAssistant.callAction(config10.turnOn(clampedPercentage, this.agent));
|
|
165993
|
+
} else {
|
|
165994
|
+
const presetModes = config10.getPresetModes(homeAssistant.entity.state, this.agent) ?? [];
|
|
165995
|
+
const speedPresets = presetModes.filter(
|
|
165996
|
+
(m) => m.toLowerCase() !== "auto"
|
|
165997
|
+
);
|
|
165998
|
+
if (speedPresets.length > 0) {
|
|
165999
|
+
const presetIndex = Math.min(
|
|
166000
|
+
Math.floor(percentage / 100 * speedPresets.length),
|
|
166001
|
+
speedPresets.length - 1
|
|
165995
166002
|
);
|
|
165996
|
-
|
|
165997
|
-
|
|
165998
|
-
|
|
165999
|
-
const speedPresets = presetModes.filter(
|
|
166000
|
-
(m) => m.toLowerCase() !== "auto"
|
|
166003
|
+
const targetPreset = speedPresets[presetIndex];
|
|
166004
|
+
homeAssistant.callAction(
|
|
166005
|
+
config10.setPresetMode(targetPreset, this.agent)
|
|
166001
166006
|
);
|
|
166002
|
-
if (speedPresets.length > 0) {
|
|
166003
|
-
const presetIndex = Math.min(
|
|
166004
|
-
Math.floor(percentage / 100 * speedPresets.length),
|
|
166005
|
-
speedPresets.length - 1
|
|
166006
|
-
);
|
|
166007
|
-
const targetPreset = speedPresets[presetIndex];
|
|
166008
|
-
homeAssistant.callAction(
|
|
166009
|
-
config10.setPresetMode(targetPreset, this.agent)
|
|
166010
|
-
);
|
|
166011
|
-
}
|
|
166012
166007
|
}
|
|
166013
|
-
}
|
|
166008
|
+
}
|
|
166014
166009
|
}
|
|
166015
166010
|
targetAirflowDirectionChanged(airflowDirection, _oldValue, context) {
|
|
166016
166011
|
if (transactionIsOffline(context)) {
|
|
@@ -166150,6 +166145,8 @@ init_home_assistant_entity_behavior();
|
|
|
166150
166145
|
init_esm();
|
|
166151
166146
|
init_home_assistant_entity_behavior();
|
|
166152
166147
|
var lastTurnOnTimestamps = /* @__PURE__ */ new Map();
|
|
166148
|
+
var optimisticLevelTimestamps = /* @__PURE__ */ new Map();
|
|
166149
|
+
var OPTIMISTIC_LEVEL_COOLDOWN_MS = 2e3;
|
|
166153
166150
|
function notifyLightTurnedOn(entityId) {
|
|
166154
166151
|
lastTurnOnTimestamps.set(entityId, Date.now());
|
|
166155
166152
|
}
|
|
@@ -166194,6 +166191,11 @@ var LevelControlServerBase = class extends FeaturedBase4 {
|
|
|
166194
166191
|
if (currentLevel != null) {
|
|
166195
166192
|
currentLevel = Math.min(Math.max(minLevel, currentLevel), maxLevel);
|
|
166196
166193
|
}
|
|
166194
|
+
const lastOptimistic = optimisticLevelTimestamps.get(entity.entity_id);
|
|
166195
|
+
const inCooldown = lastOptimistic != null && Date.now() - lastOptimistic < OPTIMISTIC_LEVEL_COOLDOWN_MS;
|
|
166196
|
+
if (inCooldown && currentLevel != null) {
|
|
166197
|
+
currentLevel = null;
|
|
166198
|
+
}
|
|
166197
166199
|
applyPatchState(this.state, {
|
|
166198
166200
|
minLevel,
|
|
166199
166201
|
maxLevel,
|
|
@@ -166261,6 +166263,7 @@ var LevelControlServerBase = class extends FeaturedBase4 {
|
|
|
166261
166263
|
};
|
|
166262
166264
|
}
|
|
166263
166265
|
this.state.currentLevel = level;
|
|
166266
|
+
optimisticLevelTimestamps.set(entityId, Date.now());
|
|
166264
166267
|
homeAssistant.callAction(action);
|
|
166265
166268
|
}
|
|
166266
166269
|
};
|
|
@@ -169349,6 +169352,8 @@ init_nodejs();
|
|
|
169349
169352
|
// src/matter/behaviors/color-control-server.ts
|
|
169350
169353
|
init_home_assistant_entity_behavior();
|
|
169351
169354
|
var logger170 = Logger.get("ColorControlServer");
|
|
169355
|
+
var optimisticColorTimestamps = /* @__PURE__ */ new Map();
|
|
169356
|
+
var OPTIMISTIC_COLOR_COOLDOWN_MS = 2e3;
|
|
169352
169357
|
var FeaturedBase7 = ColorControlServer.with("ColorTemperature", "HueSaturation");
|
|
169353
169358
|
var ColorControlServerBase = class extends FeaturedBase7 {
|
|
169354
169359
|
pendingTransitionTime;
|
|
@@ -169427,6 +169432,8 @@ var ColorControlServerBase = class extends FeaturedBase7 {
|
|
|
169427
169432
|
const newColorMode = this.getColorModeFromFeatures(
|
|
169428
169433
|
config10.getCurrentMode(entity.state, this.agent)
|
|
169429
169434
|
);
|
|
169435
|
+
const lastOptimistic = optimisticColorTimestamps.get(entity.entity_id);
|
|
169436
|
+
const inCooldown = lastOptimistic != null && Date.now() - lastOptimistic < OPTIMISTIC_COLOR_COOLDOWN_MS;
|
|
169430
169437
|
if (this.features.colorTemperature) {
|
|
169431
169438
|
const existingMireds = this.state.colorTemperatureMireds;
|
|
169432
169439
|
if (existingMireds != null) {
|
|
@@ -169451,12 +169458,12 @@ var ColorControlServerBase = class extends FeaturedBase7 {
|
|
|
169451
169458
|
applyPatchState(this.state, {
|
|
169452
169459
|
coupleColorTempToLevelMinMireds: minMireds,
|
|
169453
169460
|
startUpColorTemperatureMireds: startUpMireds,
|
|
169454
|
-
colorTemperatureMireds: effectiveMireds
|
|
169461
|
+
...inCooldown ? {} : { colorTemperatureMireds: effectiveMireds }
|
|
169455
169462
|
});
|
|
169456
169463
|
}
|
|
169457
169464
|
applyPatchState(this.state, {
|
|
169458
|
-
colorMode: newColorMode,
|
|
169459
|
-
...this.features.hueSaturation ? {
|
|
169465
|
+
...inCooldown ? {} : { colorMode: newColorMode },
|
|
169466
|
+
...this.features.hueSaturation && !inCooldown ? {
|
|
169460
169467
|
currentHue: hue,
|
|
169461
169468
|
currentSaturation: saturation
|
|
169462
169469
|
} : {}
|
|
@@ -169483,6 +169490,7 @@ var ColorControlServerBase = class extends FeaturedBase7 {
|
|
|
169483
169490
|
colorTemperatureMireds: targetMireds,
|
|
169484
169491
|
colorMode: ColorControl3.ColorMode.ColorTemperatureMireds
|
|
169485
169492
|
});
|
|
169493
|
+
optimisticColorTimestamps.set(homeAssistant.entityId, Date.now());
|
|
169486
169494
|
homeAssistant.callAction(action);
|
|
169487
169495
|
}
|
|
169488
169496
|
moveToHueLogic(targetHue) {
|
|
@@ -169513,6 +169521,7 @@ var ColorControlServerBase = class extends FeaturedBase7 {
|
|
|
169513
169521
|
currentSaturation: targetSaturation,
|
|
169514
169522
|
colorMode: ColorControl3.ColorMode.CurrentHueAndCurrentSaturation
|
|
169515
169523
|
});
|
|
169524
|
+
optimisticColorTimestamps.set(homeAssistant.entityId, Date.now());
|
|
169516
169525
|
homeAssistant.callAction(action);
|
|
169517
169526
|
}
|
|
169518
169527
|
applyTransition(action) {
|
|
@@ -170816,6 +170825,8 @@ init_home_assistant_entity_behavior();
|
|
|
170816
170825
|
init_esm();
|
|
170817
170826
|
init_home_assistant_entity_behavior();
|
|
170818
170827
|
var logger175 = Logger.get("SpeakerLevelControlServer");
|
|
170828
|
+
var optimisticLevelTimestamps2 = /* @__PURE__ */ new Map();
|
|
170829
|
+
var OPTIMISTIC_LEVEL_COOLDOWN_MS2 = 2e3;
|
|
170819
170830
|
var FeaturedBase9 = LevelControlServer.with("OnOff");
|
|
170820
170831
|
var SpeakerLevelControlServerBase = class extends FeaturedBase9 {
|
|
170821
170832
|
async initialize() {
|
|
@@ -170851,10 +170862,15 @@ var SpeakerLevelControlServerBase = class extends FeaturedBase9 {
|
|
|
170851
170862
|
logger175.debug(
|
|
170852
170863
|
`[${entityId}] Volume update: HA=${currentLevelPercent != null ? Math.round(currentLevelPercent * 100) : "null"}% -> currentLevel=${currentLevel}`
|
|
170853
170864
|
);
|
|
170865
|
+
const lastOptimistic = optimisticLevelTimestamps2.get(entity.entity_id);
|
|
170866
|
+
const inCooldown = lastOptimistic != null && Date.now() - lastOptimistic < OPTIMISTIC_LEVEL_COOLDOWN_MS2;
|
|
170867
|
+
if (inCooldown && currentLevel != null) {
|
|
170868
|
+
currentLevel = null;
|
|
170869
|
+
}
|
|
170854
170870
|
applyPatchState(this.state, {
|
|
170855
170871
|
minLevel,
|
|
170856
170872
|
maxLevel,
|
|
170857
|
-
currentLevel
|
|
170873
|
+
...currentLevel != null ? { currentLevel } : {}
|
|
170858
170874
|
});
|
|
170859
170875
|
}
|
|
170860
170876
|
async moveToLevel(request) {
|
|
@@ -170897,6 +170913,7 @@ var SpeakerLevelControlServerBase = class extends FeaturedBase9 {
|
|
|
170897
170913
|
return;
|
|
170898
170914
|
}
|
|
170899
170915
|
this.state.currentLevel = level;
|
|
170916
|
+
optimisticLevelTimestamps2.set(entityId, Date.now());
|
|
170900
170917
|
homeAssistant.callAction(
|
|
170901
170918
|
config10.moveToLevelPercent(levelPercent, this.agent)
|
|
170902
170919
|
);
|