@riddix/hamh 2.1.0-alpha.444 → 2.1.0-alpha.445
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
|
@@ -146057,14 +146057,23 @@ var init_clusters2 = __esm({
|
|
|
146057
146057
|
ClusterId3["bridgedDeviceBasicInformation"] = "bridgedDeviceBasicInformation";
|
|
146058
146058
|
ClusterId3["airQuality"] = "airQuality";
|
|
146059
146059
|
ClusterId3["booleanState"] = "booleanState";
|
|
146060
|
+
ClusterId3["carbonDioxideConcentrationMeasurement"] = "carbonDioxideConcentrationMeasurement";
|
|
146061
|
+
ClusterId3["carbonMonoxideConcentrationMeasurement"] = "carbonMonoxideConcentrationMeasurement";
|
|
146060
146062
|
ClusterId3["colorControl"] = "colorControl";
|
|
146061
146063
|
ClusterId3["doorLock"] = "doorLock";
|
|
146064
|
+
ClusterId3["electricalEnergyMeasurement"] = "electricalEnergyMeasurement";
|
|
146065
|
+
ClusterId3["electricalPowerMeasurement"] = "electricalPowerMeasurement";
|
|
146062
146066
|
ClusterId3["flowMeasurement"] = "flowMeasurement";
|
|
146063
146067
|
ClusterId3["levelControl"] = "levelControl";
|
|
146064
146068
|
ClusterId3["fanControl"] = "fanControl";
|
|
146065
146069
|
ClusterId3["illuminanceMeasurement"] = "illuminanceMeasurement";
|
|
146070
|
+
ClusterId3["nitrogenDioxideConcentrationMeasurement"] = "nitrogenDioxideConcentrationMeasurement";
|
|
146066
146071
|
ClusterId3["occupancySensing"] = "occupancySensing";
|
|
146067
146072
|
ClusterId3["onOff"] = "onOff";
|
|
146073
|
+
ClusterId3["ozoneConcentrationMeasurement"] = "ozoneConcentrationMeasurement";
|
|
146074
|
+
ClusterId3["pm1ConcentrationMeasurement"] = "pm1ConcentrationMeasurement";
|
|
146075
|
+
ClusterId3["pm10ConcentrationMeasurement"] = "pm10ConcentrationMeasurement";
|
|
146076
|
+
ClusterId3["pm25ConcentrationMeasurement"] = "pm25ConcentrationMeasurement";
|
|
146068
146077
|
ClusterId3["powerSource"] = "powerSource";
|
|
146069
146078
|
ClusterId3["pressureMeasurement"] = "pressureMeasurement";
|
|
146070
146079
|
ClusterId3["relativeHumidityMeasurement"] = "relativeHumidityMeasurement";
|
|
@@ -146072,6 +146081,7 @@ var init_clusters2 = __esm({
|
|
|
146072
146081
|
ClusterId3["temperatureMeasurement"] = "temperatureMeasurement";
|
|
146073
146082
|
ClusterId3["thermostat"] = "thermostat";
|
|
146074
146083
|
ClusterId3["thermostatUserInterfaceConfiguration"] = "thermostatUserInterfaceConfiguration";
|
|
146084
|
+
ClusterId3["totalVolatileOrganicCompoundsConcentrationMeasurement"] = "totalVolatileOrganicCompoundsConcentrationMeasurement";
|
|
146075
146085
|
ClusterId3["valveConfigurationAndControl"] = "valveConfigurationAndControl";
|
|
146076
146086
|
ClusterId3["windowCovering"] = "windowCovering";
|
|
146077
146087
|
ClusterId3["mediaInput"] = "mediaInput";
|
|
@@ -162324,6 +162334,7 @@ var SolarPowerDeviceDefinition = MutableEndpoint({
|
|
|
162324
162334
|
behaviors: SupportedBehaviors()
|
|
162325
162335
|
});
|
|
162326
162336
|
Object.freeze(SolarPowerDeviceDefinition);
|
|
162337
|
+
var SolarPowerDevice = SolarPowerDeviceDefinition;
|
|
162327
162338
|
|
|
162328
162339
|
// ../../node_modules/.pnpm/@matter+node@0.16.10/node_modules/@matter/node/dist/esm/devices/speaker.js
|
|
162329
162340
|
init_MutableEndpoint();
|
|
@@ -169429,6 +169440,12 @@ init_home_assistant_entity_behavior();
|
|
|
169429
169440
|
var logger170 = Logger.get("ColorControlServer");
|
|
169430
169441
|
var optimisticColorTimestamps = /* @__PURE__ */ new Map();
|
|
169431
169442
|
var OPTIMISTIC_COLOR_COOLDOWN_MS = 2e3;
|
|
169443
|
+
var pendingColorStaging = /* @__PURE__ */ new Map();
|
|
169444
|
+
function consumePendingColorStaging(entityId) {
|
|
169445
|
+
const data = pendingColorStaging.get(entityId);
|
|
169446
|
+
pendingColorStaging.delete(entityId);
|
|
169447
|
+
return data;
|
|
169448
|
+
}
|
|
169432
169449
|
var FeaturedBase7 = ColorControlServer.with("ColorTemperature", "HueSaturation");
|
|
169433
169450
|
var ColorControlServerBase = class extends FeaturedBase7 {
|
|
169434
169451
|
pendingTransitionTime;
|
|
@@ -169566,6 +169583,10 @@ var ColorControlServerBase = class extends FeaturedBase7 {
|
|
|
169566
169583
|
colorMode: ColorControl3.ColorMode.ColorTemperatureMireds
|
|
169567
169584
|
});
|
|
169568
169585
|
optimisticColorTimestamps.set(homeAssistant.entityId, Date.now());
|
|
169586
|
+
if (this.isLightOff()) {
|
|
169587
|
+
pendingColorStaging.set(homeAssistant.entityId, action.data ?? {});
|
|
169588
|
+
return;
|
|
169589
|
+
}
|
|
169569
169590
|
homeAssistant.callAction(action);
|
|
169570
169591
|
}
|
|
169571
169592
|
moveToHueLogic(targetHue) {
|
|
@@ -169597,8 +169618,16 @@ var ColorControlServerBase = class extends FeaturedBase7 {
|
|
|
169597
169618
|
colorMode: ColorControl3.ColorMode.CurrentHueAndCurrentSaturation
|
|
169598
169619
|
});
|
|
169599
169620
|
optimisticColorTimestamps.set(homeAssistant.entityId, Date.now());
|
|
169621
|
+
if (this.isLightOff()) {
|
|
169622
|
+
pendingColorStaging.set(homeAssistant.entityId, action.data ?? {});
|
|
169623
|
+
return;
|
|
169624
|
+
}
|
|
169600
169625
|
homeAssistant.callAction(action);
|
|
169601
169626
|
}
|
|
169627
|
+
isLightOff() {
|
|
169628
|
+
const homeAssistant = this.agent.get(HomeAssistantEntityBehavior);
|
|
169629
|
+
return homeAssistant.entity.state.state === "off";
|
|
169630
|
+
}
|
|
169602
169631
|
applyTransition(action) {
|
|
169603
169632
|
const tenths = this.pendingTransitionTime;
|
|
169604
169633
|
this.pendingTransitionTime = void 0;
|
|
@@ -169698,12 +169727,16 @@ var LightLevelControlServer = LevelControlServer2(config8).with(
|
|
|
169698
169727
|
);
|
|
169699
169728
|
|
|
169700
169729
|
// src/matter/endpoints/legacy/light/behaviors/light-on-off-server.ts
|
|
169730
|
+
init_home_assistant_entity_behavior();
|
|
169701
169731
|
var LightOnOffServer = OnOffServer2({
|
|
169702
|
-
turnOn: () =>
|
|
169703
|
-
|
|
169704
|
-
|
|
169705
|
-
|
|
169706
|
-
|
|
169732
|
+
turnOn: (_value, agent) => {
|
|
169733
|
+
const entityId = agent.get(HomeAssistantEntityBehavior).entityId;
|
|
169734
|
+
const staged = consumePendingColorStaging(entityId);
|
|
169735
|
+
return {
|
|
169736
|
+
action: "light.turn_on",
|
|
169737
|
+
data: staged
|
|
169738
|
+
};
|
|
169739
|
+
},
|
|
169707
169740
|
turnOff: () => ({
|
|
169708
169741
|
action: "homeassistant.turn_off"
|
|
169709
169742
|
}),
|
|
@@ -171337,34 +171370,686 @@ var AirQualitySensorServerImpl = class extends AirQualityServerWithFeatures {
|
|
|
171337
171370
|
applyPatchState(this.state, { airQuality });
|
|
171338
171371
|
}
|
|
171339
171372
|
};
|
|
171340
|
-
var AirQualitySensorType = AirQualitySensorDevice.with(
|
|
171373
|
+
var AirQualitySensorType = AirQualitySensorDevice.with(
|
|
171374
|
+
BasicInformationServer2,
|
|
171375
|
+
IdentifyServer2,
|
|
171376
|
+
HomeAssistantEntityBehavior,
|
|
171377
|
+
AirQualitySensorServerImpl
|
|
171378
|
+
);
|
|
171379
|
+
|
|
171380
|
+
// src/matter/endpoints/legacy/sensor/devices/battery-sensor.ts
|
|
171381
|
+
init_home_assistant_entity_behavior();
|
|
171382
|
+
var BatterySensorType = BatteryStorageDevice.with(
|
|
171383
|
+
BasicInformationServer2,
|
|
171384
|
+
IdentifyServer2,
|
|
171385
|
+
HomeAssistantEntityBehavior,
|
|
171386
|
+
PowerSourceServer2({
|
|
171387
|
+
getBatteryPercent(entity) {
|
|
171388
|
+
const state = entity.state;
|
|
171389
|
+
if (state == null || Number.isNaN(+state)) {
|
|
171390
|
+
return null;
|
|
171391
|
+
}
|
|
171392
|
+
return +state;
|
|
171393
|
+
}
|
|
171394
|
+
})
|
|
171395
|
+
);
|
|
171396
|
+
|
|
171397
|
+
// src/matter/behaviors/carbon-monoxide-concentration-measurement-server.ts
|
|
171398
|
+
init_home_assistant_entity_behavior();
|
|
171399
|
+
var CarbonMonoxideConcentrationMeasurementServerBase = CarbonMonoxideConcentrationMeasurementServer.with(
|
|
171400
|
+
ConcentrationMeasurement3.Feature.NumericMeasurement
|
|
171401
|
+
);
|
|
171402
|
+
var CarbonMonoxideConcentrationMeasurementServer2 = class extends CarbonMonoxideConcentrationMeasurementServerBase {
|
|
171403
|
+
async initialize() {
|
|
171404
|
+
if (this.state.measuredValue === void 0) {
|
|
171405
|
+
this.state.measuredValue = null;
|
|
171406
|
+
}
|
|
171407
|
+
if (this.state.minMeasuredValue === void 0) {
|
|
171408
|
+
this.state.minMeasuredValue = null;
|
|
171409
|
+
}
|
|
171410
|
+
if (this.state.maxMeasuredValue === void 0) {
|
|
171411
|
+
this.state.maxMeasuredValue = null;
|
|
171412
|
+
}
|
|
171413
|
+
if (this.state.uncertainty === void 0) {
|
|
171414
|
+
this.state.uncertainty = 0;
|
|
171415
|
+
}
|
|
171416
|
+
if (this.state.measurementUnit === void 0) {
|
|
171417
|
+
this.state.measurementUnit = ConcentrationMeasurement3.MeasurementUnit.Ppm;
|
|
171418
|
+
}
|
|
171419
|
+
if (this.state.measurementMedium === void 0) {
|
|
171420
|
+
this.state.measurementMedium = ConcentrationMeasurement3.MeasurementMedium.Air;
|
|
171421
|
+
}
|
|
171422
|
+
await super.initialize();
|
|
171423
|
+
const homeAssistant = await this.agent.load(HomeAssistantEntityBehavior);
|
|
171424
|
+
this.update(homeAssistant.entity);
|
|
171425
|
+
this.reactTo(homeAssistant.onChange, this.update);
|
|
171426
|
+
}
|
|
171427
|
+
update(entity) {
|
|
171428
|
+
if (!entity.state) {
|
|
171429
|
+
return;
|
|
171430
|
+
}
|
|
171431
|
+
const state = entity.state.state;
|
|
171432
|
+
let measuredValue = null;
|
|
171433
|
+
if (state != null && !Number.isNaN(+state)) {
|
|
171434
|
+
measuredValue = +state;
|
|
171435
|
+
}
|
|
171436
|
+
applyPatchState(this.state, { measuredValue });
|
|
171437
|
+
}
|
|
171438
|
+
};
|
|
171439
|
+
|
|
171440
|
+
// src/matter/endpoints/legacy/sensor/devices/carbon-monoxide-sensor.ts
|
|
171441
|
+
init_home_assistant_entity_behavior();
|
|
171442
|
+
var CoAirQualityServerBase = AirQualityServer.with(
|
|
171443
|
+
AirQuality3.Feature.Fair,
|
|
171444
|
+
AirQuality3.Feature.Moderate,
|
|
171445
|
+
AirQuality3.Feature.VeryPoor,
|
|
171446
|
+
AirQuality3.Feature.ExtremelyPoor
|
|
171447
|
+
);
|
|
171448
|
+
var CoAirQualityServer = class extends CoAirQualityServerBase {
|
|
171449
|
+
async initialize() {
|
|
171450
|
+
if (this.state.airQuality === void 0) {
|
|
171451
|
+
this.state.airQuality = AirQuality3.AirQualityEnum.Unknown;
|
|
171452
|
+
}
|
|
171453
|
+
await super.initialize();
|
|
171454
|
+
const homeAssistant = await this.agent.load(HomeAssistantEntityBehavior);
|
|
171455
|
+
this.update(homeAssistant.entity);
|
|
171456
|
+
this.reactTo(homeAssistant.onChange, this.update);
|
|
171457
|
+
}
|
|
171458
|
+
update(entity) {
|
|
171459
|
+
const state = entity.state.state;
|
|
171460
|
+
let airQuality = AirQuality3.AirQualityEnum.Unknown;
|
|
171461
|
+
if (state != null && !Number.isNaN(+state)) {
|
|
171462
|
+
const ppm = +state;
|
|
171463
|
+
if (ppm <= 9) {
|
|
171464
|
+
airQuality = AirQuality3.AirQualityEnum.Good;
|
|
171465
|
+
} else if (ppm <= 25) {
|
|
171466
|
+
airQuality = AirQuality3.AirQualityEnum.Fair;
|
|
171467
|
+
} else if (ppm <= 50) {
|
|
171468
|
+
airQuality = AirQuality3.AirQualityEnum.Moderate;
|
|
171469
|
+
} else if (ppm <= 100) {
|
|
171470
|
+
airQuality = AirQuality3.AirQualityEnum.Poor;
|
|
171471
|
+
} else if (ppm <= 200) {
|
|
171472
|
+
airQuality = AirQuality3.AirQualityEnum.VeryPoor;
|
|
171473
|
+
} else {
|
|
171474
|
+
airQuality = AirQuality3.AirQualityEnum.ExtremelyPoor;
|
|
171475
|
+
}
|
|
171476
|
+
}
|
|
171477
|
+
applyPatchState(this.state, { airQuality });
|
|
171478
|
+
}
|
|
171479
|
+
};
|
|
171480
|
+
var CarbonMonoxideSensorType = AirQualitySensorDevice.with(
|
|
171481
|
+
BasicInformationServer2,
|
|
171482
|
+
IdentifyServer2,
|
|
171483
|
+
HomeAssistantEntityBehavior,
|
|
171484
|
+
CoAirQualityServer,
|
|
171485
|
+
CarbonMonoxideConcentrationMeasurementServer2
|
|
171486
|
+
);
|
|
171487
|
+
|
|
171488
|
+
// src/matter/endpoints/legacy/sensor/devices/electrical-sensor.ts
|
|
171489
|
+
init_dist();
|
|
171490
|
+
init_home_assistant_entity_behavior();
|
|
171491
|
+
var StandalonePowerServer = class extends ElectricalPowerMeasurementServer {
|
|
171492
|
+
async initialize() {
|
|
171493
|
+
await super.initialize();
|
|
171494
|
+
const homeAssistant = await this.agent.load(HomeAssistantEntityBehavior);
|
|
171495
|
+
this.update(homeAssistant.entity);
|
|
171496
|
+
this.reactTo(homeAssistant.onChange, this.update);
|
|
171497
|
+
}
|
|
171498
|
+
update(entity) {
|
|
171499
|
+
const state = entity.state.state;
|
|
171500
|
+
if (state == null || Number.isNaN(+state)) return;
|
|
171501
|
+
const attrs = entity.state.attributes;
|
|
171502
|
+
const dc = attrs.device_class;
|
|
171503
|
+
if (dc === SensorDeviceClass.power) {
|
|
171504
|
+
applyPatchState(this.state, {
|
|
171505
|
+
activePower: Math.round(+state * 1e3)
|
|
171506
|
+
});
|
|
171507
|
+
} else if (dc === SensorDeviceClass.voltage) {
|
|
171508
|
+
applyPatchState(this.state, {
|
|
171509
|
+
voltage: Math.round(+state * 1e3)
|
|
171510
|
+
});
|
|
171511
|
+
} else if (dc === SensorDeviceClass.current) {
|
|
171512
|
+
applyPatchState(this.state, {
|
|
171513
|
+
activeCurrent: Math.round(+state * 1e3)
|
|
171514
|
+
});
|
|
171515
|
+
}
|
|
171516
|
+
}
|
|
171517
|
+
};
|
|
171518
|
+
((StandalonePowerServer2) => {
|
|
171519
|
+
class State extends ElectricalPowerMeasurementServer.State {
|
|
171520
|
+
}
|
|
171521
|
+
StandalonePowerServer2.State = State;
|
|
171522
|
+
})(StandalonePowerServer || (StandalonePowerServer = {}));
|
|
171523
|
+
var PowerServer = StandalonePowerServer.set({
|
|
171524
|
+
powerMode: ElectricalPowerMeasurement3.PowerMode.Ac,
|
|
171525
|
+
numberOfMeasurementTypes: 1,
|
|
171526
|
+
accuracy: [
|
|
171527
|
+
{
|
|
171528
|
+
measurementType: ElectricalPowerMeasurement3.MeasurementType.ActivePower,
|
|
171529
|
+
measured: true,
|
|
171530
|
+
minMeasuredValue: -1e6,
|
|
171531
|
+
maxMeasuredValue: 1e8,
|
|
171532
|
+
accuracyRanges: [
|
|
171533
|
+
{
|
|
171534
|
+
rangeMin: -1e6,
|
|
171535
|
+
rangeMax: 1e8,
|
|
171536
|
+
fixedMax: 1e3
|
|
171537
|
+
}
|
|
171538
|
+
]
|
|
171539
|
+
}
|
|
171540
|
+
]
|
|
171541
|
+
});
|
|
171542
|
+
var EnergyFeaturedBase = ElectricalEnergyMeasurementServer.with(
|
|
171543
|
+
"CumulativeEnergy",
|
|
171544
|
+
"ImportedEnergy"
|
|
171545
|
+
);
|
|
171546
|
+
var StandaloneEnergyServer = class extends EnergyFeaturedBase {
|
|
171547
|
+
async initialize() {
|
|
171548
|
+
await super.initialize();
|
|
171549
|
+
const homeAssistant = await this.agent.load(HomeAssistantEntityBehavior);
|
|
171550
|
+
this.update(homeAssistant.entity);
|
|
171551
|
+
this.reactTo(homeAssistant.onChange, this.update);
|
|
171552
|
+
}
|
|
171553
|
+
update(entity) {
|
|
171554
|
+
const attrs = entity.state.attributes;
|
|
171555
|
+
if (attrs.device_class !== SensorDeviceClass.energy) return;
|
|
171556
|
+
const state = entity.state.state;
|
|
171557
|
+
if (state == null || Number.isNaN(+state)) return;
|
|
171558
|
+
const energyMwh = Math.round(+state * 1e6);
|
|
171559
|
+
const energyImported = { energy: energyMwh };
|
|
171560
|
+
applyPatchState(this.state, {
|
|
171561
|
+
cumulativeEnergyImported: energyImported
|
|
171562
|
+
});
|
|
171563
|
+
this.events.cumulativeEnergyMeasured?.emit(
|
|
171564
|
+
{ energyImported, energyExported: void 0 },
|
|
171565
|
+
this.context
|
|
171566
|
+
);
|
|
171567
|
+
}
|
|
171568
|
+
};
|
|
171569
|
+
((StandaloneEnergyServer2) => {
|
|
171570
|
+
class State extends EnergyFeaturedBase.State {
|
|
171571
|
+
}
|
|
171572
|
+
StandaloneEnergyServer2.State = State;
|
|
171573
|
+
})(StandaloneEnergyServer || (StandaloneEnergyServer = {}));
|
|
171574
|
+
var EnergyServer = StandaloneEnergyServer.set({
|
|
171575
|
+
accuracy: {
|
|
171576
|
+
measurementType: ElectricalPowerMeasurement3.MeasurementType.ElectricalEnergy,
|
|
171577
|
+
measured: true,
|
|
171578
|
+
minMeasuredValue: -1e6,
|
|
171579
|
+
maxMeasuredValue: 1e11,
|
|
171580
|
+
accuracyRanges: [
|
|
171581
|
+
{
|
|
171582
|
+
rangeMin: -1e6,
|
|
171583
|
+
rangeMax: 1e11,
|
|
171584
|
+
fixedMax: 1e3
|
|
171585
|
+
}
|
|
171586
|
+
]
|
|
171587
|
+
}
|
|
171588
|
+
});
|
|
171589
|
+
var ElectricalSensorType = SolarPowerDevice.with(
|
|
171590
|
+
BasicInformationServer2,
|
|
171591
|
+
IdentifyServer2,
|
|
171592
|
+
HomeAssistantEntityBehavior,
|
|
171593
|
+
PowerServer,
|
|
171594
|
+
EnergyServer
|
|
171595
|
+
);
|
|
171596
|
+
|
|
171597
|
+
// src/matter/behaviors/flow-measurement-server.ts
|
|
171598
|
+
init_home_assistant_entity_behavior();
|
|
171599
|
+
var FlowMeasurementServerBase = class extends FlowMeasurementServer {
|
|
171600
|
+
async initialize() {
|
|
171601
|
+
await super.initialize();
|
|
171602
|
+
const homeAssistant = await this.agent.load(HomeAssistantEntityBehavior);
|
|
171603
|
+
this.update(homeAssistant.entity);
|
|
171604
|
+
this.reactTo(homeAssistant.onChange, this.update);
|
|
171605
|
+
}
|
|
171606
|
+
update(entity) {
|
|
171607
|
+
if (!entity.state) {
|
|
171608
|
+
return;
|
|
171609
|
+
}
|
|
171610
|
+
applyPatchState(this.state, {
|
|
171611
|
+
measuredValue: this.getFlow(entity.state) ?? null,
|
|
171612
|
+
// min/max values in 0.1 m³/h units: 0 to 65534 (max uint16)
|
|
171613
|
+
minMeasuredValue: 0,
|
|
171614
|
+
maxMeasuredValue: 65534
|
|
171615
|
+
});
|
|
171616
|
+
}
|
|
171617
|
+
getFlow(entity) {
|
|
171618
|
+
const value = this.state.config.getValue(entity, this.agent);
|
|
171619
|
+
if (value == null) {
|
|
171620
|
+
return void 0;
|
|
171621
|
+
}
|
|
171622
|
+
return Math.round(value * 10);
|
|
171623
|
+
}
|
|
171624
|
+
};
|
|
171625
|
+
((FlowMeasurementServerBase2) => {
|
|
171626
|
+
class State extends FlowMeasurementServer.State {
|
|
171627
|
+
config;
|
|
171628
|
+
}
|
|
171629
|
+
FlowMeasurementServerBase2.State = State;
|
|
171630
|
+
})(FlowMeasurementServerBase || (FlowMeasurementServerBase = {}));
|
|
171631
|
+
function FlowMeasurementServer2(config10) {
|
|
171632
|
+
return FlowMeasurementServerBase.set({ config: config10 });
|
|
171633
|
+
}
|
|
171634
|
+
|
|
171635
|
+
// src/matter/endpoints/legacy/sensor/devices/flow-sensor.ts
|
|
171636
|
+
init_home_assistant_entity_behavior();
|
|
171637
|
+
var flowSensorConfig = {
|
|
171638
|
+
getValue(entity) {
|
|
171639
|
+
const state = entity.state;
|
|
171640
|
+
const attributes7 = entity.attributes;
|
|
171641
|
+
const flow = state == null || Number.isNaN(+state) ? null : +state;
|
|
171642
|
+
if (flow == null) {
|
|
171643
|
+
return void 0;
|
|
171644
|
+
}
|
|
171645
|
+
const unit = attributes7.unit_of_measurement?.toLowerCase();
|
|
171646
|
+
if (unit === "l/min") {
|
|
171647
|
+
return flow * 0.06;
|
|
171648
|
+
}
|
|
171649
|
+
if (unit === "l/h") {
|
|
171650
|
+
return flow / 1e3;
|
|
171651
|
+
}
|
|
171652
|
+
if (unit === "gal/min" || unit === "gpm") {
|
|
171653
|
+
return flow * 0.227;
|
|
171654
|
+
}
|
|
171655
|
+
if (unit === "m\xB3/h" || unit === "m3/h") {
|
|
171656
|
+
return flow;
|
|
171657
|
+
}
|
|
171658
|
+
return flow;
|
|
171659
|
+
}
|
|
171660
|
+
};
|
|
171661
|
+
var FlowSensorType = FlowSensorDevice.with(
|
|
171662
|
+
BasicInformationServer2,
|
|
171663
|
+
IdentifyServer2,
|
|
171664
|
+
HomeAssistantEntityBehavior,
|
|
171665
|
+
FlowMeasurementServer2(flowSensorConfig)
|
|
171666
|
+
);
|
|
171667
|
+
|
|
171668
|
+
// src/matter/behaviors/formaldehyde-concentration-measurement-server.ts
|
|
171669
|
+
init_home_assistant_entity_behavior();
|
|
171670
|
+
var FormaldehydeConcentrationMeasurementServerBase = FormaldehydeConcentrationMeasurementServer.with(
|
|
171671
|
+
ConcentrationMeasurement3.Feature.NumericMeasurement
|
|
171672
|
+
);
|
|
171673
|
+
var FormaldehydeConcentrationMeasurementServer2 = class extends FormaldehydeConcentrationMeasurementServerBase {
|
|
171674
|
+
async initialize() {
|
|
171675
|
+
if (this.state.measuredValue === void 0) {
|
|
171676
|
+
this.state.measuredValue = null;
|
|
171677
|
+
}
|
|
171678
|
+
if (this.state.minMeasuredValue === void 0) {
|
|
171679
|
+
this.state.minMeasuredValue = null;
|
|
171680
|
+
}
|
|
171681
|
+
if (this.state.maxMeasuredValue === void 0) {
|
|
171682
|
+
this.state.maxMeasuredValue = null;
|
|
171683
|
+
}
|
|
171684
|
+
if (this.state.uncertainty === void 0) {
|
|
171685
|
+
this.state.uncertainty = 0;
|
|
171686
|
+
}
|
|
171687
|
+
if (this.state.measurementUnit === void 0) {
|
|
171688
|
+
this.state.measurementUnit = ConcentrationMeasurement3.MeasurementUnit.Ugm3;
|
|
171689
|
+
}
|
|
171690
|
+
if (this.state.measurementMedium === void 0) {
|
|
171691
|
+
this.state.measurementMedium = ConcentrationMeasurement3.MeasurementMedium.Air;
|
|
171692
|
+
}
|
|
171693
|
+
await super.initialize();
|
|
171694
|
+
const homeAssistant = await this.agent.load(HomeAssistantEntityBehavior);
|
|
171695
|
+
this.update(homeAssistant.entity);
|
|
171696
|
+
this.reactTo(homeAssistant.onChange, this.update);
|
|
171697
|
+
}
|
|
171698
|
+
update(entity) {
|
|
171699
|
+
if (!entity.state) {
|
|
171700
|
+
return;
|
|
171701
|
+
}
|
|
171702
|
+
const state = entity.state.state;
|
|
171703
|
+
let measuredValue = null;
|
|
171704
|
+
if (state != null && !Number.isNaN(+state)) {
|
|
171705
|
+
measuredValue = +state;
|
|
171706
|
+
}
|
|
171707
|
+
applyPatchState(this.state, { measuredValue });
|
|
171708
|
+
}
|
|
171709
|
+
};
|
|
171710
|
+
|
|
171711
|
+
// src/matter/endpoints/legacy/sensor/devices/formaldehyde-sensor.ts
|
|
171712
|
+
init_home_assistant_entity_behavior();
|
|
171713
|
+
var FormaldehydeAirQualityServerBase = AirQualityServer.with(
|
|
171714
|
+
AirQuality3.Feature.Fair,
|
|
171715
|
+
AirQuality3.Feature.Moderate,
|
|
171716
|
+
AirQuality3.Feature.VeryPoor,
|
|
171717
|
+
AirQuality3.Feature.ExtremelyPoor
|
|
171718
|
+
);
|
|
171719
|
+
var FormaldehydeAirQualityServer = class extends FormaldehydeAirQualityServerBase {
|
|
171720
|
+
async initialize() {
|
|
171721
|
+
if (this.state.airQuality === void 0) {
|
|
171722
|
+
this.state.airQuality = AirQuality3.AirQualityEnum.Unknown;
|
|
171723
|
+
}
|
|
171724
|
+
await super.initialize();
|
|
171725
|
+
const homeAssistant = await this.agent.load(HomeAssistantEntityBehavior);
|
|
171726
|
+
this.update(homeAssistant.entity);
|
|
171727
|
+
this.reactTo(homeAssistant.onChange, this.update);
|
|
171728
|
+
}
|
|
171729
|
+
update(entity) {
|
|
171730
|
+
const state = entity.state.state;
|
|
171731
|
+
let airQuality = AirQuality3.AirQualityEnum.Unknown;
|
|
171732
|
+
if (state != null && !Number.isNaN(+state)) {
|
|
171733
|
+
const ugm3 = +state;
|
|
171734
|
+
if (ugm3 <= 30) {
|
|
171735
|
+
airQuality = AirQuality3.AirQualityEnum.Good;
|
|
171736
|
+
} else if (ugm3 <= 60) {
|
|
171737
|
+
airQuality = AirQuality3.AirQualityEnum.Fair;
|
|
171738
|
+
} else if (ugm3 <= 100) {
|
|
171739
|
+
airQuality = AirQuality3.AirQualityEnum.Moderate;
|
|
171740
|
+
} else if (ugm3 <= 200) {
|
|
171741
|
+
airQuality = AirQuality3.AirQualityEnum.Poor;
|
|
171742
|
+
} else if (ugm3 <= 500) {
|
|
171743
|
+
airQuality = AirQuality3.AirQualityEnum.VeryPoor;
|
|
171744
|
+
} else {
|
|
171745
|
+
airQuality = AirQuality3.AirQualityEnum.ExtremelyPoor;
|
|
171746
|
+
}
|
|
171747
|
+
}
|
|
171748
|
+
applyPatchState(this.state, { airQuality });
|
|
171749
|
+
}
|
|
171750
|
+
};
|
|
171751
|
+
var FormaldehydeSensorType = AirQualitySensorDevice.with(
|
|
171752
|
+
BasicInformationServer2,
|
|
171753
|
+
IdentifyServer2,
|
|
171754
|
+
HomeAssistantEntityBehavior,
|
|
171755
|
+
FormaldehydeAirQualityServer,
|
|
171756
|
+
FormaldehydeConcentrationMeasurementServer2
|
|
171757
|
+
);
|
|
171758
|
+
|
|
171759
|
+
// src/matter/endpoints/legacy/sensor/devices/humidity-sensor.ts
|
|
171760
|
+
init_home_assistant_entity_behavior();
|
|
171761
|
+
var humiditySensorConfig = {
|
|
171762
|
+
getValue({ state }) {
|
|
171763
|
+
if (state == null || Number.isNaN(+state)) {
|
|
171764
|
+
return null;
|
|
171765
|
+
}
|
|
171766
|
+
return +state;
|
|
171767
|
+
}
|
|
171768
|
+
};
|
|
171769
|
+
var HumiditySensorType = HumiditySensorDevice.with(
|
|
171770
|
+
BasicInformationServer2,
|
|
171771
|
+
IdentifyServer2,
|
|
171772
|
+
HomeAssistantEntityBehavior,
|
|
171773
|
+
HumidityMeasurementServer(humiditySensorConfig)
|
|
171774
|
+
);
|
|
171775
|
+
|
|
171776
|
+
// src/matter/endpoints/legacy/sensor/devices/illuminance-sensor.ts
|
|
171777
|
+
init_home_assistant_entity_behavior();
|
|
171778
|
+
|
|
171779
|
+
// src/matter/behaviors/illuminance-measurement-server.ts
|
|
171780
|
+
init_home_assistant_entity_behavior();
|
|
171781
|
+
var IlluminanceMeasurementServerBase = class extends IlluminanceMeasurementServer {
|
|
171782
|
+
async initialize() {
|
|
171783
|
+
await super.initialize();
|
|
171784
|
+
const homeAssistant = await this.agent.load(HomeAssistantEntityBehavior);
|
|
171785
|
+
this.update(homeAssistant.entity);
|
|
171786
|
+
this.reactTo(homeAssistant.onChange, this.update);
|
|
171787
|
+
}
|
|
171788
|
+
update(entity) {
|
|
171789
|
+
if (!entity.state) {
|
|
171790
|
+
return;
|
|
171791
|
+
}
|
|
171792
|
+
const illuminance = this.getIlluminance(this.state.config, entity.state);
|
|
171793
|
+
applyPatchState(this.state, {
|
|
171794
|
+
measuredValue: illuminance,
|
|
171795
|
+
// min/max values: 1 (min valid) to 0xFFFE (max illuminance in log scale)
|
|
171796
|
+
// Matter spec requires minMeasuredValue >= 1 for IlluminanceMeasurement
|
|
171797
|
+
minMeasuredValue: 1,
|
|
171798
|
+
maxMeasuredValue: 65534
|
|
171799
|
+
});
|
|
171800
|
+
}
|
|
171801
|
+
getIlluminance(config10, entity) {
|
|
171802
|
+
const illuminance = config10.getValue(entity, this.agent);
|
|
171803
|
+
if (illuminance == null) {
|
|
171804
|
+
return null;
|
|
171805
|
+
}
|
|
171806
|
+
if (illuminance < 1) {
|
|
171807
|
+
return 0;
|
|
171808
|
+
}
|
|
171809
|
+
const measuredValue = Math.round(1e4 * Math.log10(illuminance) + 1);
|
|
171810
|
+
return Math.min(65534, Math.max(1, measuredValue));
|
|
171811
|
+
}
|
|
171812
|
+
};
|
|
171813
|
+
((IlluminanceMeasurementServerBase2) => {
|
|
171814
|
+
class State extends IlluminanceMeasurementServer.State {
|
|
171815
|
+
config;
|
|
171816
|
+
}
|
|
171817
|
+
IlluminanceMeasurementServerBase2.State = State;
|
|
171818
|
+
})(IlluminanceMeasurementServerBase || (IlluminanceMeasurementServerBase = {}));
|
|
171819
|
+
function IlluminanceMeasurementServer2(config10) {
|
|
171820
|
+
return IlluminanceMeasurementServerBase.set({ config: config10 });
|
|
171821
|
+
}
|
|
171822
|
+
|
|
171823
|
+
// src/matter/endpoints/legacy/sensor/devices/illuminance-sensor.ts
|
|
171824
|
+
var illuminanceSensorConfig = {
|
|
171825
|
+
getValue({ state }) {
|
|
171826
|
+
if (state == null || Number.isNaN(+state)) {
|
|
171827
|
+
return null;
|
|
171828
|
+
}
|
|
171829
|
+
return +state;
|
|
171830
|
+
}
|
|
171831
|
+
};
|
|
171832
|
+
var IlluminanceSensorType = LightSensorDevice.with(
|
|
171833
|
+
BasicInformationServer2,
|
|
171834
|
+
IdentifyServer2,
|
|
171835
|
+
HomeAssistantEntityBehavior,
|
|
171836
|
+
IlluminanceMeasurementServer2(illuminanceSensorConfig)
|
|
171837
|
+
);
|
|
171838
|
+
|
|
171839
|
+
// src/matter/endpoints/legacy/sensor/devices/nitrogen-dioxide-sensor.ts
|
|
171840
|
+
init_home_assistant_entity_behavior();
|
|
171841
|
+
|
|
171842
|
+
// src/matter/behaviors/nitrogen-dioxide-concentration-measurement-server.ts
|
|
171843
|
+
init_home_assistant_entity_behavior();
|
|
171844
|
+
var NitrogenDioxideConcentrationMeasurementServerBase = NitrogenDioxideConcentrationMeasurementServer.with(
|
|
171845
|
+
ConcentrationMeasurement3.Feature.NumericMeasurement
|
|
171846
|
+
);
|
|
171847
|
+
var NitrogenDioxideConcentrationMeasurementServer2 = class extends NitrogenDioxideConcentrationMeasurementServerBase {
|
|
171848
|
+
async initialize() {
|
|
171849
|
+
if (this.state.measuredValue === void 0) {
|
|
171850
|
+
this.state.measuredValue = null;
|
|
171851
|
+
}
|
|
171852
|
+
if (this.state.minMeasuredValue === void 0) {
|
|
171853
|
+
this.state.minMeasuredValue = null;
|
|
171854
|
+
}
|
|
171855
|
+
if (this.state.maxMeasuredValue === void 0) {
|
|
171856
|
+
this.state.maxMeasuredValue = null;
|
|
171857
|
+
}
|
|
171858
|
+
if (this.state.uncertainty === void 0) {
|
|
171859
|
+
this.state.uncertainty = 0;
|
|
171860
|
+
}
|
|
171861
|
+
if (this.state.measurementUnit === void 0) {
|
|
171862
|
+
this.state.measurementUnit = ConcentrationMeasurement3.MeasurementUnit.Ugm3;
|
|
171863
|
+
}
|
|
171864
|
+
if (this.state.measurementMedium === void 0) {
|
|
171865
|
+
this.state.measurementMedium = ConcentrationMeasurement3.MeasurementMedium.Air;
|
|
171866
|
+
}
|
|
171867
|
+
await super.initialize();
|
|
171868
|
+
const homeAssistant = await this.agent.load(HomeAssistantEntityBehavior);
|
|
171869
|
+
this.update(homeAssistant.entity);
|
|
171870
|
+
this.reactTo(homeAssistant.onChange, this.update);
|
|
171871
|
+
}
|
|
171872
|
+
update(entity) {
|
|
171873
|
+
if (!entity.state) {
|
|
171874
|
+
return;
|
|
171875
|
+
}
|
|
171876
|
+
const state = entity.state.state;
|
|
171877
|
+
let measuredValue = null;
|
|
171878
|
+
if (state != null && !Number.isNaN(+state)) {
|
|
171879
|
+
measuredValue = +state;
|
|
171880
|
+
}
|
|
171881
|
+
applyPatchState(this.state, { measuredValue });
|
|
171882
|
+
}
|
|
171883
|
+
};
|
|
171884
|
+
|
|
171885
|
+
// src/matter/endpoints/legacy/sensor/devices/nitrogen-dioxide-sensor.ts
|
|
171886
|
+
var No2AirQualityServerBase = AirQualityServer.with(
|
|
171887
|
+
AirQuality3.Feature.Fair,
|
|
171888
|
+
AirQuality3.Feature.Moderate,
|
|
171889
|
+
AirQuality3.Feature.VeryPoor,
|
|
171890
|
+
AirQuality3.Feature.ExtremelyPoor
|
|
171891
|
+
);
|
|
171892
|
+
var No2AirQualityServer = class extends No2AirQualityServerBase {
|
|
171893
|
+
async initialize() {
|
|
171894
|
+
if (this.state.airQuality === void 0) {
|
|
171895
|
+
this.state.airQuality = AirQuality3.AirQualityEnum.Unknown;
|
|
171896
|
+
}
|
|
171897
|
+
await super.initialize();
|
|
171898
|
+
const homeAssistant = await this.agent.load(HomeAssistantEntityBehavior);
|
|
171899
|
+
this.update(homeAssistant.entity);
|
|
171900
|
+
this.reactTo(homeAssistant.onChange, this.update);
|
|
171901
|
+
}
|
|
171902
|
+
update(entity) {
|
|
171903
|
+
const state = entity.state.state;
|
|
171904
|
+
let airQuality = AirQuality3.AirQualityEnum.Unknown;
|
|
171905
|
+
if (state != null && !Number.isNaN(+state)) {
|
|
171906
|
+
const ugm3 = +state;
|
|
171907
|
+
if (ugm3 <= 25) {
|
|
171908
|
+
airQuality = AirQuality3.AirQualityEnum.Good;
|
|
171909
|
+
} else if (ugm3 <= 50) {
|
|
171910
|
+
airQuality = AirQuality3.AirQualityEnum.Fair;
|
|
171911
|
+
} else if (ugm3 <= 100) {
|
|
171912
|
+
airQuality = AirQuality3.AirQualityEnum.Moderate;
|
|
171913
|
+
} else if (ugm3 <= 200) {
|
|
171914
|
+
airQuality = AirQuality3.AirQualityEnum.Poor;
|
|
171915
|
+
} else if (ugm3 <= 400) {
|
|
171916
|
+
airQuality = AirQuality3.AirQualityEnum.VeryPoor;
|
|
171917
|
+
} else {
|
|
171918
|
+
airQuality = AirQuality3.AirQualityEnum.ExtremelyPoor;
|
|
171919
|
+
}
|
|
171920
|
+
}
|
|
171921
|
+
applyPatchState(this.state, { airQuality });
|
|
171922
|
+
}
|
|
171923
|
+
};
|
|
171924
|
+
var NitrogenDioxideSensorType = AirQualitySensorDevice.with(
|
|
171925
|
+
BasicInformationServer2,
|
|
171926
|
+
IdentifyServer2,
|
|
171927
|
+
HomeAssistantEntityBehavior,
|
|
171928
|
+
No2AirQualityServer,
|
|
171929
|
+
NitrogenDioxideConcentrationMeasurementServer2
|
|
171930
|
+
);
|
|
171931
|
+
|
|
171932
|
+
// src/matter/endpoints/legacy/sensor/devices/ozone-sensor.ts
|
|
171933
|
+
init_home_assistant_entity_behavior();
|
|
171934
|
+
|
|
171935
|
+
// src/matter/behaviors/ozone-concentration-measurement-server.ts
|
|
171936
|
+
init_home_assistant_entity_behavior();
|
|
171937
|
+
var OzoneConcentrationMeasurementServerBase = OzoneConcentrationMeasurementServer.with(
|
|
171938
|
+
ConcentrationMeasurement3.Feature.NumericMeasurement
|
|
171939
|
+
);
|
|
171940
|
+
var OzoneConcentrationMeasurementServer2 = class extends OzoneConcentrationMeasurementServerBase {
|
|
171941
|
+
async initialize() {
|
|
171942
|
+
if (this.state.measuredValue === void 0) {
|
|
171943
|
+
this.state.measuredValue = null;
|
|
171944
|
+
}
|
|
171945
|
+
if (this.state.minMeasuredValue === void 0) {
|
|
171946
|
+
this.state.minMeasuredValue = null;
|
|
171947
|
+
}
|
|
171948
|
+
if (this.state.maxMeasuredValue === void 0) {
|
|
171949
|
+
this.state.maxMeasuredValue = null;
|
|
171950
|
+
}
|
|
171951
|
+
if (this.state.uncertainty === void 0) {
|
|
171952
|
+
this.state.uncertainty = 0;
|
|
171953
|
+
}
|
|
171954
|
+
if (this.state.measurementUnit === void 0) {
|
|
171955
|
+
this.state.measurementUnit = ConcentrationMeasurement3.MeasurementUnit.Ugm3;
|
|
171956
|
+
}
|
|
171957
|
+
if (this.state.measurementMedium === void 0) {
|
|
171958
|
+
this.state.measurementMedium = ConcentrationMeasurement3.MeasurementMedium.Air;
|
|
171959
|
+
}
|
|
171960
|
+
await super.initialize();
|
|
171961
|
+
const homeAssistant = await this.agent.load(HomeAssistantEntityBehavior);
|
|
171962
|
+
this.update(homeAssistant.entity);
|
|
171963
|
+
this.reactTo(homeAssistant.onChange, this.update);
|
|
171964
|
+
}
|
|
171965
|
+
update(entity) {
|
|
171966
|
+
if (!entity.state) {
|
|
171967
|
+
return;
|
|
171968
|
+
}
|
|
171969
|
+
const state = entity.state.state;
|
|
171970
|
+
let measuredValue = null;
|
|
171971
|
+
if (state != null && !Number.isNaN(+state)) {
|
|
171972
|
+
measuredValue = +state;
|
|
171973
|
+
}
|
|
171974
|
+
applyPatchState(this.state, { measuredValue });
|
|
171975
|
+
}
|
|
171976
|
+
};
|
|
171977
|
+
|
|
171978
|
+
// src/matter/endpoints/legacy/sensor/devices/ozone-sensor.ts
|
|
171979
|
+
var OzoneAirQualityServerBase = AirQualityServer.with(
|
|
171980
|
+
AirQuality3.Feature.Fair,
|
|
171981
|
+
AirQuality3.Feature.Moderate,
|
|
171982
|
+
AirQuality3.Feature.VeryPoor,
|
|
171983
|
+
AirQuality3.Feature.ExtremelyPoor
|
|
171984
|
+
);
|
|
171985
|
+
var OzoneAirQualityServer = class extends OzoneAirQualityServerBase {
|
|
171986
|
+
async initialize() {
|
|
171987
|
+
if (this.state.airQuality === void 0) {
|
|
171988
|
+
this.state.airQuality = AirQuality3.AirQualityEnum.Unknown;
|
|
171989
|
+
}
|
|
171990
|
+
await super.initialize();
|
|
171991
|
+
const homeAssistant = await this.agent.load(HomeAssistantEntityBehavior);
|
|
171992
|
+
this.update(homeAssistant.entity);
|
|
171993
|
+
this.reactTo(homeAssistant.onChange, this.update);
|
|
171994
|
+
}
|
|
171995
|
+
update(entity) {
|
|
171996
|
+
const state = entity.state.state;
|
|
171997
|
+
let airQuality = AirQuality3.AirQualityEnum.Unknown;
|
|
171998
|
+
if (state != null && !Number.isNaN(+state)) {
|
|
171999
|
+
const ugm3 = +state;
|
|
172000
|
+
if (ugm3 <= 60) {
|
|
172001
|
+
airQuality = AirQuality3.AirQualityEnum.Good;
|
|
172002
|
+
} else if (ugm3 <= 100) {
|
|
172003
|
+
airQuality = AirQuality3.AirQualityEnum.Fair;
|
|
172004
|
+
} else if (ugm3 <= 140) {
|
|
172005
|
+
airQuality = AirQuality3.AirQualityEnum.Moderate;
|
|
172006
|
+
} else if (ugm3 <= 180) {
|
|
172007
|
+
airQuality = AirQuality3.AirQualityEnum.Poor;
|
|
172008
|
+
} else if (ugm3 <= 240) {
|
|
172009
|
+
airQuality = AirQuality3.AirQualityEnum.VeryPoor;
|
|
172010
|
+
} else {
|
|
172011
|
+
airQuality = AirQuality3.AirQualityEnum.ExtremelyPoor;
|
|
172012
|
+
}
|
|
172013
|
+
}
|
|
172014
|
+
applyPatchState(this.state, { airQuality });
|
|
172015
|
+
}
|
|
172016
|
+
};
|
|
172017
|
+
var OzoneSensorType = AirQualitySensorDevice.with(
|
|
171341
172018
|
BasicInformationServer2,
|
|
171342
172019
|
IdentifyServer2,
|
|
171343
172020
|
HomeAssistantEntityBehavior,
|
|
171344
|
-
|
|
172021
|
+
OzoneAirQualityServer,
|
|
172022
|
+
OzoneConcentrationMeasurementServer2
|
|
171345
172023
|
);
|
|
171346
172024
|
|
|
171347
|
-
// src/matter/endpoints/legacy/sensor/devices/
|
|
172025
|
+
// src/matter/endpoints/legacy/sensor/devices/pm1-sensor.ts
|
|
171348
172026
|
init_home_assistant_entity_behavior();
|
|
171349
|
-
var BatterySensorType = BatteryStorageDevice.with(
|
|
171350
|
-
BasicInformationServer2,
|
|
171351
|
-
IdentifyServer2,
|
|
171352
|
-
HomeAssistantEntityBehavior,
|
|
171353
|
-
PowerSourceServer2({
|
|
171354
|
-
getBatteryPercent(entity) {
|
|
171355
|
-
const state = entity.state;
|
|
171356
|
-
if (state == null || Number.isNaN(+state)) {
|
|
171357
|
-
return null;
|
|
171358
|
-
}
|
|
171359
|
-
return +state;
|
|
171360
|
-
}
|
|
171361
|
-
})
|
|
171362
|
-
);
|
|
171363
172027
|
|
|
171364
|
-
// src/matter/behaviors/
|
|
172028
|
+
// src/matter/behaviors/pm1-concentration-measurement-server.ts
|
|
171365
172029
|
init_home_assistant_entity_behavior();
|
|
171366
|
-
var
|
|
172030
|
+
var Pm1ConcentrationMeasurementServerBase = Pm1ConcentrationMeasurementServer.with(
|
|
172031
|
+
ConcentrationMeasurement3.Feature.NumericMeasurement
|
|
172032
|
+
);
|
|
172033
|
+
var Pm1ConcentrationMeasurementServer2 = class extends Pm1ConcentrationMeasurementServerBase {
|
|
171367
172034
|
async initialize() {
|
|
172035
|
+
if (this.state.measuredValue === void 0) {
|
|
172036
|
+
this.state.measuredValue = null;
|
|
172037
|
+
}
|
|
172038
|
+
if (this.state.minMeasuredValue === void 0) {
|
|
172039
|
+
this.state.minMeasuredValue = null;
|
|
172040
|
+
}
|
|
172041
|
+
if (this.state.maxMeasuredValue === void 0) {
|
|
172042
|
+
this.state.maxMeasuredValue = null;
|
|
172043
|
+
}
|
|
172044
|
+
if (this.state.uncertainty === void 0) {
|
|
172045
|
+
this.state.uncertainty = 0;
|
|
172046
|
+
}
|
|
172047
|
+
if (this.state.measurementUnit === void 0) {
|
|
172048
|
+
this.state.measurementUnit = ConcentrationMeasurement3.MeasurementUnit.Ugm3;
|
|
172049
|
+
}
|
|
172050
|
+
if (this.state.measurementMedium === void 0) {
|
|
172051
|
+
this.state.measurementMedium = ConcentrationMeasurement3.MeasurementMedium.Air;
|
|
172052
|
+
}
|
|
171368
172053
|
await super.initialize();
|
|
171369
172054
|
const homeAssistant = await this.agent.load(HomeAssistantEntityBehavior);
|
|
171370
172055
|
this.update(homeAssistant.entity);
|
|
@@ -171374,88 +172059,110 @@ var FlowMeasurementServerBase = class extends FlowMeasurementServer {
|
|
|
171374
172059
|
if (!entity.state) {
|
|
171375
172060
|
return;
|
|
171376
172061
|
}
|
|
171377
|
-
|
|
171378
|
-
|
|
171379
|
-
|
|
171380
|
-
|
|
171381
|
-
maxMeasuredValue: 65534
|
|
171382
|
-
});
|
|
171383
|
-
}
|
|
171384
|
-
getFlow(entity) {
|
|
171385
|
-
const value = this.state.config.getValue(entity, this.agent);
|
|
171386
|
-
if (value == null) {
|
|
171387
|
-
return void 0;
|
|
172062
|
+
const state = entity.state.state;
|
|
172063
|
+
let measuredValue = null;
|
|
172064
|
+
if (state != null && !Number.isNaN(+state)) {
|
|
172065
|
+
measuredValue = +state;
|
|
171388
172066
|
}
|
|
171389
|
-
|
|
172067
|
+
applyPatchState(this.state, { measuredValue });
|
|
171390
172068
|
}
|
|
171391
172069
|
};
|
|
171392
|
-
((FlowMeasurementServerBase2) => {
|
|
171393
|
-
class State extends FlowMeasurementServer.State {
|
|
171394
|
-
config;
|
|
171395
|
-
}
|
|
171396
|
-
FlowMeasurementServerBase2.State = State;
|
|
171397
|
-
})(FlowMeasurementServerBase || (FlowMeasurementServerBase = {}));
|
|
171398
|
-
function FlowMeasurementServer2(config10) {
|
|
171399
|
-
return FlowMeasurementServerBase.set({ config: config10 });
|
|
171400
|
-
}
|
|
171401
172070
|
|
|
171402
|
-
// src/matter/endpoints/legacy/sensor/devices/
|
|
171403
|
-
|
|
171404
|
-
|
|
171405
|
-
|
|
171406
|
-
|
|
171407
|
-
|
|
171408
|
-
|
|
171409
|
-
|
|
171410
|
-
|
|
171411
|
-
|
|
171412
|
-
|
|
171413
|
-
if (unit === "l/min") {
|
|
171414
|
-
return flow * 0.06;
|
|
171415
|
-
}
|
|
171416
|
-
if (unit === "l/h") {
|
|
171417
|
-
return flow / 1e3;
|
|
171418
|
-
}
|
|
171419
|
-
if (unit === "gal/min" || unit === "gpm") {
|
|
171420
|
-
return flow * 0.227;
|
|
172071
|
+
// src/matter/endpoints/legacy/sensor/devices/pm1-sensor.ts
|
|
172072
|
+
var Pm1AirQualityServerBase = AirQualityServer.with(
|
|
172073
|
+
AirQuality3.Feature.Fair,
|
|
172074
|
+
AirQuality3.Feature.Moderate,
|
|
172075
|
+
AirQuality3.Feature.VeryPoor,
|
|
172076
|
+
AirQuality3.Feature.ExtremelyPoor
|
|
172077
|
+
);
|
|
172078
|
+
var Pm1AirQualityServer = class extends Pm1AirQualityServerBase {
|
|
172079
|
+
async initialize() {
|
|
172080
|
+
if (this.state.airQuality === void 0) {
|
|
172081
|
+
this.state.airQuality = AirQuality3.AirQualityEnum.Unknown;
|
|
171421
172082
|
}
|
|
171422
|
-
|
|
171423
|
-
|
|
172083
|
+
await super.initialize();
|
|
172084
|
+
const homeAssistant = await this.agent.load(HomeAssistantEntityBehavior);
|
|
172085
|
+
this.update(homeAssistant.entity);
|
|
172086
|
+
this.reactTo(homeAssistant.onChange, this.update);
|
|
172087
|
+
}
|
|
172088
|
+
update(entity) {
|
|
172089
|
+
const state = entity.state.state;
|
|
172090
|
+
let airQuality = AirQuality3.AirQualityEnum.Unknown;
|
|
172091
|
+
if (state != null && !Number.isNaN(+state)) {
|
|
172092
|
+
const ugm3 = +state;
|
|
172093
|
+
if (ugm3 <= 10) {
|
|
172094
|
+
airQuality = AirQuality3.AirQualityEnum.Good;
|
|
172095
|
+
} else if (ugm3 <= 25) {
|
|
172096
|
+
airQuality = AirQuality3.AirQualityEnum.Fair;
|
|
172097
|
+
} else if (ugm3 <= 50) {
|
|
172098
|
+
airQuality = AirQuality3.AirQualityEnum.Moderate;
|
|
172099
|
+
} else if (ugm3 <= 100) {
|
|
172100
|
+
airQuality = AirQuality3.AirQualityEnum.Poor;
|
|
172101
|
+
} else if (ugm3 <= 200) {
|
|
172102
|
+
airQuality = AirQuality3.AirQualityEnum.VeryPoor;
|
|
172103
|
+
} else {
|
|
172104
|
+
airQuality = AirQuality3.AirQualityEnum.ExtremelyPoor;
|
|
172105
|
+
}
|
|
171424
172106
|
}
|
|
171425
|
-
|
|
172107
|
+
applyPatchState(this.state, { airQuality });
|
|
171426
172108
|
}
|
|
171427
172109
|
};
|
|
171428
|
-
var
|
|
172110
|
+
var Pm1SensorType = AirQualitySensorDevice.with(
|
|
171429
172111
|
BasicInformationServer2,
|
|
171430
172112
|
IdentifyServer2,
|
|
171431
172113
|
HomeAssistantEntityBehavior,
|
|
171432
|
-
|
|
172114
|
+
Pm1AirQualityServer,
|
|
172115
|
+
Pm1ConcentrationMeasurementServer2
|
|
171433
172116
|
);
|
|
171434
172117
|
|
|
171435
|
-
// src/matter/endpoints/legacy/sensor/devices/
|
|
172118
|
+
// src/matter/endpoints/legacy/sensor/devices/pressure-sensor.ts
|
|
171436
172119
|
init_home_assistant_entity_behavior();
|
|
171437
|
-
var
|
|
171438
|
-
getValue(
|
|
171439
|
-
|
|
171440
|
-
|
|
172120
|
+
var pressureSensorConfig = {
|
|
172121
|
+
getValue(entity) {
|
|
172122
|
+
const state = entity.state;
|
|
172123
|
+
const attributes7 = entity.attributes;
|
|
172124
|
+
const pressure = state == null || Number.isNaN(+state) ? null : +state;
|
|
172125
|
+
if (pressure == null) {
|
|
172126
|
+
return void 0;
|
|
171441
172127
|
}
|
|
171442
|
-
return
|
|
172128
|
+
return convertPressureToHpa(pressure, attributes7.unit_of_measurement);
|
|
171443
172129
|
}
|
|
171444
172130
|
};
|
|
171445
|
-
var
|
|
172131
|
+
var PressureSensorType = PressureSensorDevice.with(
|
|
171446
172132
|
BasicInformationServer2,
|
|
171447
172133
|
IdentifyServer2,
|
|
171448
172134
|
HomeAssistantEntityBehavior,
|
|
171449
|
-
|
|
172135
|
+
PressureMeasurementServer2(pressureSensorConfig)
|
|
171450
172136
|
);
|
|
171451
172137
|
|
|
171452
|
-
// src/matter/endpoints/legacy/sensor/devices/
|
|
172138
|
+
// src/matter/endpoints/legacy/sensor/devices/radon-sensor.ts
|
|
171453
172139
|
init_home_assistant_entity_behavior();
|
|
171454
172140
|
|
|
171455
|
-
// src/matter/behaviors/
|
|
172141
|
+
// src/matter/behaviors/radon-concentration-measurement-server.ts
|
|
171456
172142
|
init_home_assistant_entity_behavior();
|
|
171457
|
-
var
|
|
172143
|
+
var RadonConcentrationMeasurementServerBase = RadonConcentrationMeasurementServer.with(
|
|
172144
|
+
ConcentrationMeasurement3.Feature.NumericMeasurement
|
|
172145
|
+
);
|
|
172146
|
+
var RadonConcentrationMeasurementServer2 = class extends RadonConcentrationMeasurementServerBase {
|
|
171458
172147
|
async initialize() {
|
|
172148
|
+
if (this.state.measuredValue === void 0) {
|
|
172149
|
+
this.state.measuredValue = null;
|
|
172150
|
+
}
|
|
172151
|
+
if (this.state.minMeasuredValue === void 0) {
|
|
172152
|
+
this.state.minMeasuredValue = null;
|
|
172153
|
+
}
|
|
172154
|
+
if (this.state.maxMeasuredValue === void 0) {
|
|
172155
|
+
this.state.maxMeasuredValue = null;
|
|
172156
|
+
}
|
|
172157
|
+
if (this.state.uncertainty === void 0) {
|
|
172158
|
+
this.state.uncertainty = 0;
|
|
172159
|
+
}
|
|
172160
|
+
if (this.state.measurementUnit === void 0) {
|
|
172161
|
+
this.state.measurementUnit = ConcentrationMeasurement3.MeasurementUnit.Bqm3;
|
|
172162
|
+
}
|
|
172163
|
+
if (this.state.measurementMedium === void 0) {
|
|
172164
|
+
this.state.measurementMedium = ConcentrationMeasurement3.MeasurementMedium.Air;
|
|
172165
|
+
}
|
|
171459
172166
|
await super.initialize();
|
|
171460
172167
|
const homeAssistant = await this.agent.load(HomeAssistantEntityBehavior);
|
|
171461
172168
|
this.update(homeAssistant.entity);
|
|
@@ -171465,71 +172172,60 @@ var IlluminanceMeasurementServerBase = class extends IlluminanceMeasurementServe
|
|
|
171465
172172
|
if (!entity.state) {
|
|
171466
172173
|
return;
|
|
171467
172174
|
}
|
|
171468
|
-
const
|
|
171469
|
-
|
|
171470
|
-
|
|
171471
|
-
|
|
171472
|
-
// Matter spec requires minMeasuredValue >= 1 for IlluminanceMeasurement
|
|
171473
|
-
minMeasuredValue: 1,
|
|
171474
|
-
maxMeasuredValue: 65534
|
|
171475
|
-
});
|
|
171476
|
-
}
|
|
171477
|
-
getIlluminance(config10, entity) {
|
|
171478
|
-
const illuminance = config10.getValue(entity, this.agent);
|
|
171479
|
-
if (illuminance == null) {
|
|
171480
|
-
return null;
|
|
171481
|
-
}
|
|
171482
|
-
if (illuminance < 1) {
|
|
171483
|
-
return 0;
|
|
172175
|
+
const state = entity.state.state;
|
|
172176
|
+
let measuredValue = null;
|
|
172177
|
+
if (state != null && !Number.isNaN(+state)) {
|
|
172178
|
+
measuredValue = +state;
|
|
171484
172179
|
}
|
|
171485
|
-
|
|
171486
|
-
return Math.min(65534, Math.max(1, measuredValue));
|
|
172180
|
+
applyPatchState(this.state, { measuredValue });
|
|
171487
172181
|
}
|
|
171488
172182
|
};
|
|
171489
|
-
((IlluminanceMeasurementServerBase2) => {
|
|
171490
|
-
class State extends IlluminanceMeasurementServer.State {
|
|
171491
|
-
config;
|
|
171492
|
-
}
|
|
171493
|
-
IlluminanceMeasurementServerBase2.State = State;
|
|
171494
|
-
})(IlluminanceMeasurementServerBase || (IlluminanceMeasurementServerBase = {}));
|
|
171495
|
-
function IlluminanceMeasurementServer2(config10) {
|
|
171496
|
-
return IlluminanceMeasurementServerBase.set({ config: config10 });
|
|
171497
|
-
}
|
|
171498
172183
|
|
|
171499
|
-
// src/matter/endpoints/legacy/sensor/devices/
|
|
171500
|
-
var
|
|
171501
|
-
|
|
171502
|
-
|
|
171503
|
-
|
|
172184
|
+
// src/matter/endpoints/legacy/sensor/devices/radon-sensor.ts
|
|
172185
|
+
var RadonAirQualityServerBase = AirQualityServer.with(
|
|
172186
|
+
AirQuality3.Feature.Fair,
|
|
172187
|
+
AirQuality3.Feature.Moderate,
|
|
172188
|
+
AirQuality3.Feature.VeryPoor,
|
|
172189
|
+
AirQuality3.Feature.ExtremelyPoor
|
|
172190
|
+
);
|
|
172191
|
+
var RadonAirQualityServer = class extends RadonAirQualityServerBase {
|
|
172192
|
+
async initialize() {
|
|
172193
|
+
if (this.state.airQuality === void 0) {
|
|
172194
|
+
this.state.airQuality = AirQuality3.AirQualityEnum.Unknown;
|
|
171504
172195
|
}
|
|
171505
|
-
|
|
172196
|
+
await super.initialize();
|
|
172197
|
+
const homeAssistant = await this.agent.load(HomeAssistantEntityBehavior);
|
|
172198
|
+
this.update(homeAssistant.entity);
|
|
172199
|
+
this.reactTo(homeAssistant.onChange, this.update);
|
|
171506
172200
|
}
|
|
171507
|
-
|
|
171508
|
-
|
|
171509
|
-
|
|
171510
|
-
|
|
171511
|
-
|
|
171512
|
-
|
|
171513
|
-
|
|
171514
|
-
|
|
171515
|
-
|
|
171516
|
-
|
|
171517
|
-
|
|
171518
|
-
|
|
171519
|
-
|
|
171520
|
-
|
|
171521
|
-
|
|
171522
|
-
|
|
171523
|
-
|
|
172201
|
+
update(entity) {
|
|
172202
|
+
const state = entity.state.state;
|
|
172203
|
+
let airQuality = AirQuality3.AirQualityEnum.Unknown;
|
|
172204
|
+
if (state != null && !Number.isNaN(+state)) {
|
|
172205
|
+
const bqm3 = +state;
|
|
172206
|
+
if (bqm3 <= 50) {
|
|
172207
|
+
airQuality = AirQuality3.AirQualityEnum.Good;
|
|
172208
|
+
} else if (bqm3 <= 100) {
|
|
172209
|
+
airQuality = AirQuality3.AirQualityEnum.Fair;
|
|
172210
|
+
} else if (bqm3 <= 200) {
|
|
172211
|
+
airQuality = AirQuality3.AirQualityEnum.Moderate;
|
|
172212
|
+
} else if (bqm3 <= 300) {
|
|
172213
|
+
airQuality = AirQuality3.AirQualityEnum.Poor;
|
|
172214
|
+
} else if (bqm3 <= 600) {
|
|
172215
|
+
airQuality = AirQuality3.AirQualityEnum.VeryPoor;
|
|
172216
|
+
} else {
|
|
172217
|
+
airQuality = AirQuality3.AirQualityEnum.ExtremelyPoor;
|
|
172218
|
+
}
|
|
171524
172219
|
}
|
|
171525
|
-
|
|
172220
|
+
applyPatchState(this.state, { airQuality });
|
|
171526
172221
|
}
|
|
171527
172222
|
};
|
|
171528
|
-
var
|
|
172223
|
+
var RadonSensorType = AirQualitySensorDevice.with(
|
|
171529
172224
|
BasicInformationServer2,
|
|
171530
172225
|
IdentifyServer2,
|
|
171531
172226
|
HomeAssistantEntityBehavior,
|
|
171532
|
-
|
|
172227
|
+
RadonAirQualityServer,
|
|
172228
|
+
RadonConcentrationMeasurementServer2
|
|
171533
172229
|
);
|
|
171534
172230
|
|
|
171535
172231
|
// src/matter/endpoints/legacy/sensor/devices/temperature-sensor.ts
|
|
@@ -172239,6 +172935,21 @@ function SensorDevice(homeAssistantEntity) {
|
|
|
172239
172935
|
if (deviceClass === SensorDeviceClass.aqi) {
|
|
172240
172936
|
return AirQualitySensorType.set({ homeAssistantEntity });
|
|
172241
172937
|
}
|
|
172938
|
+
if (deviceClass === SensorDeviceClass.carbon_monoxide) {
|
|
172939
|
+
return CarbonMonoxideSensorType.set({ homeAssistantEntity });
|
|
172940
|
+
}
|
|
172941
|
+
if (deviceClass === SensorDeviceClass.nitrogen_dioxide) {
|
|
172942
|
+
return NitrogenDioxideSensorType.set({ homeAssistantEntity });
|
|
172943
|
+
}
|
|
172944
|
+
if (deviceClass === SensorDeviceClass.ozone) {
|
|
172945
|
+
return OzoneSensorType.set({ homeAssistantEntity });
|
|
172946
|
+
}
|
|
172947
|
+
if (deviceClass === SensorDeviceClass.pm1) {
|
|
172948
|
+
return Pm1SensorType.set({ homeAssistantEntity });
|
|
172949
|
+
}
|
|
172950
|
+
if (deviceClass === SensorDeviceClass.power || deviceClass === SensorDeviceClass.energy || deviceClass === SensorDeviceClass.voltage || deviceClass === SensorDeviceClass.current) {
|
|
172951
|
+
return ElectricalSensorType.set({ homeAssistantEntity });
|
|
172952
|
+
}
|
|
172242
172953
|
if (deviceClass === SensorDeviceClass.battery) {
|
|
172243
172954
|
return BatterySensorType.set({ homeAssistantEntity });
|
|
172244
172955
|
}
|
|
@@ -174622,6 +175333,27 @@ var matterDeviceTypeFactories = {
|
|
|
174622
175333
|
tvoc_sensor: (ha) => TvocSensorType.set({
|
|
174623
175334
|
homeAssistantEntity: { entity: ha.entity, customName: ha.customName }
|
|
174624
175335
|
}),
|
|
175336
|
+
carbon_monoxide_sensor: (ha) => CarbonMonoxideSensorType.set({
|
|
175337
|
+
homeAssistantEntity: { entity: ha.entity, customName: ha.customName }
|
|
175338
|
+
}),
|
|
175339
|
+
nitrogen_dioxide_sensor: (ha) => NitrogenDioxideSensorType.set({
|
|
175340
|
+
homeAssistantEntity: { entity: ha.entity, customName: ha.customName }
|
|
175341
|
+
}),
|
|
175342
|
+
ozone_sensor: (ha) => OzoneSensorType.set({
|
|
175343
|
+
homeAssistantEntity: { entity: ha.entity, customName: ha.customName }
|
|
175344
|
+
}),
|
|
175345
|
+
formaldehyde_sensor: (ha) => FormaldehydeSensorType.set({
|
|
175346
|
+
homeAssistantEntity: { entity: ha.entity, customName: ha.customName }
|
|
175347
|
+
}),
|
|
175348
|
+
radon_sensor: (ha) => RadonSensorType.set({
|
|
175349
|
+
homeAssistantEntity: { entity: ha.entity, customName: ha.customName }
|
|
175350
|
+
}),
|
|
175351
|
+
pm1_sensor: (ha) => Pm1SensorType.set({
|
|
175352
|
+
homeAssistantEntity: { entity: ha.entity, customName: ha.customName }
|
|
175353
|
+
}),
|
|
175354
|
+
electrical_sensor: (ha) => ElectricalSensorType.set({
|
|
175355
|
+
homeAssistantEntity: { entity: ha.entity, customName: ha.customName }
|
|
175356
|
+
}),
|
|
174625
175357
|
mode_select: SelectDevice,
|
|
174626
175358
|
water_valve: ValveDevice,
|
|
174627
175359
|
pump: PumpEndpoint,
|