@riddix/hamh 2.1.0-alpha.527 → 2.1.0-alpha.529
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
|
@@ -147567,7 +147567,7 @@ var DiagnosticService = class {
|
|
|
147567
147567
|
}
|
|
147568
147568
|
}
|
|
147569
147569
|
}
|
|
147570
|
-
const entities = this.collectEntities(bridge.aggregator);
|
|
147570
|
+
const entities = bridge.aggregator ? this.collectEntities(bridge.aggregator) : [];
|
|
147571
147571
|
return {
|
|
147572
147572
|
bridgeId: data.id,
|
|
147573
147573
|
bridgeName: data.name,
|
|
@@ -166283,6 +166283,7 @@ function validatePluginDevice(device) {
|
|
|
166283
166283
|
}
|
|
166284
166284
|
var PluginManager = class {
|
|
166285
166285
|
instances = /* @__PURE__ */ new Map();
|
|
166286
|
+
domainMappings = /* @__PURE__ */ new Map();
|
|
166286
166287
|
storageDir;
|
|
166287
166288
|
bridgeId;
|
|
166288
166289
|
runner = new SafePluginRunner();
|
|
@@ -166414,6 +166415,21 @@ var PluginManager = class {
|
|
|
166414
166415
|
clusterId3,
|
|
166415
166416
|
attributes7
|
|
166416
166417
|
);
|
|
166418
|
+
},
|
|
166419
|
+
registerDomainMapping: (mapping) => {
|
|
166420
|
+
if (!mapping.domain || typeof mapping.domain !== "string" || !mapping.matterDeviceType || typeof mapping.matterDeviceType !== "string") {
|
|
166421
|
+
pluginLogger.warn("Invalid domain mapping, skipping");
|
|
166422
|
+
return;
|
|
166423
|
+
}
|
|
166424
|
+
if (this.domainMappings.has(mapping.domain)) {
|
|
166425
|
+
pluginLogger.warn(
|
|
166426
|
+
`Domain "${mapping.domain}" already mapped by another plugin, overwriting`
|
|
166427
|
+
);
|
|
166428
|
+
}
|
|
166429
|
+
this.domainMappings.set(mapping.domain, mapping);
|
|
166430
|
+
pluginLogger.info(
|
|
166431
|
+
`Registered domain mapping: ${mapping.domain} \u2192 ${mapping.matterDeviceType}`
|
|
166432
|
+
);
|
|
166417
166433
|
}
|
|
166418
166434
|
};
|
|
166419
166435
|
this.instances.set(plugin.name, {
|
|
@@ -166539,6 +166555,9 @@ var PluginManager = class {
|
|
|
166539
166555
|
if (!instance) return void 0;
|
|
166540
166556
|
return instance.plugin.getConfigSchema?.();
|
|
166541
166557
|
}
|
|
166558
|
+
getDomainMappings() {
|
|
166559
|
+
return new Map(this.domainMappings);
|
|
166560
|
+
}
|
|
166542
166561
|
async updateConfig(pluginName, config10) {
|
|
166543
166562
|
const instance = this.instances.get(pluginName);
|
|
166544
166563
|
if (!instance) return false;
|
|
@@ -167718,6 +167737,26 @@ function PowerSourceServer2(config10) {
|
|
|
167718
167737
|
order: PowerSource3.Cluster.id
|
|
167719
167738
|
});
|
|
167720
167739
|
}
|
|
167740
|
+
var defaultBatteryConfig = {
|
|
167741
|
+
getBatteryPercent: (entity, agent) => {
|
|
167742
|
+
const homeAssistant = agent.get(HomeAssistantEntityBehavior);
|
|
167743
|
+
const batteryEntity = homeAssistant.state.mapping?.batteryEntity;
|
|
167744
|
+
if (batteryEntity) {
|
|
167745
|
+
const stateProvider = agent.env.get(EntityStateProvider);
|
|
167746
|
+
const battery = stateProvider.getBatteryPercent(batteryEntity);
|
|
167747
|
+
if (battery != null) {
|
|
167748
|
+
return Math.max(0, Math.min(100, battery));
|
|
167749
|
+
}
|
|
167750
|
+
}
|
|
167751
|
+
const attrs = entity.attributes;
|
|
167752
|
+
const level = attrs.battery_level ?? attrs.battery;
|
|
167753
|
+
if (level == null || Number.isNaN(Number(level))) {
|
|
167754
|
+
return null;
|
|
167755
|
+
}
|
|
167756
|
+
return Number(level);
|
|
167757
|
+
}
|
|
167758
|
+
};
|
|
167759
|
+
var DefaultPowerSourceServer = PowerSourceServer2(defaultBatteryConfig);
|
|
167721
167760
|
|
|
167722
167761
|
// src/matter/behaviors/temperature-measurement-server.ts
|
|
167723
167762
|
init_home_assistant_entity_behavior();
|
|
@@ -169227,6 +169266,9 @@ init_esm7();
|
|
|
169227
169266
|
import debounce4 from "debounce";
|
|
169228
169267
|
init_home_assistant_entity_behavior();
|
|
169229
169268
|
|
|
169269
|
+
// src/matter/endpoints/legacy/create-legacy-endpoint-type.ts
|
|
169270
|
+
init_esm();
|
|
169271
|
+
|
|
169230
169272
|
// src/matter/endpoints/legacy/air-purifier/index.ts
|
|
169231
169273
|
init_dist();
|
|
169232
169274
|
init_home_assistant_entity_behavior();
|
|
@@ -170802,25 +170844,6 @@ function ClimateThermostatServer(initialState = {}, features2) {
|
|
|
170802
170844
|
}
|
|
170803
170845
|
|
|
170804
170846
|
// src/matter/endpoints/legacy/climate/index.ts
|
|
170805
|
-
var ClimatePowerSourceServer = PowerSourceServer2({
|
|
170806
|
-
getBatteryPercent: (entity, agent) => {
|
|
170807
|
-
const homeAssistant = agent.get(HomeAssistantEntityBehavior);
|
|
170808
|
-
const batteryEntity = homeAssistant.state.mapping?.batteryEntity;
|
|
170809
|
-
if (batteryEntity) {
|
|
170810
|
-
const stateProvider = agent.env.get(EntityStateProvider);
|
|
170811
|
-
const battery = stateProvider.getBatteryPercent(batteryEntity);
|
|
170812
|
-
if (battery != null) {
|
|
170813
|
-
return Math.max(0, Math.min(100, battery));
|
|
170814
|
-
}
|
|
170815
|
-
}
|
|
170816
|
-
const attrs = entity.attributes;
|
|
170817
|
-
const level = attrs.battery_level ?? attrs.battery;
|
|
170818
|
-
if (level == null || Number.isNaN(Number(level))) {
|
|
170819
|
-
return null;
|
|
170820
|
-
}
|
|
170821
|
-
return Number(level);
|
|
170822
|
-
}
|
|
170823
|
-
});
|
|
170824
170847
|
var ClimateDeviceType = (supportsOnOff, supportsHumidity, supportsFanMode, hasBattery, features2, initialState = {}) => {
|
|
170825
170848
|
const additionalClusters = [];
|
|
170826
170849
|
if (supportsOnOff) {
|
|
@@ -170830,7 +170853,7 @@ var ClimateDeviceType = (supportsOnOff, supportsHumidity, supportsFanMode, hasBa
|
|
|
170830
170853
|
additionalClusters.push(ClimateHumidityMeasurementServer);
|
|
170831
170854
|
}
|
|
170832
170855
|
if (hasBattery) {
|
|
170833
|
-
additionalClusters.push(
|
|
170856
|
+
additionalClusters.push(DefaultPowerSourceServer);
|
|
170834
170857
|
}
|
|
170835
170858
|
const thermostatServer = ClimateThermostatServer(initialState, features2);
|
|
170836
170859
|
if (supportsFanMode) {
|
|
@@ -171424,25 +171447,6 @@ var CoverWindowCoveringServer = WindowCoveringServer2(config5);
|
|
|
171424
171447
|
|
|
171425
171448
|
// src/matter/endpoints/legacy/cover/index.ts
|
|
171426
171449
|
var logger177 = Logger.get("CoverDevice");
|
|
171427
|
-
var CoverPowerSourceServer = PowerSourceServer2({
|
|
171428
|
-
getBatteryPercent: (entity, agent) => {
|
|
171429
|
-
const homeAssistant = agent.get(HomeAssistantEntityBehavior);
|
|
171430
|
-
const batteryEntity = homeAssistant.state.mapping?.batteryEntity;
|
|
171431
|
-
if (batteryEntity) {
|
|
171432
|
-
const stateProvider = agent.env.get(EntityStateProvider);
|
|
171433
|
-
const battery = stateProvider.getBatteryPercent(batteryEntity);
|
|
171434
|
-
if (battery != null) {
|
|
171435
|
-
return Math.max(0, Math.min(100, battery));
|
|
171436
|
-
}
|
|
171437
|
-
}
|
|
171438
|
-
const attrs = entity.attributes;
|
|
171439
|
-
const level = attrs.battery_level ?? attrs.battery;
|
|
171440
|
-
if (level == null || Number.isNaN(Number(level))) {
|
|
171441
|
-
return null;
|
|
171442
|
-
}
|
|
171443
|
-
return Number(level);
|
|
171444
|
-
}
|
|
171445
|
-
});
|
|
171446
171450
|
var CoverDeviceType = (supportedFeatures, hasBattery, entityId) => {
|
|
171447
171451
|
const features2 = /* @__PURE__ */ new Set();
|
|
171448
171452
|
if (testBit(supportedFeatures, CoverSupportedFeatures.support_open)) {
|
|
@@ -171477,7 +171481,10 @@ var CoverDeviceType = (supportedFeatures, hasBattery, entityId) => {
|
|
|
171477
171481
|
CoverWindowCoveringServer.with(...features2)
|
|
171478
171482
|
];
|
|
171479
171483
|
if (hasBattery) {
|
|
171480
|
-
return WindowCoveringDevice.with(
|
|
171484
|
+
return WindowCoveringDevice.with(
|
|
171485
|
+
...baseBehaviors,
|
|
171486
|
+
DefaultPowerSourceServer
|
|
171487
|
+
);
|
|
171481
171488
|
}
|
|
171482
171489
|
return WindowCoveringDevice.with(...baseBehaviors);
|
|
171483
171490
|
};
|
|
@@ -171598,25 +171605,6 @@ function EventDevice(homeAssistantEntity) {
|
|
|
171598
171605
|
// src/matter/endpoints/legacy/fan/index.ts
|
|
171599
171606
|
init_dist();
|
|
171600
171607
|
init_home_assistant_entity_behavior();
|
|
171601
|
-
var FanPowerSourceServer = PowerSourceServer2({
|
|
171602
|
-
getBatteryPercent: (entity, agent) => {
|
|
171603
|
-
const homeAssistant = agent.get(HomeAssistantEntityBehavior);
|
|
171604
|
-
const batteryEntity = homeAssistant.state.mapping?.batteryEntity;
|
|
171605
|
-
if (batteryEntity) {
|
|
171606
|
-
const stateProvider = agent.env.get(EntityStateProvider);
|
|
171607
|
-
const battery = stateProvider.getBatteryPercent(batteryEntity);
|
|
171608
|
-
if (battery != null) {
|
|
171609
|
-
return Math.max(0, Math.min(100, battery));
|
|
171610
|
-
}
|
|
171611
|
-
}
|
|
171612
|
-
const attrs = entity.attributes;
|
|
171613
|
-
const level = attrs.battery_level ?? attrs.battery;
|
|
171614
|
-
if (level == null || Number.isNaN(Number(level))) {
|
|
171615
|
-
return null;
|
|
171616
|
-
}
|
|
171617
|
-
return Number(level);
|
|
171618
|
-
}
|
|
171619
|
-
});
|
|
171620
171608
|
function FanDevice2(homeAssistantEntity) {
|
|
171621
171609
|
const attributes7 = homeAssistantEntity.entity.state.attributes;
|
|
171622
171610
|
const supportedFeatures = attributes7.supported_features ?? 0;
|
|
@@ -171636,7 +171624,7 @@ function FanDevice2(homeAssistantEntity) {
|
|
|
171636
171624
|
BasicInformationServer2,
|
|
171637
171625
|
HomeAssistantEntityBehavior,
|
|
171638
171626
|
FanOnOffServer,
|
|
171639
|
-
|
|
171627
|
+
DefaultPowerSourceServer
|
|
171640
171628
|
) : OnOffPlugInUnitDevice.with(
|
|
171641
171629
|
IdentifyServer2,
|
|
171642
171630
|
BasicInformationServer2,
|
|
@@ -171671,7 +171659,7 @@ function FanDevice2(homeAssistantEntity) {
|
|
|
171671
171659
|
HomeAssistantEntityBehavior,
|
|
171672
171660
|
FanOnOffServer,
|
|
171673
171661
|
FanFanControlServer.with(...features2),
|
|
171674
|
-
|
|
171662
|
+
DefaultPowerSourceServer
|
|
171675
171663
|
) : FanDevice.with(
|
|
171676
171664
|
IdentifyServer2,
|
|
171677
171665
|
BasicInformationServer2,
|
|
@@ -172196,25 +172184,6 @@ var ColorTemperatureLightType = ColorTemperatureLightDevice.with(
|
|
|
172196
172184
|
|
|
172197
172185
|
// src/matter/endpoints/legacy/light/devices/dimmable-light.ts
|
|
172198
172186
|
init_home_assistant_entity_behavior();
|
|
172199
|
-
var LightPowerSourceServer = PowerSourceServer2({
|
|
172200
|
-
getBatteryPercent: (entity, agent) => {
|
|
172201
|
-
const homeAssistant = agent.get(HomeAssistantEntityBehavior);
|
|
172202
|
-
const batteryEntity = homeAssistant.state.mapping?.batteryEntity;
|
|
172203
|
-
if (batteryEntity) {
|
|
172204
|
-
const stateProvider = agent.env.get(EntityStateProvider);
|
|
172205
|
-
const battery = stateProvider.getBatteryPercent(batteryEntity);
|
|
172206
|
-
if (battery != null) {
|
|
172207
|
-
return Math.max(0, Math.min(100, battery));
|
|
172208
|
-
}
|
|
172209
|
-
}
|
|
172210
|
-
const attrs = entity.attributes;
|
|
172211
|
-
const level = attrs.battery_level ?? attrs.battery;
|
|
172212
|
-
if (level == null || Number.isNaN(Number(level))) {
|
|
172213
|
-
return null;
|
|
172214
|
-
}
|
|
172215
|
-
return Number(level);
|
|
172216
|
-
}
|
|
172217
|
-
});
|
|
172218
172187
|
var DimmableLightType = DimmableLightDevice.with(
|
|
172219
172188
|
IdentifyServer2,
|
|
172220
172189
|
BasicInformationServer2,
|
|
@@ -172228,30 +172197,11 @@ var DimmableLightWithBatteryType = DimmableLightDevice.with(
|
|
|
172228
172197
|
HomeAssistantEntityBehavior,
|
|
172229
172198
|
LightOnOffServer,
|
|
172230
172199
|
LightLevelControlServer,
|
|
172231
|
-
|
|
172200
|
+
DefaultPowerSourceServer
|
|
172232
172201
|
);
|
|
172233
172202
|
|
|
172234
172203
|
// src/matter/endpoints/legacy/light/devices/extended-color-light.ts
|
|
172235
172204
|
init_home_assistant_entity_behavior();
|
|
172236
|
-
var LightPowerSourceServer2 = PowerSourceServer2({
|
|
172237
|
-
getBatteryPercent: (entity, agent) => {
|
|
172238
|
-
const homeAssistant = agent.get(HomeAssistantEntityBehavior);
|
|
172239
|
-
const batteryEntity = homeAssistant.state.mapping?.batteryEntity;
|
|
172240
|
-
if (batteryEntity) {
|
|
172241
|
-
const stateProvider = agent.env.get(EntityStateProvider);
|
|
172242
|
-
const battery = stateProvider.getBatteryPercent(batteryEntity);
|
|
172243
|
-
if (battery != null) {
|
|
172244
|
-
return Math.max(0, Math.min(100, battery));
|
|
172245
|
-
}
|
|
172246
|
-
}
|
|
172247
|
-
const attrs = entity.attributes;
|
|
172248
|
-
const level = attrs.battery_level ?? attrs.battery;
|
|
172249
|
-
if (level == null || Number.isNaN(Number(level))) {
|
|
172250
|
-
return null;
|
|
172251
|
-
}
|
|
172252
|
-
return Number(level);
|
|
172253
|
-
}
|
|
172254
|
-
});
|
|
172255
172205
|
var ExtendedColorLightType = (supportsColorControl, supportsTemperature, hasBattery = false) => {
|
|
172256
172206
|
const features2 = /* @__PURE__ */ new Set();
|
|
172257
172207
|
if (supportsColorControl) {
|
|
@@ -172268,7 +172218,7 @@ var ExtendedColorLightType = (supportsColorControl, supportsTemperature, hasBatt
|
|
|
172268
172218
|
LightOnOffServer,
|
|
172269
172219
|
LightLevelControlServer,
|
|
172270
172220
|
LightColorControlServer.with(...features2),
|
|
172271
|
-
|
|
172221
|
+
DefaultPowerSourceServer
|
|
172272
172222
|
);
|
|
172273
172223
|
}
|
|
172274
172224
|
return ExtendedColorLightDevice.with(
|
|
@@ -172283,25 +172233,6 @@ var ExtendedColorLightType = (supportsColorControl, supportsTemperature, hasBatt
|
|
|
172283
172233
|
|
|
172284
172234
|
// src/matter/endpoints/legacy/light/devices/on-off-light-device.ts
|
|
172285
172235
|
init_home_assistant_entity_behavior();
|
|
172286
|
-
var LightPowerSourceServer3 = PowerSourceServer2({
|
|
172287
|
-
getBatteryPercent: (entity, agent) => {
|
|
172288
|
-
const homeAssistant = agent.get(HomeAssistantEntityBehavior);
|
|
172289
|
-
const batteryEntity = homeAssistant.state.mapping?.batteryEntity;
|
|
172290
|
-
if (batteryEntity) {
|
|
172291
|
-
const stateProvider = agent.env.get(EntityStateProvider);
|
|
172292
|
-
const battery = stateProvider.getBatteryPercent(batteryEntity);
|
|
172293
|
-
if (battery != null) {
|
|
172294
|
-
return Math.max(0, Math.min(100, battery));
|
|
172295
|
-
}
|
|
172296
|
-
}
|
|
172297
|
-
const attrs = entity.attributes;
|
|
172298
|
-
const level = attrs.battery_level ?? attrs.battery;
|
|
172299
|
-
if (level == null || Number.isNaN(Number(level))) {
|
|
172300
|
-
return null;
|
|
172301
|
-
}
|
|
172302
|
-
return Number(level);
|
|
172303
|
-
}
|
|
172304
|
-
});
|
|
172305
172236
|
var OnOffLightType = OnOffLightDevice.with(
|
|
172306
172237
|
IdentifyServer2,
|
|
172307
172238
|
BasicInformationServer2,
|
|
@@ -172313,7 +172244,7 @@ var OnOffLightWithBatteryType = OnOffLightDevice.with(
|
|
|
172313
172244
|
BasicInformationServer2,
|
|
172314
172245
|
HomeAssistantEntityBehavior,
|
|
172315
172246
|
LightOnOffServer,
|
|
172316
|
-
|
|
172247
|
+
DefaultPowerSourceServer
|
|
172317
172248
|
);
|
|
172318
172249
|
|
|
172319
172250
|
// src/matter/endpoints/legacy/light/index.ts
|
|
@@ -173004,25 +172935,6 @@ var lockServerConfig = {
|
|
|
173004
172935
|
unlock: () => ({ action: "lock.unlock" }),
|
|
173005
172936
|
unlatch: () => ({ action: "lock.open" })
|
|
173006
172937
|
};
|
|
173007
|
-
var LockPowerSourceServer = PowerSourceServer2({
|
|
173008
|
-
getBatteryPercent: (entity, agent) => {
|
|
173009
|
-
const homeAssistant = agent.get(HomeAssistantEntityBehavior);
|
|
173010
|
-
const batteryEntity = homeAssistant.state.mapping?.batteryEntity;
|
|
173011
|
-
if (batteryEntity) {
|
|
173012
|
-
const stateProvider = agent.env.get(EntityStateProvider);
|
|
173013
|
-
const battery = stateProvider.getBatteryPercent(batteryEntity);
|
|
173014
|
-
if (battery != null) {
|
|
173015
|
-
return Math.max(0, Math.min(100, battery));
|
|
173016
|
-
}
|
|
173017
|
-
}
|
|
173018
|
-
const attrs = entity.attributes;
|
|
173019
|
-
const level = attrs.battery_level ?? attrs.battery;
|
|
173020
|
-
if (level == null || Number.isNaN(Number(level))) {
|
|
173021
|
-
return null;
|
|
173022
|
-
}
|
|
173023
|
-
return Number(level);
|
|
173024
|
-
}
|
|
173025
|
-
});
|
|
173026
172938
|
var LockDeviceType = DoorLockDevice.with(
|
|
173027
172939
|
BasicInformationServer2,
|
|
173028
172940
|
IdentifyServer2,
|
|
@@ -173034,7 +172946,7 @@ var LockWithBatteryDeviceType = DoorLockDevice.with(
|
|
|
173034
172946
|
IdentifyServer2,
|
|
173035
172947
|
HomeAssistantEntityBehavior,
|
|
173036
172948
|
LockServerWithPin(lockServerConfig),
|
|
173037
|
-
|
|
172949
|
+
DefaultPowerSourceServer
|
|
173038
172950
|
);
|
|
173039
172951
|
var LockWithUnlatchDeviceType = DoorLockDevice.with(
|
|
173040
172952
|
BasicInformationServer2,
|
|
@@ -173047,7 +172959,7 @@ var LockWithUnlatchAndBatteryDeviceType = DoorLockDevice.with(
|
|
|
173047
172959
|
IdentifyServer2,
|
|
173048
172960
|
HomeAssistantEntityBehavior,
|
|
173049
172961
|
LockServerWithPinAndUnbolt(lockServerConfig),
|
|
173050
|
-
|
|
172962
|
+
DefaultPowerSourceServer
|
|
173051
172963
|
);
|
|
173052
172964
|
function LockDevice(homeAssistantEntity) {
|
|
173053
172965
|
const attrs = homeAssistantEntity.entity.state.attributes;
|
|
@@ -173629,25 +173541,7 @@ var PumpWithBatteryType = PumpDevice.with(
|
|
|
173629
173541
|
HomeAssistantEntityBehavior,
|
|
173630
173542
|
PumpOnOffServer,
|
|
173631
173543
|
PumpConfigurationAndControlServer2,
|
|
173632
|
-
|
|
173633
|
-
getBatteryPercent: (entity, agent) => {
|
|
173634
|
-
const homeAssistant = agent.get(HomeAssistantEntityBehavior);
|
|
173635
|
-
const batteryEntity = homeAssistant.state.mapping?.batteryEntity;
|
|
173636
|
-
if (batteryEntity) {
|
|
173637
|
-
const stateProvider = agent.env.get(EntityStateProvider);
|
|
173638
|
-
const battery = stateProvider.getBatteryPercent(batteryEntity);
|
|
173639
|
-
if (battery != null) {
|
|
173640
|
-
return Math.max(0, Math.min(100, battery));
|
|
173641
|
-
}
|
|
173642
|
-
}
|
|
173643
|
-
const attrs = entity.attributes;
|
|
173644
|
-
const level = attrs.battery_level ?? attrs.battery;
|
|
173645
|
-
if (level == null || Number.isNaN(Number(level))) {
|
|
173646
|
-
return null;
|
|
173647
|
-
}
|
|
173648
|
-
return Number(level);
|
|
173649
|
-
}
|
|
173650
|
-
})
|
|
173544
|
+
DefaultPowerSourceServer
|
|
173651
173545
|
);
|
|
173652
173546
|
function PumpEndpoint(homeAssistantEntity) {
|
|
173653
173547
|
const attrs = homeAssistantEntity.entity.state.attributes;
|
|
@@ -175459,25 +175353,7 @@ var SwitchWithBatteryEndpointType = OnOffPlugInUnitDevice.with(
|
|
|
175459
175353
|
IdentifyServer2,
|
|
175460
175354
|
HomeAssistantEntityBehavior,
|
|
175461
175355
|
SwitchOnOffServer,
|
|
175462
|
-
|
|
175463
|
-
getBatteryPercent: (entity, agent) => {
|
|
175464
|
-
const homeAssistant = agent.get(HomeAssistantEntityBehavior);
|
|
175465
|
-
const batteryEntity = homeAssistant.state.mapping?.batteryEntity;
|
|
175466
|
-
if (batteryEntity) {
|
|
175467
|
-
const stateProvider = agent.env.get(EntityStateProvider);
|
|
175468
|
-
const battery = stateProvider.getBatteryPercent(batteryEntity);
|
|
175469
|
-
if (battery != null) {
|
|
175470
|
-
return Math.max(0, Math.min(100, battery));
|
|
175471
|
-
}
|
|
175472
|
-
}
|
|
175473
|
-
const attrs = entity.attributes;
|
|
175474
|
-
const level = attrs.battery_level ?? attrs.battery;
|
|
175475
|
-
if (level == null || Number.isNaN(Number(level))) {
|
|
175476
|
-
return null;
|
|
175477
|
-
}
|
|
175478
|
-
return Number(level);
|
|
175479
|
-
}
|
|
175480
|
-
})
|
|
175356
|
+
DefaultPowerSourceServer
|
|
175481
175357
|
);
|
|
175482
175358
|
function SwitchDevice(homeAssistantEntity) {
|
|
175483
175359
|
const attrs = homeAssistantEntity.entity.state.attributes;
|
|
@@ -177679,25 +177555,7 @@ var ValveWithBatteryEndpointType = WaterValveDevice.with(
|
|
|
177679
177555
|
IdentifyServer2,
|
|
177680
177556
|
HomeAssistantEntityBehavior,
|
|
177681
177557
|
ValveServer,
|
|
177682
|
-
|
|
177683
|
-
getBatteryPercent: (entity, agent) => {
|
|
177684
|
-
const homeAssistant = agent.get(HomeAssistantEntityBehavior);
|
|
177685
|
-
const batteryEntity = homeAssistant.state.mapping?.batteryEntity;
|
|
177686
|
-
if (batteryEntity) {
|
|
177687
|
-
const stateProvider = agent.env.get(EntityStateProvider);
|
|
177688
|
-
const battery = stateProvider.getBatteryPercent(batteryEntity);
|
|
177689
|
-
if (battery != null) {
|
|
177690
|
-
return Math.max(0, Math.min(100, battery));
|
|
177691
|
-
}
|
|
177692
|
-
}
|
|
177693
|
-
const attrs = entity.attributes;
|
|
177694
|
-
const level = attrs.battery_level ?? attrs.battery;
|
|
177695
|
-
if (level == null || Number.isNaN(Number(level))) {
|
|
177696
|
-
return null;
|
|
177697
|
-
}
|
|
177698
|
-
return Number(level);
|
|
177699
|
-
}
|
|
177700
|
-
})
|
|
177558
|
+
DefaultPowerSourceServer
|
|
177701
177559
|
);
|
|
177702
177560
|
function ValveDevice(homeAssistantEntity) {
|
|
177703
177561
|
const attrs = homeAssistantEntity.entity.state.attributes;
|
|
@@ -177825,6 +177683,7 @@ function WaterHeaterDevice(homeAssistantEntity) {
|
|
|
177825
177683
|
}
|
|
177826
177684
|
|
|
177827
177685
|
// src/matter/endpoints/legacy/create-legacy-endpoint-type.ts
|
|
177686
|
+
var legacyLogger = Logger.get("LegacyEndpointType");
|
|
177828
177687
|
function createLegacyEndpointType(entity, mapping, areaName, options) {
|
|
177829
177688
|
const domain = entity.entity_id.split(".")[0];
|
|
177830
177689
|
const customName = mapping?.customName;
|
|
@@ -177844,10 +177703,20 @@ function createLegacyEndpointType(entity, mapping, areaName, options) {
|
|
|
177844
177703
|
);
|
|
177845
177704
|
} else {
|
|
177846
177705
|
const factory = deviceCtrs[domain];
|
|
177847
|
-
if (
|
|
177706
|
+
if (factory) {
|
|
177707
|
+
type = factory({ entity, customName, mapping });
|
|
177708
|
+
} else if (options?.pluginDomainMappings?.has(domain)) {
|
|
177709
|
+
const mappedType = options.pluginDomainMappings.get(domain);
|
|
177710
|
+
const mappedFactory = matterDeviceTypeFactories[mappedType];
|
|
177711
|
+
if (mappedFactory) {
|
|
177712
|
+
legacyLogger.info(
|
|
177713
|
+
`Using plugin domain mapping for "${domain}" \u2192 "${mappedType}"`
|
|
177714
|
+
);
|
|
177715
|
+
type = mappedFactory({ entity, customName, mapping });
|
|
177716
|
+
}
|
|
177717
|
+
} else {
|
|
177848
177718
|
return void 0;
|
|
177849
177719
|
}
|
|
177850
|
-
type = factory({ entity, customName, mapping });
|
|
177851
177720
|
}
|
|
177852
177721
|
}
|
|
177853
177722
|
if (!type) {
|
|
@@ -178190,7 +178059,7 @@ var UserComposedEndpoint = class _UserComposedEndpoint extends Endpoint {
|
|
|
178190
178059
|
// src/matter/endpoints/legacy/legacy-endpoint.ts
|
|
178191
178060
|
var logger199 = Logger.get("LegacyEndpoint");
|
|
178192
178061
|
var LegacyEndpoint = class _LegacyEndpoint extends EntityEndpoint {
|
|
178193
|
-
static async create(registry2, entityId, mapping) {
|
|
178062
|
+
static async create(registry2, entityId, mapping, pluginDomainMappings) {
|
|
178194
178063
|
const deviceRegistry = registry2.deviceOf(entityId);
|
|
178195
178064
|
let state = registry2.initialState(entityId);
|
|
178196
178065
|
const entity = registry2.entity(entityId);
|
|
@@ -178485,7 +178354,8 @@ var LegacyEndpoint = class _LegacyEndpoint extends EntityEndpoint {
|
|
|
178485
178354
|
const areaName = registry2.getAreaName(entityId);
|
|
178486
178355
|
const type = createLegacyEndpointType(payload, effectiveMapping, areaName, {
|
|
178487
178356
|
vacuumOnOff: registry2.isVacuumOnOffEnabled(),
|
|
178488
|
-
cleaningModeOptions
|
|
178357
|
+
cleaningModeOptions,
|
|
178358
|
+
pluginDomainMappings
|
|
178489
178359
|
});
|
|
178490
178360
|
if (!type) {
|
|
178491
178361
|
return;
|
|
@@ -178989,6 +178859,16 @@ var BridgeEndpointManager = class extends Service {
|
|
|
178989
178859
|
}
|
|
178990
178860
|
}
|
|
178991
178861
|
}
|
|
178862
|
+
getPluginDomainMappings() {
|
|
178863
|
+
if (!this.pluginManager) return void 0;
|
|
178864
|
+
const mappings = this.pluginManager.getDomainMappings();
|
|
178865
|
+
if (mappings.size === 0) return void 0;
|
|
178866
|
+
const result = /* @__PURE__ */ new Map();
|
|
178867
|
+
for (const [domain, mapping] of mappings) {
|
|
178868
|
+
result.set(domain, mapping.matterDeviceType);
|
|
178869
|
+
}
|
|
178870
|
+
return result;
|
|
178871
|
+
}
|
|
178992
178872
|
getEntityMapping(entityId) {
|
|
178993
178873
|
return this.mappingStorage.getMapping(this.bridgeId, entityId);
|
|
178994
178874
|
}
|
|
@@ -179144,10 +179024,12 @@ var BridgeEndpointManager = class extends Service {
|
|
|
179144
179024
|
let endpoint = existingEndpoints.find((e) => e.entityId === entityId);
|
|
179145
179025
|
if (!endpoint) {
|
|
179146
179026
|
try {
|
|
179027
|
+
const domainMappings = this.getPluginDomainMappings();
|
|
179147
179028
|
endpoint = await LegacyEndpoint.create(
|
|
179148
179029
|
this.registry,
|
|
179149
179030
|
entityId,
|
|
179150
|
-
mapping
|
|
179031
|
+
mapping,
|
|
179032
|
+
domainMappings
|
|
179151
179033
|
);
|
|
179152
179034
|
} catch (e) {
|
|
179153
179035
|
const reason = this.extractErrorReason(e);
|
|
@@ -181170,8 +181052,7 @@ process.on("unhandledRejection", (reason) => {
|
|
|
181170
181052
|
if (shouldSuppressError(reason)) {
|
|
181171
181053
|
return;
|
|
181172
181054
|
}
|
|
181173
|
-
console.error("Unhandled rejection:", reason);
|
|
181174
|
-
process.exit(1);
|
|
181055
|
+
console.error("Unhandled rejection (process continuing):", reason);
|
|
181175
181056
|
});
|
|
181176
181057
|
function registerFinalErrorHandlers() {
|
|
181177
181058
|
process.removeAllListeners("uncaughtException");
|
|
@@ -181197,8 +181078,7 @@ function registerFinalErrorHandlers() {
|
|
|
181197
181078
|
console.warn("Suppressed Matter.js internal error:", reason);
|
|
181198
181079
|
return;
|
|
181199
181080
|
}
|
|
181200
|
-
console.error("Unhandled rejection:", reason);
|
|
181201
|
-
process.exit(1);
|
|
181081
|
+
console.error("Unhandled rejection (process continuing):", reason);
|
|
181202
181082
|
});
|
|
181203
181083
|
}
|
|
181204
181084
|
async function startHandler(startOptions, webUiDist) {
|