@riddix/hamh 2.1.0-alpha.536 → 2.1.0-alpha.537
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
|
@@ -147451,7 +147451,7 @@ import * as ws from "ws";
|
|
|
147451
147451
|
|
|
147452
147452
|
// src/api/web-api.ts
|
|
147453
147453
|
init_service();
|
|
147454
|
-
import
|
|
147454
|
+
import express17 from "express";
|
|
147455
147455
|
import basicAuth from "express-basic-auth";
|
|
147456
147456
|
import AccessControl5 from "express-ip-access-control";
|
|
147457
147457
|
import nocache from "nocache";
|
|
@@ -148777,7 +148777,8 @@ function healthApi(bridgeService, haClient, version, startTime) {
|
|
|
148777
148777
|
connectivity: {
|
|
148778
148778
|
totalSessions: sessionInfo.totalSessions,
|
|
148779
148779
|
totalSubscriptions: sessionInfo.totalSubscriptions,
|
|
148780
|
-
sessions: sessionInfo.sessions
|
|
148780
|
+
sessions: sessionInfo.sessions,
|
|
148781
|
+
fabricSummary: sessionInfo.fabrics
|
|
148781
148782
|
}
|
|
148782
148783
|
};
|
|
148783
148784
|
});
|
|
@@ -150020,9 +150021,164 @@ function metricsApi(bridgeService, haClient, haRegistry, startTime) {
|
|
|
150020
150021
|
return router;
|
|
150021
150022
|
}
|
|
150022
150023
|
|
|
150024
|
+
// src/api/network-diagnostic-api.ts
|
|
150025
|
+
import * as os2 from "node:os";
|
|
150026
|
+
import express13 from "express";
|
|
150027
|
+
function networkDiagnosticApi(mdnsInterface, mdnsIpv4) {
|
|
150028
|
+
const router = express13.Router();
|
|
150029
|
+
router.get("/", (_, res) => {
|
|
150030
|
+
const result = runDiagnostics(mdnsInterface, mdnsIpv4);
|
|
150031
|
+
res.json(result);
|
|
150032
|
+
});
|
|
150033
|
+
return router;
|
|
150034
|
+
}
|
|
150035
|
+
function getNetworkInterfaces() {
|
|
150036
|
+
const raw = os2.networkInterfaces();
|
|
150037
|
+
const result = [];
|
|
150038
|
+
for (const [name, addrs] of Object.entries(raw)) {
|
|
150039
|
+
if (!addrs) continue;
|
|
150040
|
+
const info = {
|
|
150041
|
+
name,
|
|
150042
|
+
ipv4: [],
|
|
150043
|
+
ipv6: [],
|
|
150044
|
+
mac: addrs[0]?.mac ?? "00:00:00:00:00:00",
|
|
150045
|
+
internal: addrs[0]?.internal ?? false
|
|
150046
|
+
};
|
|
150047
|
+
for (const addr of addrs) {
|
|
150048
|
+
if (addr.family === "IPv4") {
|
|
150049
|
+
info.ipv4.push(addr.address);
|
|
150050
|
+
} else if (addr.family === "IPv6") {
|
|
150051
|
+
info.ipv6.push(addr.address);
|
|
150052
|
+
}
|
|
150053
|
+
}
|
|
150054
|
+
result.push(info);
|
|
150055
|
+
}
|
|
150056
|
+
return result;
|
|
150057
|
+
}
|
|
150058
|
+
function runDiagnostics(mdnsInterface, mdnsIpv4) {
|
|
150059
|
+
const interfaces = getNetworkInterfaces();
|
|
150060
|
+
const checks = [];
|
|
150061
|
+
const external = interfaces.filter((i) => !i.internal);
|
|
150062
|
+
if (external.length === 0) {
|
|
150063
|
+
checks.push({
|
|
150064
|
+
name: "external_interface",
|
|
150065
|
+
status: "fail",
|
|
150066
|
+
message: "No external network interfaces found",
|
|
150067
|
+
detail: "Matter requires a network interface for mDNS discovery. Check Docker network mode (host networking recommended)."
|
|
150068
|
+
});
|
|
150069
|
+
} else {
|
|
150070
|
+
checks.push({
|
|
150071
|
+
name: "external_interface",
|
|
150072
|
+
status: "pass",
|
|
150073
|
+
message: `${external.length} external interface(s) available`,
|
|
150074
|
+
detail: external.map((i) => i.name).join(", ")
|
|
150075
|
+
});
|
|
150076
|
+
}
|
|
150077
|
+
const ipv6Interfaces = external.filter((i) => i.ipv6.length > 0);
|
|
150078
|
+
if (ipv6Interfaces.length === 0) {
|
|
150079
|
+
checks.push({
|
|
150080
|
+
name: "ipv6_available",
|
|
150081
|
+
status: "warn",
|
|
150082
|
+
message: "No IPv6 addresses found on external interfaces",
|
|
150083
|
+
detail: "Matter primarily uses IPv6 for communication. Some controllers may require it. Ensure IPv6 is enabled on your network."
|
|
150084
|
+
});
|
|
150085
|
+
} else {
|
|
150086
|
+
const linkLocal = ipv6Interfaces.filter(
|
|
150087
|
+
(i) => i.ipv6.some((addr) => addr.startsWith("fe80"))
|
|
150088
|
+
);
|
|
150089
|
+
const ula = ipv6Interfaces.filter(
|
|
150090
|
+
(i) => i.ipv6.some((addr) => addr.startsWith("fd"))
|
|
150091
|
+
);
|
|
150092
|
+
checks.push({
|
|
150093
|
+
name: "ipv6_available",
|
|
150094
|
+
status: "pass",
|
|
150095
|
+
message: `IPv6 available on ${ipv6Interfaces.length} interface(s)`,
|
|
150096
|
+
detail: `Link-local: ${linkLocal.length > 0 ? "yes" : "no"}, ULA (fd::): ${ula.length > 0 ? "yes" : "no"}`
|
|
150097
|
+
});
|
|
150098
|
+
}
|
|
150099
|
+
const ipv4Interfaces = external.filter((i) => i.ipv4.length > 0);
|
|
150100
|
+
if (ipv4Interfaces.length === 0) {
|
|
150101
|
+
checks.push({
|
|
150102
|
+
name: "ipv4_available",
|
|
150103
|
+
status: "warn",
|
|
150104
|
+
message: "No IPv4 addresses found on external interfaces",
|
|
150105
|
+
detail: "Some controllers use IPv4 for mDNS discovery."
|
|
150106
|
+
});
|
|
150107
|
+
} else {
|
|
150108
|
+
checks.push({
|
|
150109
|
+
name: "ipv4_available",
|
|
150110
|
+
status: "pass",
|
|
150111
|
+
message: `IPv4 available on ${ipv4Interfaces.length} interface(s)`,
|
|
150112
|
+
detail: ipv4Interfaces.flatMap((i) => i.ipv4.map((addr) => `${i.name}: ${addr}`)).join(", ")
|
|
150113
|
+
});
|
|
150114
|
+
}
|
|
150115
|
+
if (mdnsInterface) {
|
|
150116
|
+
const bound = interfaces.find((i) => i.name === mdnsInterface);
|
|
150117
|
+
if (!bound) {
|
|
150118
|
+
checks.push({
|
|
150119
|
+
name: "mdns_interface_binding",
|
|
150120
|
+
status: "fail",
|
|
150121
|
+
message: `Configured interface "${mdnsInterface}" not found`,
|
|
150122
|
+
detail: `Available interfaces: ${interfaces.map((i) => i.name).join(", ")}. Check the --mdns-network-interface option.`
|
|
150123
|
+
});
|
|
150124
|
+
} else if (bound.internal) {
|
|
150125
|
+
checks.push({
|
|
150126
|
+
name: "mdns_interface_binding",
|
|
150127
|
+
status: "warn",
|
|
150128
|
+
message: `mDNS bound to internal/loopback interface "${mdnsInterface}"`,
|
|
150129
|
+
detail: "Controllers on the network cannot discover the bridge via loopback. Bind to an external interface."
|
|
150130
|
+
});
|
|
150131
|
+
} else {
|
|
150132
|
+
checks.push({
|
|
150133
|
+
name: "mdns_interface_binding",
|
|
150134
|
+
status: "pass",
|
|
150135
|
+
message: `mDNS bound to "${mdnsInterface}"`,
|
|
150136
|
+
detail: `IPv4: ${bound.ipv4.join(", ") || "none"}, IPv6: ${bound.ipv6.join(", ") || "none"}`
|
|
150137
|
+
});
|
|
150138
|
+
}
|
|
150139
|
+
} else {
|
|
150140
|
+
checks.push({
|
|
150141
|
+
name: "mdns_interface_binding",
|
|
150142
|
+
status: "pass",
|
|
150143
|
+
message: "mDNS bound to all interfaces (default)"
|
|
150144
|
+
});
|
|
150145
|
+
}
|
|
150146
|
+
if (mdnsIpv4) {
|
|
150147
|
+
checks.push({
|
|
150148
|
+
name: "mdns_ipv4",
|
|
150149
|
+
status: "pass",
|
|
150150
|
+
message: "IPv4 mDNS enabled"
|
|
150151
|
+
});
|
|
150152
|
+
} else {
|
|
150153
|
+
checks.push({
|
|
150154
|
+
name: "mdns_ipv4",
|
|
150155
|
+
status: "warn",
|
|
150156
|
+
message: "IPv4 mDNS disabled (IPv6-only mode)",
|
|
150157
|
+
detail: "Some controllers (older Alexa, Google Home) may need IPv4 mDNS for discovery. Enable with --mdns-ipv4."
|
|
150158
|
+
});
|
|
150159
|
+
}
|
|
150160
|
+
if (external.length > 1 && !mdnsInterface) {
|
|
150161
|
+
checks.push({
|
|
150162
|
+
name: "multiple_interfaces",
|
|
150163
|
+
status: "warn",
|
|
150164
|
+
message: `${external.length} external interfaces detected without explicit binding`,
|
|
150165
|
+
detail: "mDNS will broadcast on all interfaces. If controllers are on a specific VLAN, consider binding to a specific interface with --mdns-network-interface."
|
|
150166
|
+
});
|
|
150167
|
+
}
|
|
150168
|
+
return {
|
|
150169
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
150170
|
+
interfaces,
|
|
150171
|
+
checks,
|
|
150172
|
+
matterConfig: {
|
|
150173
|
+
boundInterface: mdnsInterface ?? null,
|
|
150174
|
+
ipv4Enabled: mdnsIpv4
|
|
150175
|
+
}
|
|
150176
|
+
};
|
|
150177
|
+
}
|
|
150178
|
+
|
|
150023
150179
|
// src/api/plugin-api.ts
|
|
150024
150180
|
import * as nodePath from "node:path";
|
|
150025
|
-
import
|
|
150181
|
+
import express14 from "express";
|
|
150026
150182
|
|
|
150027
150183
|
// src/plugins/plugin-installer.ts
|
|
150028
150184
|
init_esm();
|
|
@@ -150398,7 +150554,7 @@ var BLOCKED_PREFIXES = [
|
|
|
150398
150554
|
"/root"
|
|
150399
150555
|
];
|
|
150400
150556
|
function pluginApi(bridgeService, storageLocation) {
|
|
150401
|
-
const router =
|
|
150557
|
+
const router = express14.Router();
|
|
150402
150558
|
const installer = new PluginInstaller(storageLocation);
|
|
150403
150559
|
const registry2 = new PluginRegistry(storageLocation);
|
|
150404
150560
|
router.get("/", (_req, res) => {
|
|
@@ -150743,10 +150899,10 @@ function settingsApi(settingsStorage, envAuth) {
|
|
|
150743
150899
|
// src/api/system-api.ts
|
|
150744
150900
|
init_esm();
|
|
150745
150901
|
import { exec } from "node:child_process";
|
|
150746
|
-
import
|
|
150902
|
+
import os3 from "node:os";
|
|
150747
150903
|
import { promisify } from "node:util";
|
|
150748
150904
|
import v8 from "node:v8";
|
|
150749
|
-
import
|
|
150905
|
+
import express15 from "express";
|
|
150750
150906
|
var execAsync = promisify(exec);
|
|
150751
150907
|
var logger144 = Logger.get("SystemApi");
|
|
150752
150908
|
function detectEnvironment2() {
|
|
@@ -150766,7 +150922,7 @@ function detectEnvironment2() {
|
|
|
150766
150922
|
return "Standalone";
|
|
150767
150923
|
}
|
|
150768
150924
|
function systemApi(version) {
|
|
150769
|
-
const router =
|
|
150925
|
+
const router = express15.Router();
|
|
150770
150926
|
router.get("/update-check", async (_req, res) => {
|
|
150771
150927
|
try {
|
|
150772
150928
|
const response = await fetch(
|
|
@@ -150799,22 +150955,22 @@ function systemApi(version) {
|
|
|
150799
150955
|
});
|
|
150800
150956
|
router.get("/info", async (_req, res) => {
|
|
150801
150957
|
try {
|
|
150802
|
-
const totalMem =
|
|
150803
|
-
const freeMem =
|
|
150958
|
+
const totalMem = os3.totalmem();
|
|
150959
|
+
const freeMem = os3.freemem();
|
|
150804
150960
|
const usedMem = totalMem - freeMem;
|
|
150805
150961
|
const storageInfo = await getStorageInfo();
|
|
150806
|
-
const cpus =
|
|
150962
|
+
const cpus = os3.cpus();
|
|
150807
150963
|
const memUsage = process.memoryUsage();
|
|
150808
150964
|
const systemInfo = {
|
|
150809
150965
|
version,
|
|
150810
150966
|
nodeVersion: process.version,
|
|
150811
|
-
hostname:
|
|
150812
|
-
platform:
|
|
150813
|
-
arch:
|
|
150814
|
-
uptime:
|
|
150967
|
+
hostname: os3.hostname(),
|
|
150968
|
+
platform: os3.platform(),
|
|
150969
|
+
arch: os3.arch(),
|
|
150970
|
+
uptime: os3.uptime(),
|
|
150815
150971
|
cpuCount: cpus.length,
|
|
150816
150972
|
cpuModel: cpus[0]?.model || "Unknown",
|
|
150817
|
-
loadAvg:
|
|
150973
|
+
loadAvg: os3.loadavg(),
|
|
150818
150974
|
environment: detectEnvironment2(),
|
|
150819
150975
|
memory: {
|
|
150820
150976
|
total: totalMem,
|
|
@@ -150823,7 +150979,7 @@ function systemApi(version) {
|
|
|
150823
150979
|
usagePercent: Math.round(usedMem / totalMem * 100)
|
|
150824
150980
|
},
|
|
150825
150981
|
network: {
|
|
150826
|
-
interfaces:
|
|
150982
|
+
interfaces: getNetworkInterfaces2()
|
|
150827
150983
|
},
|
|
150828
150984
|
storage: {
|
|
150829
150985
|
...storageInfo,
|
|
@@ -150848,10 +151004,10 @@ function systemApi(version) {
|
|
|
150848
151004
|
});
|
|
150849
151005
|
return router;
|
|
150850
151006
|
}
|
|
150851
|
-
function
|
|
151007
|
+
function getNetworkInterfaces2() {
|
|
150852
151008
|
const interfaces = [];
|
|
150853
|
-
const
|
|
150854
|
-
for (const [name, ifaceList] of Object.entries(
|
|
151009
|
+
const networkInterfaces3 = os3.networkInterfaces();
|
|
151010
|
+
for (const [name, ifaceList] of Object.entries(networkInterfaces3)) {
|
|
150855
151011
|
if (!ifaceList) continue;
|
|
150856
151012
|
for (const iface of ifaceList) {
|
|
150857
151013
|
const family = String(iface.family);
|
|
@@ -150879,7 +151035,7 @@ function getNetworkInterfaces() {
|
|
|
150879
151035
|
async function getStorageInfo() {
|
|
150880
151036
|
try {
|
|
150881
151037
|
const pathToCheck = getDataPath();
|
|
150882
|
-
if (
|
|
151038
|
+
if (os3.platform() === "win32") {
|
|
150883
151039
|
return await getWindowsStorageInfo(pathToCheck);
|
|
150884
151040
|
} else {
|
|
150885
151041
|
return await getUnixStorageInfo(pathToCheck);
|
|
@@ -150956,14 +151112,14 @@ async function getUnixStorageInfo(path14) {
|
|
|
150956
151112
|
// src/api/web-ui.ts
|
|
150957
151113
|
import fs6 from "node:fs";
|
|
150958
151114
|
import path7 from "node:path";
|
|
150959
|
-
import
|
|
151115
|
+
import express16 from "express";
|
|
150960
151116
|
function webUi(dist) {
|
|
150961
|
-
const router =
|
|
151117
|
+
const router = express16.Router();
|
|
150962
151118
|
if (dist) {
|
|
150963
151119
|
const index = replaceBase(dist);
|
|
150964
151120
|
router.get("/", index);
|
|
150965
151121
|
router.get("/index.html", index);
|
|
150966
|
-
router.use(
|
|
151122
|
+
router.use(express16.static(dist));
|
|
150967
151123
|
router.get(/.*/, index);
|
|
150968
151124
|
}
|
|
150969
151125
|
return router;
|
|
@@ -151144,8 +151300,8 @@ var WebApi = class extends Service {
|
|
|
151144
151300
|
return this.wsApi;
|
|
151145
151301
|
}
|
|
151146
151302
|
async initialize() {
|
|
151147
|
-
const api =
|
|
151148
|
-
api.use(
|
|
151303
|
+
const api = express17.Router();
|
|
151304
|
+
api.use(express17.json()).use(nocache()).use("/matter", matterApi(this.bridgeService, this.haRegistry)).use(
|
|
151149
151305
|
"/health",
|
|
151150
151306
|
healthApi(
|
|
151151
151307
|
this.bridgeService,
|
|
@@ -151185,6 +151341,12 @@ var WebApi = class extends Service {
|
|
|
151185
151341
|
).use(
|
|
151186
151342
|
"/plugins",
|
|
151187
151343
|
pluginApi(this.bridgeService, this.props.storageLocation)
|
|
151344
|
+
).use(
|
|
151345
|
+
"/network",
|
|
151346
|
+
networkDiagnosticApi(
|
|
151347
|
+
this.props.mdnsInterface,
|
|
151348
|
+
this.props.mdnsIpv4 ?? true
|
|
151349
|
+
)
|
|
151188
151350
|
);
|
|
151189
151351
|
const middlewares = [
|
|
151190
151352
|
this.accessLogger,
|
|
@@ -151210,9 +151372,9 @@ var WebApi = class extends Service {
|
|
|
151210
151372
|
})
|
|
151211
151373
|
);
|
|
151212
151374
|
}
|
|
151213
|
-
const appRouter =
|
|
151375
|
+
const appRouter = express17.Router();
|
|
151214
151376
|
appRouter.use(...middlewares).use("/api", api).use(webUi(this.props.webUiDist));
|
|
151215
|
-
this.app =
|
|
151377
|
+
this.app = express17();
|
|
151216
151378
|
const basePath = this.props.basePath;
|
|
151217
151379
|
if (basePath !== "/") {
|
|
151218
151380
|
this.log.info(`Base path configured: ${basePath}`);
|
|
@@ -151463,7 +151625,7 @@ function mdns(env, options) {
|
|
|
151463
151625
|
// src/core/app/storage.ts
|
|
151464
151626
|
init_esm7();
|
|
151465
151627
|
import fs8 from "node:fs";
|
|
151466
|
-
import
|
|
151628
|
+
import os4 from "node:os";
|
|
151467
151629
|
import path8 from "node:path";
|
|
151468
151630
|
|
|
151469
151631
|
// src/core/app/storage/custom-storage.ts
|
|
@@ -151570,7 +151732,7 @@ function storage(environment, options) {
|
|
|
151570
151732
|
storageService.factory = (ns) => new CustomStorage(logger204, path8.resolve(location2, ns));
|
|
151571
151733
|
}
|
|
151572
151734
|
function resolveStorageLocation(storageLocation) {
|
|
151573
|
-
const homedir =
|
|
151735
|
+
const homedir = os4.homedir();
|
|
151574
151736
|
return storageLocation ? path8.resolve(storageLocation.replace(/^~\//, `${homedir}/`)) : path8.join(homedir, ".home-assistant-matter-hub");
|
|
151575
151737
|
}
|
|
151576
151738
|
|
|
@@ -151590,7 +151752,7 @@ function configureDefaultEnvironment(options) {
|
|
|
151590
151752
|
// src/core/app/options.ts
|
|
151591
151753
|
init_esm7();
|
|
151592
151754
|
import { createRequire } from "node:module";
|
|
151593
|
-
import
|
|
151755
|
+
import os5 from "node:os";
|
|
151594
151756
|
import path9 from "node:path";
|
|
151595
151757
|
function resolveAppVersion() {
|
|
151596
151758
|
try {
|
|
@@ -151649,12 +151811,14 @@ var Options = class {
|
|
|
151649
151811
|
version: resolveAppVersion(),
|
|
151650
151812
|
storageLocation: this.resolveStorageLocation(),
|
|
151651
151813
|
basePath: normalizeBasePath(this.startOptions.httpBasePath),
|
|
151652
|
-
auth
|
|
151814
|
+
auth,
|
|
151815
|
+
mdnsInterface: notEmpty(this.startOptions.mdnsNetworkInterface),
|
|
151816
|
+
mdnsIpv4: true
|
|
151653
151817
|
};
|
|
151654
151818
|
}
|
|
151655
151819
|
resolveStorageLocation() {
|
|
151656
151820
|
const storageLocation = notEmpty(this.startOptions.storageLocation);
|
|
151657
|
-
const homedir =
|
|
151821
|
+
const homedir = os5.homedir();
|
|
151658
151822
|
return storageLocation ? path9.resolve(storageLocation.replace(/^~\//, `${homedir}/`)) : path9.join(homedir, ".home-assistant-matter-hub");
|
|
151659
151823
|
}
|
|
151660
151824
|
get bridgeService() {
|
|
@@ -166954,25 +167118,44 @@ var Bridge = class {
|
|
|
166954
167118
|
const sessionManager = this.server.env.get(SessionManager);
|
|
166955
167119
|
const sessions = [...sessionManager.sessions];
|
|
166956
167120
|
let totalSubscriptions = 0;
|
|
167121
|
+
const fabricMap = /* @__PURE__ */ new Map();
|
|
166957
167122
|
const sessionList = sessions.map((s) => {
|
|
166958
167123
|
const subCount = s.subscriptions.size;
|
|
166959
167124
|
totalSubscriptions += subCount;
|
|
167125
|
+
const fi = typeof s.fabric?.fabricIndex === "number" ? s.fabric.fabricIndex : null;
|
|
167126
|
+
if (fi !== null) {
|
|
167127
|
+
const existing = fabricMap.get(fi) ?? {
|
|
167128
|
+
sessions: 0,
|
|
167129
|
+
subscriptions: 0
|
|
167130
|
+
};
|
|
167131
|
+
existing.sessions++;
|
|
167132
|
+
existing.subscriptions += subCount;
|
|
167133
|
+
fabricMap.set(fi, existing);
|
|
167134
|
+
}
|
|
166960
167135
|
return {
|
|
166961
167136
|
id: s.id,
|
|
166962
167137
|
peerNodeId: String(s.peerNodeId),
|
|
167138
|
+
fabricIndex: fi,
|
|
166963
167139
|
subscriptionCount: subCount
|
|
166964
167140
|
};
|
|
166965
167141
|
});
|
|
167142
|
+
const fabrics = [...fabricMap.entries()].map(([fabricIndex, data]) => ({
|
|
167143
|
+
fabricIndex,
|
|
167144
|
+
sessions: data.sessions,
|
|
167145
|
+
subscriptions: data.subscriptions
|
|
167146
|
+
}));
|
|
166966
167147
|
return {
|
|
166967
167148
|
sessions: sessionList,
|
|
166968
167149
|
totalSessions: sessions.length,
|
|
166969
|
-
totalSubscriptions
|
|
167150
|
+
totalSubscriptions,
|
|
167151
|
+
fabrics
|
|
166970
167152
|
};
|
|
166971
167153
|
} catch {
|
|
166972
167154
|
return {
|
|
166973
167155
|
sessions: [],
|
|
166974
167156
|
totalSessions: 0,
|
|
166975
|
-
totalSubscriptions: 0
|
|
167157
|
+
totalSubscriptions: 0,
|
|
167158
|
+
fabrics: []
|
|
166976
167159
|
};
|
|
166977
167160
|
}
|
|
166978
167161
|
}
|
|
@@ -167617,13 +167800,137 @@ function hash(maxLength, value) {
|
|
|
167617
167800
|
return trimToLength(value, maxLength, suffix);
|
|
167618
167801
|
}
|
|
167619
167802
|
|
|
167803
|
+
// src/matter/behaviors/electrical-energy-measurement-server.ts
|
|
167804
|
+
init_esm();
|
|
167805
|
+
|
|
167806
|
+
// ../../node_modules/.pnpm/@matter+main@0.16.10/node_modules/@matter/main/dist/esm/clusters.js
|
|
167807
|
+
init_nodejs();
|
|
167808
|
+
init_clusters();
|
|
167809
|
+
|
|
167810
|
+
// src/matter/behaviors/electrical-energy-measurement-server.ts
|
|
167811
|
+
init_home_assistant_entity_behavior();
|
|
167812
|
+
var logger164 = Logger.get("ElectricalEnergyMeasurementServer");
|
|
167813
|
+
var FeaturedBase = ElectricalEnergyMeasurementServer.with("CumulativeEnergy", "ImportedEnergy");
|
|
167814
|
+
var ElectricalEnergyMeasurementServerBase = class extends FeaturedBase {
|
|
167815
|
+
async initialize() {
|
|
167816
|
+
await super.initialize();
|
|
167817
|
+
const homeAssistant = await this.agent.load(HomeAssistantEntityBehavior);
|
|
167818
|
+
const entityId = homeAssistant.entityId;
|
|
167819
|
+
const energyEntity = homeAssistant.state.mapping?.energyEntity;
|
|
167820
|
+
if (energyEntity) {
|
|
167821
|
+
logger164.debug(
|
|
167822
|
+
`[${entityId}] ElectricalEnergyMeasurement using mapped energy entity: ${energyEntity}`
|
|
167823
|
+
);
|
|
167824
|
+
}
|
|
167825
|
+
this.update();
|
|
167826
|
+
this.reactTo(homeAssistant.onChange, this.update);
|
|
167827
|
+
}
|
|
167828
|
+
update() {
|
|
167829
|
+
const homeAssistant = this.agent.get(HomeAssistantEntityBehavior);
|
|
167830
|
+
const energyEntity = homeAssistant.state.mapping?.energyEntity;
|
|
167831
|
+
if (!energyEntity) return;
|
|
167832
|
+
const stateProvider = this.agent.env.get(EntityStateProvider);
|
|
167833
|
+
const energyKwh = stateProvider.getNumericState(energyEntity);
|
|
167834
|
+
if (energyKwh == null) return;
|
|
167835
|
+
const energyMwh = Math.round(energyKwh * 1e6);
|
|
167836
|
+
const energyImported = { energy: energyMwh };
|
|
167837
|
+
applyPatchState(this.state, {
|
|
167838
|
+
cumulativeEnergyImported: energyImported
|
|
167839
|
+
});
|
|
167840
|
+
this.events.cumulativeEnergyMeasured?.emit(
|
|
167841
|
+
{ energyImported, energyExported: void 0 },
|
|
167842
|
+
this.context
|
|
167843
|
+
);
|
|
167844
|
+
}
|
|
167845
|
+
};
|
|
167846
|
+
((ElectricalEnergyMeasurementServerBase2) => {
|
|
167847
|
+
class State extends FeaturedBase.State {
|
|
167848
|
+
}
|
|
167849
|
+
ElectricalEnergyMeasurementServerBase2.State = State;
|
|
167850
|
+
})(ElectricalEnergyMeasurementServerBase || (ElectricalEnergyMeasurementServerBase = {}));
|
|
167851
|
+
var HaElectricalEnergyMeasurementServer = ElectricalEnergyMeasurementServerBase.set({
|
|
167852
|
+
accuracy: {
|
|
167853
|
+
measurementType: ElectricalPowerMeasurement3.MeasurementType.ElectricalEnergy,
|
|
167854
|
+
measured: true,
|
|
167855
|
+
minMeasuredValue: -1e6,
|
|
167856
|
+
// -1000Wh, allows 0 and all positive values
|
|
167857
|
+
maxMeasuredValue: 1e11,
|
|
167858
|
+
// 100MWh in mWh
|
|
167859
|
+
accuracyRanges: [
|
|
167860
|
+
{
|
|
167861
|
+
rangeMin: -1e6,
|
|
167862
|
+
rangeMax: 1e11,
|
|
167863
|
+
fixedMax: 1e3
|
|
167864
|
+
// 1Wh accuracy
|
|
167865
|
+
}
|
|
167866
|
+
]
|
|
167867
|
+
}
|
|
167868
|
+
});
|
|
167869
|
+
|
|
167870
|
+
// src/matter/behaviors/electrical-power-measurement-server.ts
|
|
167871
|
+
init_esm();
|
|
167872
|
+
init_home_assistant_entity_behavior();
|
|
167873
|
+
var logger165 = Logger.get("ElectricalPowerMeasurementServer");
|
|
167874
|
+
var ElectricalPowerMeasurementServerBase = class extends ElectricalPowerMeasurementServer {
|
|
167875
|
+
async initialize() {
|
|
167876
|
+
await super.initialize();
|
|
167877
|
+
const homeAssistant = await this.agent.load(HomeAssistantEntityBehavior);
|
|
167878
|
+
const entityId = homeAssistant.entityId;
|
|
167879
|
+
const powerEntity = homeAssistant.state.mapping?.powerEntity;
|
|
167880
|
+
if (powerEntity) {
|
|
167881
|
+
logger165.debug(
|
|
167882
|
+
`[${entityId}] ElectricalPowerMeasurement using mapped power entity: ${powerEntity}`
|
|
167883
|
+
);
|
|
167884
|
+
}
|
|
167885
|
+
this.update();
|
|
167886
|
+
this.reactTo(homeAssistant.onChange, this.update);
|
|
167887
|
+
}
|
|
167888
|
+
update() {
|
|
167889
|
+
const homeAssistant = this.agent.get(HomeAssistantEntityBehavior);
|
|
167890
|
+
const powerEntity = homeAssistant.state.mapping?.powerEntity;
|
|
167891
|
+
if (!powerEntity) return;
|
|
167892
|
+
const stateProvider = this.agent.env.get(EntityStateProvider);
|
|
167893
|
+
const powerWatts = stateProvider.getNumericState(powerEntity);
|
|
167894
|
+
if (powerWatts == null) return;
|
|
167895
|
+
const activePower = Math.round(powerWatts * 1e3);
|
|
167896
|
+
applyPatchState(this.state, { activePower });
|
|
167897
|
+
}
|
|
167898
|
+
};
|
|
167899
|
+
((ElectricalPowerMeasurementServerBase2) => {
|
|
167900
|
+
class State extends ElectricalPowerMeasurementServer.State {
|
|
167901
|
+
}
|
|
167902
|
+
ElectricalPowerMeasurementServerBase2.State = State;
|
|
167903
|
+
})(ElectricalPowerMeasurementServerBase || (ElectricalPowerMeasurementServerBase = {}));
|
|
167904
|
+
var HaElectricalPowerMeasurementServer = ElectricalPowerMeasurementServerBase.set({
|
|
167905
|
+
powerMode: ElectricalPowerMeasurement3.PowerMode.Ac,
|
|
167906
|
+
numberOfMeasurementTypes: 1,
|
|
167907
|
+
accuracy: [
|
|
167908
|
+
{
|
|
167909
|
+
measurementType: ElectricalPowerMeasurement3.MeasurementType.ActivePower,
|
|
167910
|
+
measured: true,
|
|
167911
|
+
minMeasuredValue: -1e6,
|
|
167912
|
+
// -1000W, allows 0 and all positive values
|
|
167913
|
+
maxMeasuredValue: 1e8,
|
|
167914
|
+
// 100kW in mW
|
|
167915
|
+
accuracyRanges: [
|
|
167916
|
+
{
|
|
167917
|
+
rangeMin: -1e6,
|
|
167918
|
+
rangeMax: 1e8,
|
|
167919
|
+
fixedMax: 1e3
|
|
167920
|
+
// 1W accuracy
|
|
167921
|
+
}
|
|
167922
|
+
]
|
|
167923
|
+
}
|
|
167924
|
+
]
|
|
167925
|
+
});
|
|
167926
|
+
|
|
167620
167927
|
// src/matter/endpoints/composed/composed-air-purifier-endpoint.ts
|
|
167621
167928
|
init_home_assistant_entity_behavior();
|
|
167622
167929
|
|
|
167623
167930
|
// src/matter/behaviors/humidity-measurement-server.ts
|
|
167624
167931
|
init_esm();
|
|
167625
167932
|
init_home_assistant_entity_behavior();
|
|
167626
|
-
var
|
|
167933
|
+
var logger166 = Logger.get("HumidityMeasurementServer");
|
|
167627
167934
|
var HumidityMeasurementServerBase = class extends RelativeHumidityMeasurementServer {
|
|
167628
167935
|
async initialize() {
|
|
167629
167936
|
await super.initialize();
|
|
@@ -167636,7 +167943,7 @@ var HumidityMeasurementServerBase = class extends RelativeHumidityMeasurementSer
|
|
|
167636
167943
|
return;
|
|
167637
167944
|
}
|
|
167638
167945
|
const humidity = this.getHumidity(this.state.config, entity.state);
|
|
167639
|
-
|
|
167946
|
+
logger166.debug(
|
|
167640
167947
|
`Humidity ${entity.state.entity_id} raw=${entity.state.state} measuredValue=${humidity}`
|
|
167641
167948
|
);
|
|
167642
167949
|
applyPatchState(this.state, {
|
|
@@ -167665,16 +167972,10 @@ function HumidityMeasurementServer(config10) {
|
|
|
167665
167972
|
|
|
167666
167973
|
// src/matter/behaviors/power-source-server.ts
|
|
167667
167974
|
init_esm();
|
|
167668
|
-
|
|
167669
|
-
// ../../node_modules/.pnpm/@matter+main@0.16.10/node_modules/@matter/main/dist/esm/clusters.js
|
|
167670
|
-
init_nodejs();
|
|
167671
|
-
init_clusters();
|
|
167672
|
-
|
|
167673
|
-
// src/matter/behaviors/power-source-server.ts
|
|
167674
167975
|
init_home_assistant_entity_behavior();
|
|
167675
|
-
var
|
|
167676
|
-
var
|
|
167677
|
-
var PowerSourceServerBase = class extends
|
|
167976
|
+
var logger167 = Logger.get("PowerSourceServer");
|
|
167977
|
+
var FeaturedBase2 = PowerSourceServer.with("Battery", "Rechargeable");
|
|
167978
|
+
var PowerSourceServerBase = class extends FeaturedBase2 {
|
|
167678
167979
|
async initialize() {
|
|
167679
167980
|
await super.initialize();
|
|
167680
167981
|
const homeAssistant = await this.agent.load(HomeAssistantEntityBehavior);
|
|
@@ -167684,17 +167985,17 @@ var PowerSourceServerBase = class extends FeaturedBase {
|
|
|
167684
167985
|
applyPatchState(this.state, {
|
|
167685
167986
|
endpointList: [endpointNumber]
|
|
167686
167987
|
});
|
|
167687
|
-
|
|
167988
|
+
logger167.debug(
|
|
167688
167989
|
`[${entityId}] PowerSource initialized with endpointList=[${endpointNumber}]`
|
|
167689
167990
|
);
|
|
167690
167991
|
} else {
|
|
167691
|
-
|
|
167992
|
+
logger167.warn(
|
|
167692
167993
|
`[${entityId}] PowerSource endpoint number is null during initialize - endpointList will be empty!`
|
|
167693
167994
|
);
|
|
167694
167995
|
}
|
|
167695
167996
|
const batteryEntity = homeAssistant.state.mapping?.batteryEntity;
|
|
167696
167997
|
if (batteryEntity) {
|
|
167697
|
-
|
|
167998
|
+
logger167.debug(
|
|
167698
167999
|
`[${entityId}] PowerSource using mapped battery entity: ${batteryEntity}`
|
|
167699
168000
|
);
|
|
167700
168001
|
}
|
|
@@ -167745,7 +168046,7 @@ var PowerSourceServerBase = class extends FeaturedBase {
|
|
|
167745
168046
|
}
|
|
167746
168047
|
};
|
|
167747
168048
|
((PowerSourceServerBase2) => {
|
|
167748
|
-
class State extends
|
|
168049
|
+
class State extends FeaturedBase2.State {
|
|
167749
168050
|
config;
|
|
167750
168051
|
}
|
|
167751
168052
|
PowerSourceServerBase2.State = State;
|
|
@@ -167818,8 +168119,8 @@ function TemperatureMeasurementServer2(config10) {
|
|
|
167818
168119
|
|
|
167819
168120
|
// src/matter/behaviors/hepa-filter-monitoring-server.ts
|
|
167820
168121
|
init_home_assistant_entity_behavior();
|
|
167821
|
-
var
|
|
167822
|
-
var HepaFilterMonitoringServerBase = class extends
|
|
168122
|
+
var FeaturedBase3 = HepaFilterMonitoringServer.with("Condition", "Warning");
|
|
168123
|
+
var HepaFilterMonitoringServerBase = class extends FeaturedBase3 {
|
|
167823
168124
|
async initialize() {
|
|
167824
168125
|
this.state.condition = 100;
|
|
167825
168126
|
this.state.degradationDirection = ResourceMonitoring3.DegradationDirection.Down;
|
|
@@ -167856,7 +168157,7 @@ var HepaFilterMonitoringServerBase = class extends FeaturedBase2 {
|
|
|
167856
168157
|
}
|
|
167857
168158
|
};
|
|
167858
168159
|
((HepaFilterMonitoringServerBase2) => {
|
|
167859
|
-
class State extends
|
|
168160
|
+
class State extends FeaturedBase3.State {
|
|
167860
168161
|
config;
|
|
167861
168162
|
}
|
|
167862
168163
|
HepaFilterMonitoringServerBase2.State = State;
|
|
@@ -168021,9 +168322,9 @@ var OPTIMISTIC_TOLERANCE = 5;
|
|
|
168021
168322
|
function notifyLightTurnedOn(entityId) {
|
|
168022
168323
|
lastTurnOnTimestamps.set(entityId, Date.now());
|
|
168023
168324
|
}
|
|
168024
|
-
var
|
|
168025
|
-
var
|
|
168026
|
-
var LevelControlServerBase = class extends
|
|
168325
|
+
var logger168 = Logger.get("LevelControlServer");
|
|
168326
|
+
var FeaturedBase4 = LevelControlServer.with("OnOff", "Lighting");
|
|
168327
|
+
var LevelControlServerBase = class extends FeaturedBase4 {
|
|
168027
168328
|
pendingTransitionTime;
|
|
168028
168329
|
async initialize() {
|
|
168029
168330
|
if (this.state.currentLevel == null) {
|
|
@@ -168036,12 +168337,12 @@ var LevelControlServerBase = class extends FeaturedBase3 {
|
|
|
168036
168337
|
this.state.maxLevel = 254;
|
|
168037
168338
|
}
|
|
168038
168339
|
this.state.onLevel = null;
|
|
168039
|
-
|
|
168340
|
+
logger168.debug(`initialize: calling super.initialize()`);
|
|
168040
168341
|
try {
|
|
168041
168342
|
await super.initialize();
|
|
168042
|
-
|
|
168343
|
+
logger168.debug(`initialize: super.initialize() completed successfully`);
|
|
168043
168344
|
} catch (error) {
|
|
168044
|
-
|
|
168345
|
+
logger168.error(`initialize: super.initialize() FAILED:`, error);
|
|
168045
168346
|
throw error;
|
|
168046
168347
|
}
|
|
168047
168348
|
const homeAssistant = await this.agent.load(HomeAssistantEntityBehavior);
|
|
@@ -168117,7 +168418,7 @@ var LevelControlServerBase = class extends FeaturedBase3 {
|
|
|
168117
168418
|
const timeSinceTurnOn = lastTurnOn ? Date.now() - lastTurnOn : Infinity;
|
|
168118
168419
|
const isMaxBrightness = level >= this.maxLevel;
|
|
168119
168420
|
if (isMaxBrightness && timeSinceTurnOn < 200) {
|
|
168120
|
-
|
|
168421
|
+
logger168.debug(
|
|
168121
168422
|
`[${entityId}] Ignoring moveToLevel(${level}) - Alexa brightness reset detected (${timeSinceTurnOn}ms after turn-on)`
|
|
168122
168423
|
);
|
|
168123
168424
|
return;
|
|
@@ -168147,7 +168448,7 @@ var LevelControlServerBase = class extends FeaturedBase3 {
|
|
|
168147
168448
|
}
|
|
168148
168449
|
};
|
|
168149
168450
|
((LevelControlServerBase2) => {
|
|
168150
|
-
class State extends
|
|
168451
|
+
class State extends FeaturedBase4.State {
|
|
168151
168452
|
config;
|
|
168152
168453
|
}
|
|
168153
168454
|
LevelControlServerBase2.State = State;
|
|
@@ -168160,7 +168461,7 @@ function LevelControlServer2(config10) {
|
|
|
168160
168461
|
}
|
|
168161
168462
|
|
|
168162
168463
|
// src/matter/behaviors/on-off-server.ts
|
|
168163
|
-
var
|
|
168464
|
+
var logger169 = Logger.get("OnOffServer");
|
|
168164
168465
|
var optimisticOnOffState = /* @__PURE__ */ new Map();
|
|
168165
168466
|
var OPTIMISTIC_TIMEOUT_MS2 = 3e3;
|
|
168166
168467
|
var OnOffServerBase = class extends OnOffServer {
|
|
@@ -168200,7 +168501,7 @@ var OnOffServerBase = class extends OnOffServer {
|
|
|
168200
168501
|
if (!action) {
|
|
168201
168502
|
return;
|
|
168202
168503
|
}
|
|
168203
|
-
|
|
168504
|
+
logger169.info(`[${homeAssistant.entityId}] Turning ON -> ${action.action}`);
|
|
168204
168505
|
notifyLightTurnedOn(homeAssistant.entityId);
|
|
168205
168506
|
optimisticOnOffState.set(homeAssistant.entityId, {
|
|
168206
168507
|
expectedOnOff: true,
|
|
@@ -168223,7 +168524,7 @@ var OnOffServerBase = class extends OnOffServer {
|
|
|
168223
168524
|
if (!action) {
|
|
168224
168525
|
return;
|
|
168225
168526
|
}
|
|
168226
|
-
|
|
168527
|
+
logger169.info(`[${homeAssistant.entityId}] Turning OFF -> ${action.action}`);
|
|
168227
168528
|
optimisticOnOffState.set(homeAssistant.entityId, {
|
|
168228
168529
|
expectedOnOff: false,
|
|
168229
168530
|
timestamp: Date.now()
|
|
@@ -168253,11 +168554,11 @@ function setOptimisticOnOff(entityId, expectedOnOff) {
|
|
|
168253
168554
|
}
|
|
168254
168555
|
|
|
168255
168556
|
// src/matter/behaviors/fan-control-server.ts
|
|
168256
|
-
var
|
|
168557
|
+
var logger170 = Logger.get("FanControlServer");
|
|
168257
168558
|
var defaultStepSize = 33.33;
|
|
168258
168559
|
var minSpeedMax = 3;
|
|
168259
168560
|
var maxSpeedMax = 100;
|
|
168260
|
-
var
|
|
168561
|
+
var FeaturedBase5 = FanControlServer.with(
|
|
168261
168562
|
"Step",
|
|
168262
168563
|
"MultiSpeed",
|
|
168263
168564
|
"AirflowDirection",
|
|
@@ -168271,7 +168572,7 @@ var FeaturedBase4 = FanControlServer.with(
|
|
|
168271
168572
|
rockSupport: { rockUpDown: true },
|
|
168272
168573
|
windSupport: { naturalWind: true, sleepWind: true }
|
|
168273
168574
|
});
|
|
168274
|
-
var FanControlServerBase = class extends
|
|
168575
|
+
var FanControlServerBase = class extends FeaturedBase5 {
|
|
168275
168576
|
// Track last non-zero fan speed for restore on turn-on (#225)
|
|
168276
168577
|
lastNonZeroPercent = 0;
|
|
168277
168578
|
lastNonZeroSpeed = 0;
|
|
@@ -168612,7 +168913,7 @@ var FanControlServerBase = class extends FeaturedBase4 {
|
|
|
168612
168913
|
const entityId = this.agent.get(HomeAssistantEntityBehavior).entity.entity_id;
|
|
168613
168914
|
setOptimisticOnOff(entityId, on);
|
|
168614
168915
|
} catch (e) {
|
|
168615
|
-
|
|
168916
|
+
logger170.debug(
|
|
168616
168917
|
`syncOnOff(${on}) failed: ${e instanceof Error ? e.message : String(e)}`
|
|
168617
168918
|
);
|
|
168618
168919
|
}
|
|
@@ -168625,7 +168926,7 @@ var FanControlServerBase = class extends FeaturedBase4 {
|
|
|
168625
168926
|
}
|
|
168626
168927
|
};
|
|
168627
168928
|
((FanControlServerBase2) => {
|
|
168628
|
-
class State extends
|
|
168929
|
+
class State extends FeaturedBase5.State {
|
|
168629
168930
|
config;
|
|
168630
168931
|
}
|
|
168631
168932
|
FanControlServerBase2.State = State;
|
|
@@ -168700,7 +169001,7 @@ var FanOnOffServer = OnOffServer2({
|
|
|
168700
169001
|
});
|
|
168701
169002
|
|
|
168702
169003
|
// src/matter/endpoints/composed/composed-air-purifier-endpoint.ts
|
|
168703
|
-
var
|
|
169004
|
+
var logger171 = Logger.get("ComposedAirPurifierEndpoint");
|
|
168704
169005
|
var temperatureConfig = {
|
|
168705
169006
|
getValue(entity, agent) {
|
|
168706
169007
|
const fallbackUnit = agent.env.get(HomeAssistantConfig).unitSystem.temperature;
|
|
@@ -168814,11 +169115,19 @@ var ComposedAirPurifierEndpoint = class _ComposedAirPurifierEndpoint extends End
|
|
|
168814
169115
|
);
|
|
168815
169116
|
const parentMapping = {
|
|
168816
169117
|
entityId: primaryEntityId,
|
|
168817
|
-
...config10.batteryEntityId ? { batteryEntity: config10.batteryEntityId } : {}
|
|
169118
|
+
...config10.batteryEntityId ? { batteryEntity: config10.batteryEntityId } : {},
|
|
169119
|
+
...config10.powerEntityId ? { powerEntity: config10.powerEntityId } : {},
|
|
169120
|
+
...config10.energyEntityId ? { energyEntity: config10.energyEntityId } : {}
|
|
168818
169121
|
};
|
|
168819
169122
|
if (config10.batteryEntityId) {
|
|
168820
169123
|
parentType = parentType.with(PowerSourceServer2(batteryConfig));
|
|
168821
169124
|
}
|
|
169125
|
+
if (config10.powerEntityId) {
|
|
169126
|
+
parentType = parentType.with(HaElectricalPowerMeasurementServer);
|
|
169127
|
+
}
|
|
169128
|
+
if (config10.energyEntityId) {
|
|
169129
|
+
parentType = parentType.with(HaElectricalEnergyMeasurementServer);
|
|
169130
|
+
}
|
|
168822
169131
|
if (config10.areaName) {
|
|
168823
169132
|
const truncatedName = config10.areaName.length > 16 ? config10.areaName.substring(0, 16) : config10.areaName;
|
|
168824
169133
|
parentType = parentType.with(
|
|
@@ -168880,6 +169189,8 @@ var ComposedAirPurifierEndpoint = class _ComposedAirPurifierEndpoint extends End
|
|
|
168880
169189
|
if (config10.humidityEntityId) mappedIds.push(config10.humidityEntityId);
|
|
168881
169190
|
if (config10.mapping?.filterLifeEntity)
|
|
168882
169191
|
mappedIds.push(config10.mapping.filterLifeEntity);
|
|
169192
|
+
if (config10.powerEntityId) mappedIds.push(config10.powerEntityId);
|
|
169193
|
+
if (config10.energyEntityId) mappedIds.push(config10.energyEntityId);
|
|
168883
169194
|
const endpoint = new _ComposedAirPurifierEndpoint(
|
|
168884
169195
|
parentTypeWithState,
|
|
168885
169196
|
primaryEntityId,
|
|
@@ -168899,9 +169210,11 @@ var ComposedAirPurifierEndpoint = class _ComposedAirPurifierEndpoint extends End
|
|
|
168899
169210
|
config10.temperatureEntityId ? "+Temp" : "",
|
|
168900
169211
|
config10.humidityEntityId ? "+Hum" : "",
|
|
168901
169212
|
config10.batteryEntityId ? "+Bat" : "",
|
|
168902
|
-
hasFilterLife ? "+HEPA" : ""
|
|
169213
|
+
hasFilterLife ? "+HEPA" : "",
|
|
169214
|
+
config10.powerEntityId ? "+Pwr" : "",
|
|
169215
|
+
config10.energyEntityId ? "+Nrg" : ""
|
|
168903
169216
|
].filter(Boolean).join("");
|
|
168904
|
-
|
|
169217
|
+
logger171.info(
|
|
168905
169218
|
`Created composed air purifier ${primaryEntityId}: ${clusterLabels}`
|
|
168906
169219
|
);
|
|
168907
169220
|
return endpoint;
|
|
@@ -169001,7 +169314,7 @@ init_home_assistant_entity_behavior();
|
|
|
169001
169314
|
// src/matter/behaviors/pressure-measurement-server.ts
|
|
169002
169315
|
init_esm();
|
|
169003
169316
|
init_home_assistant_entity_behavior();
|
|
169004
|
-
var
|
|
169317
|
+
var logger172 = Logger.get("PressureMeasurementServer");
|
|
169005
169318
|
var MIN_PRESSURE = 300;
|
|
169006
169319
|
var MAX_PRESSURE = 1100;
|
|
169007
169320
|
var PressureMeasurementServerBase = class extends PressureMeasurementServer {
|
|
@@ -169029,7 +169342,7 @@ var PressureMeasurementServerBase = class extends PressureMeasurementServer {
|
|
|
169029
169342
|
}
|
|
169030
169343
|
const rounded = Math.round(value);
|
|
169031
169344
|
if (rounded < MIN_PRESSURE || rounded > MAX_PRESSURE) {
|
|
169032
|
-
|
|
169345
|
+
logger172.warn(
|
|
169033
169346
|
`Pressure value ${rounded} (raw: ${value}) for ${entity.entity_id} is outside valid range [${MIN_PRESSURE}-${MAX_PRESSURE}], ignoring`
|
|
169034
169347
|
);
|
|
169035
169348
|
return null;
|
|
@@ -169048,7 +169361,7 @@ function PressureMeasurementServer2(config10) {
|
|
|
169048
169361
|
}
|
|
169049
169362
|
|
|
169050
169363
|
// src/matter/endpoints/composed/composed-sensor-endpoint.ts
|
|
169051
|
-
var
|
|
169364
|
+
var logger173 = Logger.get("ComposedSensorEndpoint");
|
|
169052
169365
|
var temperatureConfig2 = {
|
|
169053
169366
|
getValue(entity, agent) {
|
|
169054
169367
|
const fallbackUnit = agent.env.get(HomeAssistantConfig).unitSystem.temperature;
|
|
@@ -169137,11 +169450,19 @@ var ComposedSensorEndpoint = class _ComposedSensorEndpoint extends Endpoint {
|
|
|
169137
169450
|
);
|
|
169138
169451
|
const mapping = {
|
|
169139
169452
|
entityId: primaryEntityId,
|
|
169140
|
-
...config10.batteryEntityId ? { batteryEntity: config10.batteryEntityId } : {}
|
|
169453
|
+
...config10.batteryEntityId ? { batteryEntity: config10.batteryEntityId } : {},
|
|
169454
|
+
...config10.powerEntityId ? { powerEntity: config10.powerEntityId } : {},
|
|
169455
|
+
...config10.energyEntityId ? { energyEntity: config10.energyEntityId } : {}
|
|
169141
169456
|
};
|
|
169142
169457
|
if (config10.batteryEntityId) {
|
|
169143
169458
|
parentType = parentType.with(PowerSourceServer2(batteryConfig2));
|
|
169144
169459
|
}
|
|
169460
|
+
if (config10.powerEntityId) {
|
|
169461
|
+
parentType = parentType.with(HaElectricalPowerMeasurementServer);
|
|
169462
|
+
}
|
|
169463
|
+
if (config10.energyEntityId) {
|
|
169464
|
+
parentType = parentType.with(HaElectricalEnergyMeasurementServer);
|
|
169465
|
+
}
|
|
169145
169466
|
if (config10.areaName) {
|
|
169146
169467
|
const truncatedName = config10.areaName.length > 16 ? config10.areaName.substring(0, 16) : config10.areaName;
|
|
169147
169468
|
parentType = parentType.with(
|
|
@@ -169198,6 +169519,8 @@ var ComposedSensorEndpoint = class _ComposedSensorEndpoint extends Endpoint {
|
|
|
169198
169519
|
const mappedIds = [];
|
|
169199
169520
|
if (config10.humidityEntityId) mappedIds.push(config10.humidityEntityId);
|
|
169200
169521
|
if (config10.pressureEntityId) mappedIds.push(config10.pressureEntityId);
|
|
169522
|
+
if (config10.powerEntityId) mappedIds.push(config10.powerEntityId);
|
|
169523
|
+
if (config10.energyEntityId) mappedIds.push(config10.energyEntityId);
|
|
169201
169524
|
const endpoint = new _ComposedSensorEndpoint(
|
|
169202
169525
|
parentTypeWithState,
|
|
169203
169526
|
primaryEntityId,
|
|
@@ -169212,8 +169535,8 @@ var ComposedSensorEndpoint = class _ComposedSensorEndpoint extends Endpoint {
|
|
|
169212
169535
|
if (config10.pressureEntityId && pressSub) {
|
|
169213
169536
|
endpoint.subEndpoints.set(config10.pressureEntityId, pressSub);
|
|
169214
169537
|
}
|
|
169215
|
-
|
|
169216
|
-
`Created composed sensor ${primaryEntityId} with ${parts.length} sub-endpoint(s): T${humSub ? "+H" : ""}${pressSub ? "+P" : ""}${config10.batteryEntityId ? "+Bat" : ""}`
|
|
169538
|
+
logger173.info(
|
|
169539
|
+
`Created composed sensor ${primaryEntityId} with ${parts.length} sub-endpoint(s): T${humSub ? "+H" : ""}${pressSub ? "+P" : ""}${config10.batteryEntityId ? "+Bat" : ""}${config10.powerEntityId ? "+Pwr" : ""}${config10.energyEntityId ? "+Nrg" : ""}`
|
|
169217
169540
|
);
|
|
169218
169541
|
return endpoint;
|
|
169219
169542
|
}
|
|
@@ -169348,7 +169671,7 @@ init_home_assistant_entity_behavior();
|
|
|
169348
169671
|
// src/matter/behaviors/mode-select-server.ts
|
|
169349
169672
|
init_esm();
|
|
169350
169673
|
init_home_assistant_entity_behavior();
|
|
169351
|
-
var
|
|
169674
|
+
var logger174 = Logger.get("ModeSelectServer");
|
|
169352
169675
|
var ModeSelectServerBase = class extends ModeSelectServer {
|
|
169353
169676
|
async initialize() {
|
|
169354
169677
|
await super.initialize();
|
|
@@ -169377,13 +169700,13 @@ var ModeSelectServerBase = class extends ModeSelectServer {
|
|
|
169377
169700
|
const options = config10.getOptions(homeAssistant.entity);
|
|
169378
169701
|
const { newMode } = request;
|
|
169379
169702
|
if (newMode < 0 || newMode >= options.length) {
|
|
169380
|
-
|
|
169703
|
+
logger174.warn(
|
|
169381
169704
|
`[${homeAssistant.entityId}] Invalid mode ${newMode}, options: [${options.join(", ")}]`
|
|
169382
169705
|
);
|
|
169383
169706
|
return;
|
|
169384
169707
|
}
|
|
169385
169708
|
const option = options[newMode];
|
|
169386
|
-
|
|
169709
|
+
logger174.info(
|
|
169387
169710
|
`[${homeAssistant.entityId}] changeToMode(${newMode}) -> "${option}"`
|
|
169388
169711
|
);
|
|
169389
169712
|
applyPatchState(this.state, { currentMode: newMode });
|
|
@@ -169896,7 +170219,7 @@ var WaterLeakDetectorType = WaterLeakDetectorDevice.with(
|
|
|
169896
170219
|
);
|
|
169897
170220
|
|
|
169898
170221
|
// src/matter/endpoints/legacy/binary-sensor/index.ts
|
|
169899
|
-
var
|
|
170222
|
+
var logger175 = Logger.get("BinarySensorDevice");
|
|
169900
170223
|
var deviceClasses = {
|
|
169901
170224
|
[BinarySensorDeviceClass.CarbonMonoxide]: CoAlarmType,
|
|
169902
170225
|
[BinarySensorDeviceClass.Gas]: CoAlarmType,
|
|
@@ -169947,11 +170270,11 @@ function BinarySensorDevice(homeAssistantEntity) {
|
|
|
169947
170270
|
const originalTypeName = type.name;
|
|
169948
170271
|
if (hasBattery && batteryTypes.has(type)) {
|
|
169949
170272
|
type = batteryTypes.get(type);
|
|
169950
|
-
|
|
170273
|
+
logger175.info(
|
|
169951
170274
|
`[${entityId}] Using battery variant: ${originalTypeName} -> ${type.name}, batteryAttr=${hasBatteryAttr}, batteryEntity=${homeAssistantEntity.mapping?.batteryEntity ?? "none"}`
|
|
169952
170275
|
);
|
|
169953
170276
|
} else if (hasBattery) {
|
|
169954
|
-
|
|
170277
|
+
logger175.warn(
|
|
169955
170278
|
`[${entityId}] Has battery but no variant available for ${originalTypeName}`
|
|
169956
170279
|
);
|
|
169957
170280
|
}
|
|
@@ -170114,7 +170437,7 @@ init_home_assistant_entity_behavior();
|
|
|
170114
170437
|
// src/matter/behaviors/thermostat-server.ts
|
|
170115
170438
|
init_esm();
|
|
170116
170439
|
init_home_assistant_entity_behavior();
|
|
170117
|
-
var
|
|
170440
|
+
var logger176 = Logger.get("ThermostatServer");
|
|
170118
170441
|
var SystemMode = Thermostat3.SystemMode;
|
|
170119
170442
|
var RunningMode = Thermostat3.ThermostatRunningMode;
|
|
170120
170443
|
var nudgingSetpoints = /* @__PURE__ */ new Set();
|
|
@@ -170172,7 +170495,7 @@ var HeatingAndCoolingFeaturedBase = ThermostatServer.with("Heating", "Cooling").
|
|
|
170172
170495
|
);
|
|
170173
170496
|
function thermostatPreInitialize(self) {
|
|
170174
170497
|
const currentLocal = self.state.localTemperature;
|
|
170175
|
-
|
|
170498
|
+
logger176.debug(
|
|
170176
170499
|
`initialize: features - heating=${self.features.heating}, cooling=${self.features.cooling}`
|
|
170177
170500
|
);
|
|
170178
170501
|
const localValue = typeof currentLocal === "number" && !Number.isNaN(currentLocal) ? currentLocal : currentLocal === null ? null : 2100;
|
|
@@ -170195,7 +170518,7 @@ function thermostatPreInitialize(self) {
|
|
|
170195
170518
|
const coolingValue = typeof currentCooling === "number" && !Number.isNaN(currentCooling) ? currentCooling : 2400;
|
|
170196
170519
|
self.state.occupiedCoolingSetpoint = coolingValue;
|
|
170197
170520
|
}
|
|
170198
|
-
|
|
170521
|
+
logger176.debug(
|
|
170199
170522
|
`initialize: after force-set - local=${self.state.localTemperature}`
|
|
170200
170523
|
);
|
|
170201
170524
|
self.state.thermostatRunningState = runningStateAllOff;
|
|
@@ -170277,7 +170600,7 @@ var ThermostatServerBase = class extends FullFeaturedBase {
|
|
|
170277
170600
|
maxCoolLimit,
|
|
170278
170601
|
"cool"
|
|
170279
170602
|
);
|
|
170280
|
-
|
|
170603
|
+
logger176.debug(
|
|
170281
170604
|
`update: limits heat=[${minHeatLimit}, ${maxHeatLimit}], cool=[${minCoolLimit}, ${maxCoolLimit}], systemMode=${systemMode}, runningMode=${runningMode}`
|
|
170282
170605
|
);
|
|
170283
170606
|
let controlSequence = config10.getControlSequence(entity.state, this.agent);
|
|
@@ -170350,18 +170673,18 @@ var ThermostatServerBase = class extends FullFeaturedBase {
|
|
|
170350
170673
|
*/
|
|
170351
170674
|
// biome-ignore lint/correctness/noUnusedPrivateClassMembers: Called via thermostatPostInitialize + prototype copy
|
|
170352
170675
|
heatingSetpointChanging(value, _oldValue, context) {
|
|
170353
|
-
|
|
170676
|
+
logger176.debug(
|
|
170354
170677
|
`heatingSetpointChanging: value=${value}, oldValue=${_oldValue}, isOffline=${transactionIsOffline(context)}`
|
|
170355
170678
|
);
|
|
170356
170679
|
if (transactionIsOffline(context)) {
|
|
170357
|
-
|
|
170680
|
+
logger176.debug(
|
|
170358
170681
|
"heatingSetpointChanging: skipping - transaction is offline"
|
|
170359
170682
|
);
|
|
170360
170683
|
return;
|
|
170361
170684
|
}
|
|
170362
170685
|
const next = Temperature.celsius(value / 100);
|
|
170363
170686
|
if (!next) {
|
|
170364
|
-
|
|
170687
|
+
logger176.debug("heatingSetpointChanging: skipping - invalid temperature");
|
|
170365
170688
|
return;
|
|
170366
170689
|
}
|
|
170367
170690
|
this.agent.asLocalActor(() => {
|
|
@@ -170372,7 +170695,7 @@ var ThermostatServerBase = class extends FullFeaturedBase {
|
|
|
170372
170695
|
this.agent
|
|
170373
170696
|
);
|
|
170374
170697
|
const currentMode = this.state.systemMode;
|
|
170375
|
-
|
|
170698
|
+
logger176.debug(
|
|
170376
170699
|
`heatingSetpointChanging: supportsRange=${supportsRange}, systemMode=${currentMode}, features.heating=${this.features.heating}, features.cooling=${this.features.cooling}`
|
|
170377
170700
|
);
|
|
170378
170701
|
if (!supportsRange) {
|
|
@@ -170382,12 +170705,12 @@ var ThermostatServerBase = class extends FullFeaturedBase {
|
|
|
170382
170705
|
const isOff = currentMode === Thermostat3.SystemMode.Off;
|
|
170383
170706
|
if (isOff && this.features.heating) {
|
|
170384
170707
|
if (nudgingSetpoints.has(homeAssistant.entityId)) {
|
|
170385
|
-
|
|
170708
|
+
logger176.debug(
|
|
170386
170709
|
`heatingSetpointChanging: skipping auto-resume - nudge write in progress`
|
|
170387
170710
|
);
|
|
170388
170711
|
return;
|
|
170389
170712
|
}
|
|
170390
|
-
|
|
170713
|
+
logger176.info(
|
|
170391
170714
|
`heatingSetpointChanging: auto-resume - switching to Heat (was Off)`
|
|
170392
170715
|
);
|
|
170393
170716
|
const modeAction = config10.setSystemMode(
|
|
@@ -170396,17 +170719,17 @@ var ThermostatServerBase = class extends FullFeaturedBase {
|
|
|
170396
170719
|
);
|
|
170397
170720
|
homeAssistant.callAction(modeAction);
|
|
170398
170721
|
} else if (!isAutoMode && !isHeatingMode) {
|
|
170399
|
-
|
|
170722
|
+
logger176.debug(
|
|
170400
170723
|
`heatingSetpointChanging: skipping - not in heating/auto mode (mode=${currentMode}, haMode=${haHvacMode})`
|
|
170401
170724
|
);
|
|
170402
170725
|
return;
|
|
170403
170726
|
}
|
|
170404
|
-
|
|
170727
|
+
logger176.debug(
|
|
170405
170728
|
`heatingSetpointChanging: proceeding - isAutoMode=${isAutoMode}, isHeatingMode=${isHeatingMode}, isOff=${isOff}, haMode=${haHvacMode}`
|
|
170406
170729
|
);
|
|
170407
170730
|
}
|
|
170408
170731
|
const coolingSetpoint = this.features.cooling ? this.state.occupiedCoolingSetpoint : value;
|
|
170409
|
-
|
|
170732
|
+
logger176.debug(
|
|
170410
170733
|
`heatingSetpointChanging: calling setTemperature with heat=${next.celsius(true)}, cool=${coolingSetpoint}`
|
|
170411
170734
|
);
|
|
170412
170735
|
this.setTemperature(
|
|
@@ -170445,12 +170768,12 @@ var ThermostatServerBase = class extends FullFeaturedBase {
|
|
|
170445
170768
|
const isOff = currentMode === Thermostat3.SystemMode.Off;
|
|
170446
170769
|
if (isOff && !this.features.heating && this.features.cooling) {
|
|
170447
170770
|
if (nudgingSetpoints.has(homeAssistant.entityId)) {
|
|
170448
|
-
|
|
170771
|
+
logger176.debug(
|
|
170449
170772
|
`coolingSetpointChanging: skipping auto-resume - nudge write in progress`
|
|
170450
170773
|
);
|
|
170451
170774
|
return;
|
|
170452
170775
|
}
|
|
170453
|
-
|
|
170776
|
+
logger176.info(
|
|
170454
170777
|
`coolingSetpointChanging: auto-resume - switching to Cool (was Off)`
|
|
170455
170778
|
);
|
|
170456
170779
|
const modeAction = config10.setSystemMode(
|
|
@@ -170459,12 +170782,12 @@ var ThermostatServerBase = class extends FullFeaturedBase {
|
|
|
170459
170782
|
);
|
|
170460
170783
|
homeAssistant.callAction(modeAction);
|
|
170461
170784
|
} else if (!isAutoMode && !isCoolingMode) {
|
|
170462
|
-
|
|
170785
|
+
logger176.debug(
|
|
170463
170786
|
`coolingSetpointChanging: skipping - not in cooling/auto mode (mode=${currentMode}, haMode=${haHvacMode})`
|
|
170464
170787
|
);
|
|
170465
170788
|
return;
|
|
170466
170789
|
}
|
|
170467
|
-
|
|
170790
|
+
logger176.debug(
|
|
170468
170791
|
`coolingSetpointChanging: proceeding - isAutoMode=${isAutoMode}, isCoolingMode=${isCoolingMode}, isOff=${isOff}, haMode=${haHvacMode}`
|
|
170469
170792
|
);
|
|
170470
170793
|
}
|
|
@@ -170561,7 +170884,7 @@ var ThermostatServerBase = class extends FullFeaturedBase {
|
|
|
170561
170884
|
const effectiveMax = max ?? 5e3;
|
|
170562
170885
|
if (value == null || Number.isNaN(value)) {
|
|
170563
170886
|
const defaultValue = type === "heat" ? 2e3 : 2400;
|
|
170564
|
-
|
|
170887
|
+
logger176.debug(
|
|
170565
170888
|
`${type} setpoint is undefined, using default: ${defaultValue}`
|
|
170566
170889
|
);
|
|
170567
170890
|
return Math.max(effectiveMin, Math.min(effectiveMax, defaultValue));
|
|
@@ -171006,16 +171329,16 @@ init_home_assistant_entity_behavior();
|
|
|
171006
171329
|
init_esm();
|
|
171007
171330
|
init_home_assistant_actions();
|
|
171008
171331
|
init_home_assistant_entity_behavior();
|
|
171009
|
-
var
|
|
171332
|
+
var logger177 = Logger.get("WindowCoveringServer");
|
|
171010
171333
|
var MovementStatus = WindowCovering3.MovementStatus;
|
|
171011
|
-
var
|
|
171334
|
+
var FeaturedBase6 = WindowCoveringServer.with(
|
|
171012
171335
|
"Lift",
|
|
171013
171336
|
"PositionAwareLift",
|
|
171014
171337
|
"Tilt",
|
|
171015
171338
|
"PositionAwareTilt",
|
|
171016
171339
|
"AbsolutePosition"
|
|
171017
171340
|
);
|
|
171018
|
-
var WindowCoveringServerBase = class _WindowCoveringServerBase extends
|
|
171341
|
+
var WindowCoveringServerBase = class _WindowCoveringServerBase extends FeaturedBase6 {
|
|
171019
171342
|
liftDebounceTimer = null;
|
|
171020
171343
|
tiltDebounceTimer = null;
|
|
171021
171344
|
// Track when the last command was received to implement two-phase debounce
|
|
@@ -171109,7 +171432,7 @@ var WindowCoveringServerBase = class _WindowCoveringServerBase extends FeaturedB
|
|
|
171109
171432
|
}
|
|
171110
171433
|
return existing100ths ?? current100ths;
|
|
171111
171434
|
};
|
|
171112
|
-
|
|
171435
|
+
logger177.debug(
|
|
171113
171436
|
`Cover update for ${entity.entity_id}: state=${state.state}, lift=${currentLift}%, tilt=${currentTilt}%, movement=${MovementStatus[movementStatus]}`
|
|
171114
171437
|
);
|
|
171115
171438
|
const appliedPatch = applyPatchState(
|
|
@@ -171152,9 +171475,9 @@ var WindowCoveringServerBase = class _WindowCoveringServerBase extends FeaturedB
|
|
|
171152
171475
|
);
|
|
171153
171476
|
if (Object.keys(appliedPatch).length > 0) {
|
|
171154
171477
|
const hasOperationalChange = "operationalStatus" in appliedPatch;
|
|
171155
|
-
const log = hasOperationalChange ?
|
|
171478
|
+
const log = hasOperationalChange ? logger177.info : logger177.debug;
|
|
171156
171479
|
log.call(
|
|
171157
|
-
|
|
171480
|
+
logger177,
|
|
171158
171481
|
`Cover ${entity.entity_id} state changed: ${JSON.stringify(appliedPatch)}`
|
|
171159
171482
|
);
|
|
171160
171483
|
}
|
|
@@ -171162,7 +171485,7 @@ var WindowCoveringServerBase = class _WindowCoveringServerBase extends FeaturedB
|
|
|
171162
171485
|
async handleMovement(type, _, direction, targetPercent100ths) {
|
|
171163
171486
|
const currentLift = this.state.currentPositionLiftPercent100ths ?? 0;
|
|
171164
171487
|
const currentTilt = this.state.currentPositionTiltPercent100ths ?? 0;
|
|
171165
|
-
|
|
171488
|
+
logger177.info(
|
|
171166
171489
|
`handleMovement: type=${MovementType[type]}, direction=${MovementDirection[direction]}, target=${targetPercent100ths}, currentLift=${currentLift}, currentTilt=${currentTilt}, absolutePosition=${this.features.absolutePosition}`
|
|
171167
171490
|
);
|
|
171168
171491
|
if (type === MovementType.Lift) {
|
|
@@ -171181,7 +171504,7 @@ var WindowCoveringServerBase = class _WindowCoveringServerBase extends FeaturedB
|
|
|
171181
171504
|
}
|
|
171182
171505
|
} else if (type === MovementType.Tilt) {
|
|
171183
171506
|
if (targetPercent100ths == null && this.lastLiftMovementDirection === direction && Date.now() - this.lastLiftMovementMs < 50) {
|
|
171184
|
-
|
|
171507
|
+
logger177.info(
|
|
171185
171508
|
`Skipping tilt ${MovementDirection[direction]} \u2014 lift already moving in same direction`
|
|
171186
171509
|
);
|
|
171187
171510
|
return;
|
|
@@ -171206,13 +171529,13 @@ var WindowCoveringServerBase = class _WindowCoveringServerBase extends FeaturedB
|
|
|
171206
171529
|
handleLiftOpen() {
|
|
171207
171530
|
const homeAssistant = this.agent.get(HomeAssistantEntityBehavior);
|
|
171208
171531
|
const action = this.state.config.openCoverLift(void 0, this.agent);
|
|
171209
|
-
|
|
171532
|
+
logger177.info(`handleLiftOpen: calling action=${action.action}`);
|
|
171210
171533
|
homeAssistant.callAction(action);
|
|
171211
171534
|
}
|
|
171212
171535
|
handleLiftClose() {
|
|
171213
171536
|
const homeAssistant = this.agent.get(HomeAssistantEntityBehavior);
|
|
171214
171537
|
const action = this.state.config.closeCoverLift(void 0, this.agent);
|
|
171215
|
-
|
|
171538
|
+
logger177.info(`handleLiftClose: calling action=${action.action}`);
|
|
171216
171539
|
homeAssistant.callAction(action);
|
|
171217
171540
|
}
|
|
171218
171541
|
handleGoToLiftPosition(targetPercent100ths) {
|
|
@@ -171233,7 +171556,7 @@ var WindowCoveringServerBase = class _WindowCoveringServerBase extends FeaturedB
|
|
|
171233
171556
|
this.lastLiftCommandTime = now;
|
|
171234
171557
|
const isFirstInSequence = timeSinceLastCommand > _WindowCoveringServerBase.COMMAND_SEQUENCE_THRESHOLD_MS;
|
|
171235
171558
|
const debounceMs = isFirstInSequence ? _WindowCoveringServerBase.DEBOUNCE_INITIAL_MS : _WindowCoveringServerBase.DEBOUNCE_SUBSEQUENT_MS;
|
|
171236
|
-
|
|
171559
|
+
logger177.debug(
|
|
171237
171560
|
`Lift command: target=${targetPosition}%, debounce=${debounceMs}ms (${isFirstInSequence ? "initial" : "subsequent"})`
|
|
171238
171561
|
);
|
|
171239
171562
|
if (this.liftDebounceTimer) {
|
|
@@ -171282,7 +171605,7 @@ var WindowCoveringServerBase = class _WindowCoveringServerBase extends FeaturedB
|
|
|
171282
171605
|
this.lastTiltCommandTime = now;
|
|
171283
171606
|
const isFirstInSequence = timeSinceLastCommand > _WindowCoveringServerBase.COMMAND_SEQUENCE_THRESHOLD_MS;
|
|
171284
171607
|
const debounceMs = isFirstInSequence ? _WindowCoveringServerBase.DEBOUNCE_INITIAL_MS : _WindowCoveringServerBase.DEBOUNCE_SUBSEQUENT_MS;
|
|
171285
|
-
|
|
171608
|
+
logger177.debug(
|
|
171286
171609
|
`Tilt command: target=${targetPosition}%, debounce=${debounceMs}ms (${isFirstInSequence ? "initial" : "subsequent"})`
|
|
171287
171610
|
);
|
|
171288
171611
|
if (this.tiltDebounceTimer) {
|
|
@@ -171303,7 +171626,7 @@ var WindowCoveringServerBase = class _WindowCoveringServerBase extends FeaturedB
|
|
|
171303
171626
|
}
|
|
171304
171627
|
};
|
|
171305
171628
|
((WindowCoveringServerBase2) => {
|
|
171306
|
-
class State extends
|
|
171629
|
+
class State extends FeaturedBase6.State {
|
|
171307
171630
|
config;
|
|
171308
171631
|
}
|
|
171309
171632
|
WindowCoveringServerBase2.State = State;
|
|
@@ -171341,7 +171664,7 @@ function adjustPositionForWriting(position, flags2, matterSemantics) {
|
|
|
171341
171664
|
}
|
|
171342
171665
|
|
|
171343
171666
|
// src/matter/endpoints/legacy/cover/behaviors/cover-window-covering-server.ts
|
|
171344
|
-
var
|
|
171667
|
+
var logger178 = Logger.get("CoverWindowCoveringServer");
|
|
171345
171668
|
var attributes5 = (entity) => entity.attributes;
|
|
171346
171669
|
var MATTER_SEMANTIC_PLATFORMS = [
|
|
171347
171670
|
// Currently empty - no known platforms use Matter semantics by default
|
|
@@ -171359,7 +171682,7 @@ var adjustPositionForReading2 = (position, agent) => {
|
|
|
171359
171682
|
const { featureFlags } = agent.env.get(BridgeDataProvider);
|
|
171360
171683
|
const matterSem = usesMatterSemantics(agent);
|
|
171361
171684
|
const result = adjustPositionForReading(position, featureFlags, matterSem);
|
|
171362
|
-
|
|
171685
|
+
logger178.debug(`adjustPositionForReading: HA=${position}%, result=${result}%`);
|
|
171363
171686
|
return result;
|
|
171364
171687
|
};
|
|
171365
171688
|
var adjustPositionForWriting2 = (position, agent) => {
|
|
@@ -171466,7 +171789,7 @@ var config5 = {
|
|
|
171466
171789
|
var CoverWindowCoveringServer = WindowCoveringServer2(config5);
|
|
171467
171790
|
|
|
171468
171791
|
// src/matter/endpoints/legacy/cover/index.ts
|
|
171469
|
-
var
|
|
171792
|
+
var logger179 = Logger.get("CoverDevice");
|
|
171470
171793
|
var CoverDeviceType = (supportedFeatures, hasBattery, entityId) => {
|
|
171471
171794
|
const features2 = /* @__PURE__ */ new Set();
|
|
171472
171795
|
if (testBit(supportedFeatures, CoverSupportedFeatures.support_open)) {
|
|
@@ -171474,7 +171797,7 @@ var CoverDeviceType = (supportedFeatures, hasBattery, entityId) => {
|
|
|
171474
171797
|
features2.add("PositionAwareLift");
|
|
171475
171798
|
features2.add("AbsolutePosition");
|
|
171476
171799
|
} else {
|
|
171477
|
-
|
|
171800
|
+
logger179.warn(
|
|
171478
171801
|
`[${entityId}] Cover has no support_open feature (supported_features=${supportedFeatures}), adding Lift anyway`
|
|
171479
171802
|
);
|
|
171480
171803
|
features2.add("Lift");
|
|
@@ -171491,7 +171814,7 @@ var CoverDeviceType = (supportedFeatures, hasBattery, entityId) => {
|
|
|
171491
171814
|
features2.add("AbsolutePosition");
|
|
171492
171815
|
}
|
|
171493
171816
|
}
|
|
171494
|
-
|
|
171817
|
+
logger179.info(
|
|
171495
171818
|
`[${entityId}] Creating WindowCovering with features: [${[...features2].join(", ")}], supported_features=${supportedFeatures}`
|
|
171496
171819
|
);
|
|
171497
171820
|
const baseBehaviors = [
|
|
@@ -171515,11 +171838,11 @@ function CoverDevice(homeAssistantEntity) {
|
|
|
171515
171838
|
const hasBatteryEntity = !!homeAssistantEntity.mapping?.batteryEntity;
|
|
171516
171839
|
const hasBattery = hasBatteryAttr || hasBatteryEntity;
|
|
171517
171840
|
if (hasBattery) {
|
|
171518
|
-
|
|
171841
|
+
logger179.info(
|
|
171519
171842
|
`[${entityId}] Creating cover with PowerSource cluster, batteryAttr=${hasBatteryAttr}, batteryEntity=${homeAssistantEntity.mapping?.batteryEntity ?? "none"}`
|
|
171520
171843
|
);
|
|
171521
171844
|
} else {
|
|
171522
|
-
|
|
171845
|
+
logger179.debug(
|
|
171523
171846
|
`[${entityId}] Creating cover without battery (batteryAttr=${hasBatteryAttr}, batteryEntity=${homeAssistantEntity.mapping?.batteryEntity ?? "none"})`
|
|
171524
171847
|
);
|
|
171525
171848
|
}
|
|
@@ -171535,18 +171858,18 @@ function CoverDevice(homeAssistantEntity) {
|
|
|
171535
171858
|
// src/matter/behaviors/generic-switch-server.ts
|
|
171536
171859
|
init_esm();
|
|
171537
171860
|
init_home_assistant_entity_behavior();
|
|
171538
|
-
var
|
|
171539
|
-
var
|
|
171861
|
+
var logger180 = Logger.get("GenericSwitchServer");
|
|
171862
|
+
var FeaturedBase7 = SwitchServer.with(
|
|
171540
171863
|
"MomentarySwitch",
|
|
171541
171864
|
"MomentarySwitchRelease",
|
|
171542
171865
|
"MomentarySwitchMultiPress"
|
|
171543
171866
|
);
|
|
171544
|
-
var GenericSwitchServerBase = class extends
|
|
171867
|
+
var GenericSwitchServerBase = class extends FeaturedBase7 {
|
|
171545
171868
|
async initialize() {
|
|
171546
171869
|
await super.initialize();
|
|
171547
171870
|
const homeAssistant = await this.agent.load(HomeAssistantEntityBehavior);
|
|
171548
171871
|
const entityId = homeAssistant.entityId;
|
|
171549
|
-
|
|
171872
|
+
logger180.debug(`[${entityId}] GenericSwitch initialized`);
|
|
171550
171873
|
this.reactTo(homeAssistant.onChange, this.handleEventChange);
|
|
171551
171874
|
}
|
|
171552
171875
|
handleEventChange() {
|
|
@@ -171557,7 +171880,7 @@ var GenericSwitchServerBase = class extends FeaturedBase6 {
|
|
|
171557
171880
|
const eventType = attrs.event_type;
|
|
171558
171881
|
if (!eventType) return;
|
|
171559
171882
|
const entityId = homeAssistant.entityId;
|
|
171560
|
-
|
|
171883
|
+
logger180.debug(`[${entityId}] Event fired: ${eventType}`);
|
|
171561
171884
|
this.triggerPress(eventType);
|
|
171562
171885
|
}
|
|
171563
171886
|
triggerPress(eventType) {
|
|
@@ -171600,7 +171923,7 @@ var GenericSwitchServerBase = class extends FeaturedBase6 {
|
|
|
171600
171923
|
}
|
|
171601
171924
|
};
|
|
171602
171925
|
((GenericSwitchServerBase2) => {
|
|
171603
|
-
class State extends
|
|
171926
|
+
class State extends FeaturedBase7.State {
|
|
171604
171927
|
}
|
|
171605
171928
|
GenericSwitchServerBase2.State = State;
|
|
171606
171929
|
})(GenericSwitchServerBase || (GenericSwitchServerBase = {}));
|
|
@@ -171852,7 +172175,7 @@ init_nodejs();
|
|
|
171852
172175
|
|
|
171853
172176
|
// src/matter/behaviors/color-control-server.ts
|
|
171854
172177
|
init_home_assistant_entity_behavior();
|
|
171855
|
-
var
|
|
172178
|
+
var logger181 = Logger.get("ColorControlServer");
|
|
171856
172179
|
var optimisticColorState = /* @__PURE__ */ new Map();
|
|
171857
172180
|
var OPTIMISTIC_TIMEOUT_MS3 = 3e3;
|
|
171858
172181
|
var OPTIMISTIC_TOLERANCE2 = 5;
|
|
@@ -171862,8 +172185,8 @@ function consumePendingColorStaging(entityId) {
|
|
|
171862
172185
|
pendingColorStaging.delete(entityId);
|
|
171863
172186
|
return data;
|
|
171864
172187
|
}
|
|
171865
|
-
var
|
|
171866
|
-
var ColorControlServerBase = class extends
|
|
172188
|
+
var FeaturedBase8 = ColorControlServer.with("ColorTemperature", "HueSaturation");
|
|
172189
|
+
var ColorControlServerBase = class extends FeaturedBase8 {
|
|
171867
172190
|
pendingTransitionTime;
|
|
171868
172191
|
async initialize() {
|
|
171869
172192
|
if (this.features.colorTemperature) {
|
|
@@ -171885,7 +172208,7 @@ var ColorControlServerBase = class extends FeaturedBase7 {
|
|
|
171885
172208
|
if (this.state.startUpColorTemperatureMireds == null) {
|
|
171886
172209
|
this.state.startUpColorTemperatureMireds = defaultMireds;
|
|
171887
172210
|
}
|
|
171888
|
-
|
|
172211
|
+
logger181.debug(
|
|
171889
172212
|
`initialize: set ColorTemperature defaults - min=${this.state.colorTempPhysicalMinMireds}, max=${this.state.colorTempPhysicalMaxMireds}, current=${this.state.colorTemperatureMireds}`
|
|
171890
172213
|
);
|
|
171891
172214
|
}
|
|
@@ -172095,7 +172418,7 @@ var ColorControlServerBase = class extends FeaturedBase7 {
|
|
|
172095
172418
|
}
|
|
172096
172419
|
};
|
|
172097
172420
|
((ColorControlServerBase2) => {
|
|
172098
|
-
class State extends
|
|
172421
|
+
class State extends FeaturedBase8.State {
|
|
172099
172422
|
config;
|
|
172100
172423
|
}
|
|
172101
172424
|
ColorControlServerBase2.State = State;
|
|
@@ -172269,126 +172592,6 @@ var OnOffLightWithBatteryType = OnOffLightDevice.with(
|
|
|
172269
172592
|
|
|
172270
172593
|
// src/matter/endpoints/legacy/light/index.ts
|
|
172271
172594
|
init_dist();
|
|
172272
|
-
|
|
172273
|
-
// src/matter/behaviors/electrical-energy-measurement-server.ts
|
|
172274
|
-
init_esm();
|
|
172275
|
-
init_home_assistant_entity_behavior();
|
|
172276
|
-
var logger180 = Logger.get("ElectricalEnergyMeasurementServer");
|
|
172277
|
-
var FeaturedBase8 = ElectricalEnergyMeasurementServer.with("CumulativeEnergy", "ImportedEnergy");
|
|
172278
|
-
var ElectricalEnergyMeasurementServerBase = class extends FeaturedBase8 {
|
|
172279
|
-
async initialize() {
|
|
172280
|
-
await super.initialize();
|
|
172281
|
-
const homeAssistant = await this.agent.load(HomeAssistantEntityBehavior);
|
|
172282
|
-
const entityId = homeAssistant.entityId;
|
|
172283
|
-
const energyEntity = homeAssistant.state.mapping?.energyEntity;
|
|
172284
|
-
if (energyEntity) {
|
|
172285
|
-
logger180.debug(
|
|
172286
|
-
`[${entityId}] ElectricalEnergyMeasurement using mapped energy entity: ${energyEntity}`
|
|
172287
|
-
);
|
|
172288
|
-
}
|
|
172289
|
-
this.update();
|
|
172290
|
-
this.reactTo(homeAssistant.onChange, this.update);
|
|
172291
|
-
}
|
|
172292
|
-
update() {
|
|
172293
|
-
const homeAssistant = this.agent.get(HomeAssistantEntityBehavior);
|
|
172294
|
-
const energyEntity = homeAssistant.state.mapping?.energyEntity;
|
|
172295
|
-
if (!energyEntity) return;
|
|
172296
|
-
const stateProvider = this.agent.env.get(EntityStateProvider);
|
|
172297
|
-
const energyKwh = stateProvider.getNumericState(energyEntity);
|
|
172298
|
-
if (energyKwh == null) return;
|
|
172299
|
-
const energyMwh = Math.round(energyKwh * 1e6);
|
|
172300
|
-
const energyImported = { energy: energyMwh };
|
|
172301
|
-
applyPatchState(this.state, {
|
|
172302
|
-
cumulativeEnergyImported: energyImported
|
|
172303
|
-
});
|
|
172304
|
-
this.events.cumulativeEnergyMeasured?.emit(
|
|
172305
|
-
{ energyImported, energyExported: void 0 },
|
|
172306
|
-
this.context
|
|
172307
|
-
);
|
|
172308
|
-
}
|
|
172309
|
-
};
|
|
172310
|
-
((ElectricalEnergyMeasurementServerBase2) => {
|
|
172311
|
-
class State extends FeaturedBase8.State {
|
|
172312
|
-
}
|
|
172313
|
-
ElectricalEnergyMeasurementServerBase2.State = State;
|
|
172314
|
-
})(ElectricalEnergyMeasurementServerBase || (ElectricalEnergyMeasurementServerBase = {}));
|
|
172315
|
-
var HaElectricalEnergyMeasurementServer = ElectricalEnergyMeasurementServerBase.set({
|
|
172316
|
-
accuracy: {
|
|
172317
|
-
measurementType: ElectricalPowerMeasurement3.MeasurementType.ElectricalEnergy,
|
|
172318
|
-
measured: true,
|
|
172319
|
-
minMeasuredValue: -1e6,
|
|
172320
|
-
// -1000Wh, allows 0 and all positive values
|
|
172321
|
-
maxMeasuredValue: 1e11,
|
|
172322
|
-
// 100MWh in mWh
|
|
172323
|
-
accuracyRanges: [
|
|
172324
|
-
{
|
|
172325
|
-
rangeMin: -1e6,
|
|
172326
|
-
rangeMax: 1e11,
|
|
172327
|
-
fixedMax: 1e3
|
|
172328
|
-
// 1Wh accuracy
|
|
172329
|
-
}
|
|
172330
|
-
]
|
|
172331
|
-
}
|
|
172332
|
-
});
|
|
172333
|
-
|
|
172334
|
-
// src/matter/behaviors/electrical-power-measurement-server.ts
|
|
172335
|
-
init_esm();
|
|
172336
|
-
init_home_assistant_entity_behavior();
|
|
172337
|
-
var logger181 = Logger.get("ElectricalPowerMeasurementServer");
|
|
172338
|
-
var ElectricalPowerMeasurementServerBase = class extends ElectricalPowerMeasurementServer {
|
|
172339
|
-
async initialize() {
|
|
172340
|
-
await super.initialize();
|
|
172341
|
-
const homeAssistant = await this.agent.load(HomeAssistantEntityBehavior);
|
|
172342
|
-
const entityId = homeAssistant.entityId;
|
|
172343
|
-
const powerEntity = homeAssistant.state.mapping?.powerEntity;
|
|
172344
|
-
if (powerEntity) {
|
|
172345
|
-
logger181.debug(
|
|
172346
|
-
`[${entityId}] ElectricalPowerMeasurement using mapped power entity: ${powerEntity}`
|
|
172347
|
-
);
|
|
172348
|
-
}
|
|
172349
|
-
this.update();
|
|
172350
|
-
this.reactTo(homeAssistant.onChange, this.update);
|
|
172351
|
-
}
|
|
172352
|
-
update() {
|
|
172353
|
-
const homeAssistant = this.agent.get(HomeAssistantEntityBehavior);
|
|
172354
|
-
const powerEntity = homeAssistant.state.mapping?.powerEntity;
|
|
172355
|
-
if (!powerEntity) return;
|
|
172356
|
-
const stateProvider = this.agent.env.get(EntityStateProvider);
|
|
172357
|
-
const powerWatts = stateProvider.getNumericState(powerEntity);
|
|
172358
|
-
if (powerWatts == null) return;
|
|
172359
|
-
const activePower = Math.round(powerWatts * 1e3);
|
|
172360
|
-
applyPatchState(this.state, { activePower });
|
|
172361
|
-
}
|
|
172362
|
-
};
|
|
172363
|
-
((ElectricalPowerMeasurementServerBase2) => {
|
|
172364
|
-
class State extends ElectricalPowerMeasurementServer.State {
|
|
172365
|
-
}
|
|
172366
|
-
ElectricalPowerMeasurementServerBase2.State = State;
|
|
172367
|
-
})(ElectricalPowerMeasurementServerBase || (ElectricalPowerMeasurementServerBase = {}));
|
|
172368
|
-
var HaElectricalPowerMeasurementServer = ElectricalPowerMeasurementServerBase.set({
|
|
172369
|
-
powerMode: ElectricalPowerMeasurement3.PowerMode.Ac,
|
|
172370
|
-
numberOfMeasurementTypes: 1,
|
|
172371
|
-
accuracy: [
|
|
172372
|
-
{
|
|
172373
|
-
measurementType: ElectricalPowerMeasurement3.MeasurementType.ActivePower,
|
|
172374
|
-
measured: true,
|
|
172375
|
-
minMeasuredValue: -1e6,
|
|
172376
|
-
// -1000W, allows 0 and all positive values
|
|
172377
|
-
maxMeasuredValue: 1e8,
|
|
172378
|
-
// 100kW in mW
|
|
172379
|
-
accuracyRanges: [
|
|
172380
|
-
{
|
|
172381
|
-
rangeMin: -1e6,
|
|
172382
|
-
rangeMax: 1e8,
|
|
172383
|
-
fixedMax: 1e3
|
|
172384
|
-
// 1W accuracy
|
|
172385
|
-
}
|
|
172386
|
-
]
|
|
172387
|
-
}
|
|
172388
|
-
]
|
|
172389
|
-
});
|
|
172390
|
-
|
|
172391
|
-
// src/matter/endpoints/legacy/light/index.ts
|
|
172392
172595
|
var brightnessModes = Object.values(
|
|
172393
172596
|
LightDeviceColorMode
|
|
172394
172597
|
).filter((mode) => mode !== LightDeviceColorMode.UNKNOWN).filter((mode) => mode !== LightDeviceColorMode.ONOFF);
|
|
@@ -175346,6 +175549,16 @@ function SensorDevice(homeAssistantEntity) {
|
|
|
175346
175549
|
if (deviceClass === SensorDeviceClass.battery) {
|
|
175347
175550
|
return BatterySensorType.set({ homeAssistantEntity });
|
|
175348
175551
|
}
|
|
175552
|
+
if (deviceClass) {
|
|
175553
|
+
diagnosticEventBus.emit(
|
|
175554
|
+
"entity_warning",
|
|
175555
|
+
`Sensor "${homeAssistantEntity.entity.entity_id}" has unsupported device_class "${deviceClass}" \u2014 skipped`,
|
|
175556
|
+
{
|
|
175557
|
+
entityId: homeAssistantEntity.entity.entity_id,
|
|
175558
|
+
details: { device_class: deviceClass }
|
|
175559
|
+
}
|
|
175560
|
+
);
|
|
175561
|
+
}
|
|
175349
175562
|
return void 0;
|
|
175350
175563
|
}
|
|
175351
175564
|
|
|
@@ -178321,6 +178534,8 @@ var LegacyEndpoint = class _LegacyEndpoint extends EntityEndpoint {
|
|
|
178321
178534
|
humidityEntityId: effectiveMapping?.humidityEntity,
|
|
178322
178535
|
pressureEntityId: effectiveMapping?.pressureEntity,
|
|
178323
178536
|
batteryEntityId: effectiveMapping?.batteryEntity,
|
|
178537
|
+
powerEntityId: effectiveMapping?.powerEntity,
|
|
178538
|
+
energyEntityId: effectiveMapping?.energyEntity,
|
|
178324
178539
|
customName: effectiveMapping?.customName,
|
|
178325
178540
|
areaName: composedAreaName
|
|
178326
178541
|
});
|
|
@@ -178338,6 +178553,8 @@ var LegacyEndpoint = class _LegacyEndpoint extends EntityEndpoint {
|
|
|
178338
178553
|
temperatureEntityId,
|
|
178339
178554
|
humidityEntityId,
|
|
178340
178555
|
batteryEntityId: effectiveMapping?.batteryEntity,
|
|
178556
|
+
powerEntityId: effectiveMapping?.powerEntity,
|
|
178557
|
+
energyEntityId: effectiveMapping?.energyEntity,
|
|
178341
178558
|
mapping: effectiveMapping,
|
|
178342
178559
|
customName: effectiveMapping?.customName,
|
|
178343
178560
|
areaName: composedAreaName
|
|
@@ -179083,16 +179300,25 @@ var BridgeEndpointManager = class extends Service {
|
|
|
179083
179300
|
}
|
|
179084
179301
|
}
|
|
179085
179302
|
async updateStates(states) {
|
|
179303
|
+
const startMs = performance.now();
|
|
179086
179304
|
this.registry.mergeExternalStates(states);
|
|
179087
179305
|
const endpoints = this.root.parts.map((p) => p);
|
|
179088
179306
|
const results = await Promise.allSettled(
|
|
179089
179307
|
endpoints.map((endpoint) => endpoint.updateStates(states))
|
|
179090
179308
|
);
|
|
179309
|
+
let failedCount = 0;
|
|
179091
179310
|
for (const result of results) {
|
|
179092
179311
|
if (result.status === "rejected") {
|
|
179312
|
+
failedCount++;
|
|
179093
179313
|
this.log.warn("State update failed for endpoint:", result.reason);
|
|
179094
179314
|
}
|
|
179095
179315
|
}
|
|
179316
|
+
const latencyMs = Math.round((performance.now() - startMs) * 100) / 100;
|
|
179317
|
+
if (latencyMs > 200) {
|
|
179318
|
+
this.log.warn(
|
|
179319
|
+
`Slow state update: ${endpoints.length} endpoints in ${latencyMs}ms` + (failedCount > 0 ? ` (${failedCount} failed)` : "")
|
|
179320
|
+
);
|
|
179321
|
+
}
|
|
179096
179322
|
}
|
|
179097
179323
|
/**
|
|
179098
179324
|
* Log detailed behavior error information for debugging "Behaviors have errors".
|