@riddix/hamh 2.1.0-alpha.605 → 2.1.0-alpha.606
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
|
@@ -146858,6 +146858,12 @@ var init_bridge_config_schema = __esm({
|
|
|
146858
146858
|
minimum: 1,
|
|
146859
146859
|
maximum: 999
|
|
146860
146860
|
},
|
|
146861
|
+
serialNumberSuffix: {
|
|
146862
|
+
title: "Serial Number Suffix",
|
|
146863
|
+
type: "string",
|
|
146864
|
+
description: "Append a suffix to every entity serial number on this bridge. Useful for forcing controllers like Aqara to treat devices as new and bypass cached device data. Leave empty for default behavior.",
|
|
146865
|
+
maxLength: 16
|
|
146866
|
+
},
|
|
146861
146867
|
filter: homeAssistantFilterSchema,
|
|
146862
146868
|
featureFlags: featureFlagSchema
|
|
146863
146869
|
},
|
|
@@ -165146,6 +165152,11 @@ function deepEqual(a, b) {
|
|
|
165146
165152
|
return a === b;
|
|
165147
165153
|
}
|
|
165148
165154
|
|
|
165155
|
+
// src/utils/sanitize-matter-string.ts
|
|
165156
|
+
function sanitizeMatterString(value) {
|
|
165157
|
+
return value.replace(/[*!~\x00-\x1f\x7f]/g, "").trim();
|
|
165158
|
+
}
|
|
165159
|
+
|
|
165149
165160
|
// src/utils/trim-to-length.ts
|
|
165150
165161
|
function trimToLength(value, maxLength, suffix) {
|
|
165151
165162
|
const stringValue = value?.toString();
|
|
@@ -165162,6 +165173,7 @@ function trimToLength(value, maxLength, suffix) {
|
|
|
165162
165173
|
var ServerModeServerNode = class extends ServerNode {
|
|
165163
165174
|
deviceEndpoint;
|
|
165164
165175
|
featureFlags;
|
|
165176
|
+
serialNumberSuffix;
|
|
165165
165177
|
constructor(env, bridgeData) {
|
|
165166
165178
|
super({
|
|
165167
165179
|
id: bridgeData.id,
|
|
@@ -165191,6 +165203,7 @@ var ServerModeServerNode = class extends ServerNode {
|
|
|
165191
165203
|
}
|
|
165192
165204
|
});
|
|
165193
165205
|
this.featureFlags = bridgeData.featureFlags;
|
|
165206
|
+
this.serialNumberSuffix = bridgeData.serialNumberSuffix;
|
|
165194
165207
|
}
|
|
165195
165208
|
/**
|
|
165196
165209
|
* Add the device endpoint to this server node.
|
|
@@ -165219,13 +165232,15 @@ var ServerModeServerNode = class extends ServerNode {
|
|
|
165219
165232
|
*/
|
|
165220
165233
|
updateDeviceIdentity(entityId, device, mapping, friendlyName) {
|
|
165221
165234
|
const nodeLabel = trimToLength(mapping?.customName, 32, "...") ?? trimToLength(friendlyName, 32, "...") ?? trimToLength(entityId, 32, "...");
|
|
165222
|
-
const productNameFromNodeLabel = this.featureFlags?.productNameFromNodeLabel === true ? nodeLabel : void 0;
|
|
165235
|
+
const productNameFromNodeLabel = this.featureFlags?.productNameFromNodeLabel === true ? trimToLength(sanitizeMatterString(nodeLabel ?? ""), 32, "...") ?? void 0 : void 0;
|
|
165236
|
+
const rawSerial = trimToLength(mapping?.customSerialNumber, 32, "...");
|
|
165237
|
+
const serialNumber = rawSerial && this.serialNumberSuffix ? trimToLength(`${rawSerial}${this.serialNumberSuffix}`, 32, "...") : rawSerial;
|
|
165223
165238
|
applyPatchState(this.state.basicInformation, {
|
|
165224
165239
|
vendorName: trimToLength(mapping?.customVendorName, 32, "...") ?? trimToLength(device?.manufacturer, 32, "..."),
|
|
165225
165240
|
productName: trimToLength(mapping?.customProductName, 32, "...") ?? productNameFromNodeLabel ?? trimToLength(device?.model_id, 32, "...") ?? trimToLength(device?.model, 32, "..."),
|
|
165226
165241
|
productLabel: trimToLength(device?.model, 64, "..."),
|
|
165227
165242
|
nodeLabel,
|
|
165228
|
-
serialNumber
|
|
165243
|
+
serialNumber,
|
|
165229
165244
|
hardwareVersionString: trimToLength(device?.hw_version, 64, "..."),
|
|
165230
165245
|
softwareVersionString: trimToLength(device?.sw_version, 64, "...")
|
|
165231
165246
|
});
|
|
@@ -166299,6 +166314,9 @@ var BridgeDataProvider = class extends Service {
|
|
|
166299
166314
|
get priority() {
|
|
166300
166315
|
return this.data.priority;
|
|
166301
166316
|
}
|
|
166317
|
+
get serialNumberSuffix() {
|
|
166318
|
+
return this.data.serialNumberSuffix;
|
|
166319
|
+
}
|
|
166302
166320
|
/************************************************
|
|
166303
166321
|
* Functions
|
|
166304
166322
|
************************************************/
|
|
@@ -166323,6 +166341,7 @@ var BridgeDataProvider = class extends Service {
|
|
|
166323
166341
|
countryCode: this.countryCode,
|
|
166324
166342
|
icon: this.icon,
|
|
166325
166343
|
priority: this.priority,
|
|
166344
|
+
serialNumberSuffix: this.serialNumberSuffix,
|
|
166326
166345
|
status: status3.code,
|
|
166327
166346
|
statusReason: status3.reason,
|
|
166328
166347
|
commissioning: commissioning ? {
|
|
@@ -168102,7 +168121,10 @@ var BasicInformationServer2 = class extends BridgedDeviceBasicInformationServer
|
|
|
168102
168121
|
const device = entity.deviceRegistry;
|
|
168103
168122
|
const mapping = homeAssistant.state.mapping;
|
|
168104
168123
|
const nodeLabel = ellipse(32, homeAssistant.state.customName) ?? ellipse(32, entity.state?.attributes?.friendly_name) ?? ellipse(32, entity.entity_id);
|
|
168105
|
-
const productNameFromNodeLabel = featureFlags?.productNameFromNodeLabel === true ? nodeLabel : void 0;
|
|
168124
|
+
const productNameFromNodeLabel = featureFlags?.productNameFromNodeLabel === true ? ellipse(32, sanitizeMatterString(nodeLabel ?? "")) ?? void 0 : void 0;
|
|
168125
|
+
const serialNumberSuffix = this.env.get(BridgeDataProvider).serialNumberSuffix;
|
|
168126
|
+
const rawSerial = ellipse(32, mapping?.customSerialNumber) ?? hash(32, entity.entity_id);
|
|
168127
|
+
const serialNumber = serialNumberSuffix ? ellipse(32, `${rawSerial}${serialNumberSuffix}`) : rawSerial;
|
|
168106
168128
|
applyPatchState(this.state, {
|
|
168107
168129
|
vendorId: VendorId(basicInformation.vendorId),
|
|
168108
168130
|
vendorName: ellipse(32, mapping?.customVendorName) ?? ellipse(32, device?.manufacturer) ?? hash(32, basicInformation.vendorName),
|
|
@@ -168114,7 +168136,7 @@ var BasicInformationServer2 = class extends BridgedDeviceBasicInformationServer
|
|
|
168114
168136
|
softwareVersionString: ellipse(64, device?.sw_version),
|
|
168115
168137
|
nodeLabel,
|
|
168116
168138
|
reachable: entity.state?.state != null && entity.state.state !== "unavailable",
|
|
168117
|
-
serialNumber
|
|
168139
|
+
serialNumber,
|
|
168118
168140
|
// UniqueId helps controllers (especially Alexa) identify devices across
|
|
168119
168141
|
// multiple fabric connections. Using MD5 hash of entity_id for stability.
|
|
168120
168142
|
uniqueId: crypto6.createHash("md5").update(entity.entity_id).digest("hex").substring(0, 32)
|