@riddix/hamh 2.1.0-alpha.526 → 2.1.0-alpha.527
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
|
@@ -173623,8 +173623,38 @@ var PumpType = PumpDevice.with(
|
|
|
173623
173623
|
PumpOnOffServer,
|
|
173624
173624
|
PumpConfigurationAndControlServer2
|
|
173625
173625
|
);
|
|
173626
|
+
var PumpWithBatteryType = PumpDevice.with(
|
|
173627
|
+
IdentifyServer2,
|
|
173628
|
+
BasicInformationServer2,
|
|
173629
|
+
HomeAssistantEntityBehavior,
|
|
173630
|
+
PumpOnOffServer,
|
|
173631
|
+
PumpConfigurationAndControlServer2,
|
|
173632
|
+
PowerSourceServer2({
|
|
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
|
+
})
|
|
173651
|
+
);
|
|
173626
173652
|
function PumpEndpoint(homeAssistantEntity) {
|
|
173627
|
-
|
|
173653
|
+
const attrs = homeAssistantEntity.entity.state.attributes;
|
|
173654
|
+
const hasBatteryAttr = attrs.battery_level != null || attrs.battery != null;
|
|
173655
|
+
const hasBatteryEntity = !!homeAssistantEntity.mapping?.batteryEntity;
|
|
173656
|
+
const device = hasBatteryAttr || hasBatteryEntity ? PumpWithBatteryType : PumpType;
|
|
173657
|
+
return device.set({ homeAssistantEntity });
|
|
173628
173658
|
}
|
|
173629
173659
|
|
|
173630
173660
|
// src/matter/endpoints/legacy/remote/index.ts
|
|
@@ -177644,8 +177674,37 @@ var ValveEndpointType = WaterValveDevice.with(
|
|
|
177644
177674
|
HomeAssistantEntityBehavior,
|
|
177645
177675
|
ValveServer
|
|
177646
177676
|
);
|
|
177677
|
+
var ValveWithBatteryEndpointType = WaterValveDevice.with(
|
|
177678
|
+
BasicInformationServer2,
|
|
177679
|
+
IdentifyServer2,
|
|
177680
|
+
HomeAssistantEntityBehavior,
|
|
177681
|
+
ValveServer,
|
|
177682
|
+
PowerSourceServer2({
|
|
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
|
+
})
|
|
177701
|
+
);
|
|
177647
177702
|
function ValveDevice(homeAssistantEntity) {
|
|
177648
|
-
|
|
177703
|
+
const attrs = homeAssistantEntity.entity.state.attributes;
|
|
177704
|
+
const hasBatteryAttr = attrs.battery_level != null || attrs.battery != null;
|
|
177705
|
+
const hasBatteryEntity = !!homeAssistantEntity.mapping?.batteryEntity;
|
|
177706
|
+
const device = hasBatteryAttr || hasBatteryEntity ? ValveWithBatteryEndpointType : ValveEndpointType;
|
|
177707
|
+
return device.set({ homeAssistantEntity });
|
|
177649
177708
|
}
|
|
177650
177709
|
|
|
177651
177710
|
// src/matter/endpoints/legacy/water-heater/index.ts
|