@riddix/hamh 2.1.0-alpha.555 → 2.1.0-alpha.557
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
|
@@ -147448,6 +147448,7 @@ import { hideBin } from "yargs/helpers";
|
|
|
147448
147448
|
init_esm6();
|
|
147449
147449
|
|
|
147450
147450
|
// src/commands/start/start-handler.ts
|
|
147451
|
+
init_esm();
|
|
147451
147452
|
import * as ws from "ws";
|
|
147452
147453
|
|
|
147453
147454
|
// src/api/web-api.ts
|
|
@@ -148445,14 +148446,17 @@ function deviceImageApi(storageLocation, haRegistry) {
|
|
|
148445
148446
|
}
|
|
148446
148447
|
|
|
148447
148448
|
// src/api/diagnostic-api.ts
|
|
148448
|
-
import
|
|
148449
|
+
import os2 from "node:os";
|
|
148449
148450
|
import express6 from "express";
|
|
148450
148451
|
|
|
148451
148452
|
// src/api/logs-api.ts
|
|
148453
|
+
import os from "node:os";
|
|
148452
148454
|
import express5 from "express";
|
|
148455
|
+
var totalMemMB = Math.round(os.totalmem() / 1024 / 1024);
|
|
148456
|
+
var defaultMaxSize = totalMemMB < 2048 ? 200 : 1e3;
|
|
148453
148457
|
var logBuffer = {
|
|
148454
148458
|
entries: [],
|
|
148455
|
-
maxSize:
|
|
148459
|
+
maxSize: defaultMaxSize
|
|
148456
148460
|
};
|
|
148457
148461
|
function addLogEntry(entry) {
|
|
148458
148462
|
logBuffer.entries.push(entry);
|
|
@@ -148629,13 +148633,13 @@ function diagnosticApi(bridgeService, haClient, haRegistry, version, startTime)
|
|
|
148629
148633
|
version,
|
|
148630
148634
|
uptime: Math.floor((Date.now() - startTime) / 1e3),
|
|
148631
148635
|
system: {
|
|
148632
|
-
platform:
|
|
148633
|
-
arch:
|
|
148636
|
+
platform: os2.platform(),
|
|
148637
|
+
arch: os2.arch(),
|
|
148634
148638
|
nodeVersion: process.version,
|
|
148635
148639
|
environment: detectEnvironment(),
|
|
148636
148640
|
memory: {
|
|
148637
|
-
totalMB: Math.round(
|
|
148638
|
-
freeMB: Math.round(
|
|
148641
|
+
totalMB: Math.round(os2.totalmem() / 1024 / 1024),
|
|
148642
|
+
freeMB: Math.round(os2.freemem() / 1024 / 1024),
|
|
148639
148643
|
heapUsedMB: Math.round(memUsage.heapUsed / 1024 / 1024),
|
|
148640
148644
|
heapTotalMB: Math.round(memUsage.heapTotal / 1024 / 1024),
|
|
148641
148645
|
rssMB: Math.round(memUsage.rss / 1024 / 1024)
|
|
@@ -150033,7 +150037,7 @@ function metricsApi(bridgeService, haClient, haRegistry, startTime) {
|
|
|
150033
150037
|
}
|
|
150034
150038
|
|
|
150035
150039
|
// src/api/network-diagnostic-api.ts
|
|
150036
|
-
import * as
|
|
150040
|
+
import * as os3 from "node:os";
|
|
150037
150041
|
import express13 from "express";
|
|
150038
150042
|
function networkDiagnosticApi(mdnsInterface, mdnsIpv4) {
|
|
150039
150043
|
const router = express13.Router();
|
|
@@ -150044,7 +150048,7 @@ function networkDiagnosticApi(mdnsInterface, mdnsIpv4) {
|
|
|
150044
150048
|
return router;
|
|
150045
150049
|
}
|
|
150046
150050
|
function getNetworkInterfaces() {
|
|
150047
|
-
const raw =
|
|
150051
|
+
const raw = os3.networkInterfaces();
|
|
150048
150052
|
const result = [];
|
|
150049
150053
|
for (const [name, addrs] of Object.entries(raw)) {
|
|
150050
150054
|
if (!addrs) continue;
|
|
@@ -150910,7 +150914,7 @@ function settingsApi(settingsStorage, envAuth) {
|
|
|
150910
150914
|
// src/api/system-api.ts
|
|
150911
150915
|
init_esm();
|
|
150912
150916
|
import { exec } from "node:child_process";
|
|
150913
|
-
import
|
|
150917
|
+
import os4 from "node:os";
|
|
150914
150918
|
import { promisify } from "node:util";
|
|
150915
150919
|
import v8 from "node:v8";
|
|
150916
150920
|
import express15 from "express";
|
|
@@ -150966,22 +150970,22 @@ function systemApi(version) {
|
|
|
150966
150970
|
});
|
|
150967
150971
|
router.get("/info", async (_req, res) => {
|
|
150968
150972
|
try {
|
|
150969
|
-
const totalMem =
|
|
150970
|
-
const freeMem =
|
|
150973
|
+
const totalMem = os4.totalmem();
|
|
150974
|
+
const freeMem = os4.freemem();
|
|
150971
150975
|
const usedMem = totalMem - freeMem;
|
|
150972
150976
|
const storageInfo = await getStorageInfo();
|
|
150973
|
-
const cpus =
|
|
150977
|
+
const cpus = os4.cpus();
|
|
150974
150978
|
const memUsage = process.memoryUsage();
|
|
150975
150979
|
const systemInfo = {
|
|
150976
150980
|
version,
|
|
150977
150981
|
nodeVersion: process.version,
|
|
150978
|
-
hostname:
|
|
150979
|
-
platform:
|
|
150980
|
-
arch:
|
|
150981
|
-
uptime:
|
|
150982
|
+
hostname: os4.hostname(),
|
|
150983
|
+
platform: os4.platform(),
|
|
150984
|
+
arch: os4.arch(),
|
|
150985
|
+
uptime: os4.uptime(),
|
|
150982
150986
|
cpuCount: cpus.length,
|
|
150983
150987
|
cpuModel: cpus[0]?.model || "Unknown",
|
|
150984
|
-
loadAvg:
|
|
150988
|
+
loadAvg: os4.loadavg(),
|
|
150985
150989
|
environment: detectEnvironment2(),
|
|
150986
150990
|
memory: {
|
|
150987
150991
|
total: totalMem,
|
|
@@ -151017,7 +151021,7 @@ function systemApi(version) {
|
|
|
151017
151021
|
}
|
|
151018
151022
|
function getNetworkInterfaces2() {
|
|
151019
151023
|
const interfaces = [];
|
|
151020
|
-
const networkInterfaces3 =
|
|
151024
|
+
const networkInterfaces3 = os4.networkInterfaces();
|
|
151021
151025
|
for (const [name, ifaceList] of Object.entries(networkInterfaces3)) {
|
|
151022
151026
|
if (!ifaceList) continue;
|
|
151023
151027
|
for (const iface of ifaceList) {
|
|
@@ -151046,7 +151050,7 @@ function getNetworkInterfaces2() {
|
|
|
151046
151050
|
async function getStorageInfo() {
|
|
151047
151051
|
try {
|
|
151048
151052
|
const pathToCheck = getDataPath();
|
|
151049
|
-
if (
|
|
151053
|
+
if (os4.platform() === "win32") {
|
|
151050
151054
|
return await getWindowsStorageInfo(pathToCheck);
|
|
151051
151055
|
} else {
|
|
151052
151056
|
return await getUnixStorageInfo(pathToCheck);
|
|
@@ -151636,7 +151640,7 @@ function mdns(env, options) {
|
|
|
151636
151640
|
// src/core/app/storage.ts
|
|
151637
151641
|
init_esm7();
|
|
151638
151642
|
import fs8 from "node:fs";
|
|
151639
|
-
import
|
|
151643
|
+
import os5 from "node:os";
|
|
151640
151644
|
import path8 from "node:path";
|
|
151641
151645
|
|
|
151642
151646
|
// src/core/app/storage/custom-storage.ts
|
|
@@ -151743,7 +151747,7 @@ function storage(environment, options) {
|
|
|
151743
151747
|
storageService.factory = (ns) => new CustomStorage(logger205, path8.resolve(location2, ns));
|
|
151744
151748
|
}
|
|
151745
151749
|
function resolveStorageLocation(storageLocation) {
|
|
151746
|
-
const homedir =
|
|
151750
|
+
const homedir = os5.homedir();
|
|
151747
151751
|
return storageLocation ? path8.resolve(storageLocation.replace(/^~\//, `${homedir}/`)) : path8.join(homedir, ".home-assistant-matter-hub");
|
|
151748
151752
|
}
|
|
151749
151753
|
|
|
@@ -151763,7 +151767,7 @@ function configureDefaultEnvironment(options) {
|
|
|
151763
151767
|
// src/core/app/options.ts
|
|
151764
151768
|
init_esm7();
|
|
151765
151769
|
import { createRequire } from "node:module";
|
|
151766
|
-
import
|
|
151770
|
+
import os6 from "node:os";
|
|
151767
151771
|
import path9 from "node:path";
|
|
151768
151772
|
function resolveAppVersion() {
|
|
151769
151773
|
try {
|
|
@@ -151829,7 +151833,7 @@ var Options = class {
|
|
|
151829
151833
|
}
|
|
151830
151834
|
resolveStorageLocation() {
|
|
151831
151835
|
const storageLocation = notEmpty(this.startOptions.storageLocation);
|
|
151832
|
-
const homedir =
|
|
151836
|
+
const homedir = os6.homedir();
|
|
151833
151837
|
return storageLocation ? path9.resolve(storageLocation.replace(/^~\//, `${homedir}/`)) : path9.join(homedir, ".home-assistant-matter-hub");
|
|
151834
151838
|
}
|
|
151835
151839
|
get bridgeService() {
|
|
@@ -152411,8 +152415,10 @@ import { getStates } from "home-assistant-js-websocket";
|
|
|
152411
152415
|
import { fromPairs, keyBy, keys, uniq, values } from "lodash-es";
|
|
152412
152416
|
|
|
152413
152417
|
// src/utils/log-memory.ts
|
|
152418
|
+
import os7 from "node:os";
|
|
152414
152419
|
import v82 from "node:v8";
|
|
152415
152420
|
var HEAP_PRESSURE_THRESHOLD = 0.85;
|
|
152421
|
+
var LOW_MEMORY_THRESHOLD_MB = 512;
|
|
152416
152422
|
function logMemoryUsage(log, context) {
|
|
152417
152423
|
const mem = process.memoryUsage();
|
|
152418
152424
|
const heapUsedMB = Math.round(mem.heapUsed / 1024 / 1024);
|
|
@@ -152426,6 +152432,21 @@ function isHeapUnderPressure() {
|
|
|
152426
152432
|
const stats = v82.getHeapStatistics();
|
|
152427
152433
|
return stats.used_heap_size / stats.heap_size_limit > HEAP_PRESSURE_THRESHOLD;
|
|
152428
152434
|
}
|
|
152435
|
+
function logStartupMemoryGuard(log) {
|
|
152436
|
+
const totalMB = Math.round(os7.totalmem() / 1024 / 1024);
|
|
152437
|
+
const freeMB = Math.round(os7.freemem() / 1024 / 1024);
|
|
152438
|
+
const heapLimitMB = Math.round(
|
|
152439
|
+
v82.getHeapStatistics().heap_size_limit / 1024 / 1024
|
|
152440
|
+
);
|
|
152441
|
+
log.info(
|
|
152442
|
+
`System memory: ${freeMB} MB free / ${totalMB} MB total, heap limit: ${heapLimitMB} MB`
|
|
152443
|
+
);
|
|
152444
|
+
if (freeMB < LOW_MEMORY_THRESHOLD_MB) {
|
|
152445
|
+
log.warn(
|
|
152446
|
+
`Low memory detected (${freeMB} MB free). HAMH typically needs 400-600 MB. Consider reducing the number of entities per bridge, stopping memory-heavy add-ons, or increasing available RAM. See the FAQ section 'The app keeps crashing or restarting' for details.`
|
|
152447
|
+
);
|
|
152448
|
+
}
|
|
152449
|
+
}
|
|
152429
152450
|
|
|
152430
152451
|
// src/services/home-assistant/home-assistant-registry.ts
|
|
152431
152452
|
init_retry();
|
|
@@ -175877,7 +175898,6 @@ var RvcRunModeServerBase = class extends RvcRunModeServer {
|
|
|
175877
175898
|
this.trySetCurrentArea(null);
|
|
175878
175899
|
this.completedAreas.clear();
|
|
175879
175900
|
this.lastCurrentArea = null;
|
|
175880
|
-
this.activeAreas = [];
|
|
175881
175901
|
} else if (newMode === 1 /* Cleaning */) {
|
|
175882
175902
|
if (this.activeAreas.length > 0 && this.lastCurrentArea === null) {
|
|
175883
175903
|
this.trySetCurrentArea(this.activeAreas[0]);
|
|
@@ -175902,7 +175922,8 @@ var RvcRunModeServerBase = class extends RvcRunModeServer {
|
|
|
175902
175922
|
if (!roomState || !roomState.state) return;
|
|
175903
175923
|
if (this.activeAreas.length === 0) return;
|
|
175904
175924
|
const serviceArea = this.agent.get(ServiceAreaBehavior);
|
|
175905
|
-
const
|
|
175925
|
+
const sensorAttrs = roomState.attributes;
|
|
175926
|
+
const segmentId = sensorAttrs.segment_id ?? sensorAttrs.room_id;
|
|
175906
175927
|
const roomName = roomState.state;
|
|
175907
175928
|
let matchedAreaId = null;
|
|
175908
175929
|
if (segmentId != null) {
|
|
@@ -175918,7 +175939,12 @@ var RvcRunModeServerBase = class extends RvcRunModeServer {
|
|
|
175918
175939
|
matchedAreaId = area.areaId;
|
|
175919
175940
|
}
|
|
175920
175941
|
}
|
|
175921
|
-
if (matchedAreaId === null)
|
|
175942
|
+
if (matchedAreaId === null) {
|
|
175943
|
+
logger189.debug(
|
|
175944
|
+
`currentRoom sensor: no match for "${roomName}" (segmentId=${segmentId}), activeAreas=[${this.activeAreas.join(", ")}]`
|
|
175945
|
+
);
|
|
175946
|
+
return;
|
|
175947
|
+
}
|
|
175922
175948
|
if (matchedAreaId === this.lastCurrentArea) return;
|
|
175923
175949
|
if (this.lastCurrentArea !== null) {
|
|
175924
175950
|
this.completedAreas.add(this.lastCurrentArea);
|
|
@@ -176042,6 +176068,9 @@ var RvcRunModeServerBase = class extends RvcRunModeServer {
|
|
|
176042
176068
|
}
|
|
176043
176069
|
case 0 /* Idle */:
|
|
176044
176070
|
this.trySetCurrentArea(null);
|
|
176071
|
+
this.completedAreas.clear();
|
|
176072
|
+
this.lastCurrentArea = null;
|
|
176073
|
+
this.activeAreas = [];
|
|
176045
176074
|
homeAssistant.callAction(
|
|
176046
176075
|
this.state.config.returnToBase(void 0, this.agent)
|
|
176047
176076
|
);
|
|
@@ -176663,7 +176692,8 @@ var vacuumRvcRunModeConfig = {
|
|
|
176663
176692
|
VacuumState.segment_cleaning,
|
|
176664
176693
|
VacuumState.zone_cleaning,
|
|
176665
176694
|
VacuumState.spot_cleaning,
|
|
176666
|
-
VacuumState.mop_cleaning
|
|
176695
|
+
VacuumState.mop_cleaning,
|
|
176696
|
+
VacuumState.paused
|
|
176667
176697
|
];
|
|
176668
176698
|
const isCleaning = cleaningStates.includes(state);
|
|
176669
176699
|
logger192.debug(
|
|
@@ -177953,7 +177983,7 @@ var VacuumRvcOperationalStateServer = RvcOperationalStateServer2({
|
|
|
177953
177983
|
if (isCharging(entity)) {
|
|
177954
177984
|
operationalState = RvcOperationalState3.OperationalState.Charging;
|
|
177955
177985
|
} else {
|
|
177956
|
-
operationalState = RvcOperationalState3.OperationalState.
|
|
177986
|
+
operationalState = RvcOperationalState3.OperationalState.Stopped;
|
|
177957
177987
|
}
|
|
177958
177988
|
} else if (state === VacuumState.error || state === "unavailable") {
|
|
177959
177989
|
operationalState = RvcOperationalState3.OperationalState.Error;
|
|
@@ -177964,8 +177994,8 @@ var VacuumRvcOperationalStateServer = RvcOperationalStateServer2({
|
|
|
177964
177994
|
);
|
|
177965
177995
|
operationalState = RvcOperationalState3.OperationalState.Running;
|
|
177966
177996
|
} else {
|
|
177967
|
-
logger196.info(`Unknown vacuum state "${state}", treating as
|
|
177968
|
-
operationalState = RvcOperationalState3.OperationalState.
|
|
177997
|
+
logger196.info(`Unknown vacuum state "${state}", treating as Stopped`);
|
|
177998
|
+
operationalState = RvcOperationalState3.OperationalState.Stopped;
|
|
177969
177999
|
}
|
|
177970
178000
|
}
|
|
177971
178001
|
logger196.debug(
|
|
@@ -181698,6 +181728,7 @@ async function startHandler(startOptions, webUiDist) {
|
|
|
181698
181728
|
patchLevelControlTlv();
|
|
181699
181729
|
const options = new Options({ ...startOptions, webUiDist });
|
|
181700
181730
|
const rootEnv = configureDefaultEnvironment(options);
|
|
181731
|
+
logStartupMemoryGuard(Logger.get("Startup"));
|
|
181701
181732
|
const appEnvironment = await AppEnvironment.create(rootEnv, options);
|
|
181702
181733
|
registerFinalErrorHandlers();
|
|
181703
181734
|
const bridgeService$ = appEnvironment.load(BridgeService);
|