@riddix/hamh 2.1.0-alpha.525 → 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.
@@ -148516,6 +148516,15 @@ function logsApi(_logger) {
148516
148516
  }
148517
148517
 
148518
148518
  // src/api/diagnostic-api.ts
148519
+ function endpointTreeNode(ep) {
148520
+ return {
148521
+ id: ep.id,
148522
+ endpoint: ep.number,
148523
+ deviceType: `0x${ep.type.deviceType.toString(16).padStart(4, "0")}`,
148524
+ deviceTypeName: ep.type.name,
148525
+ parts: [...ep.parts].map((p) => endpointTreeNode(p))
148526
+ };
148527
+ }
148519
148528
  function detectEnvironment() {
148520
148529
  if (process.env.SUPERVISOR_TOKEN || process.env.HASSIO_TOKEN) {
148521
148530
  return "Home Assistant Add-on";
@@ -148590,7 +148599,14 @@ function diagnosticApi(bridgeService, haClient, haRegistry, version, startTime)
148590
148599
  failedEntities: failedEntities.map((fe) => ({
148591
148600
  entityId: anonymize ? anonymizeEntityId(fe.entityId) : fe.entityId,
148592
148601
  reason: fe.reason
148593
- }))
148602
+ })),
148603
+ endpointTree: (() => {
148604
+ try {
148605
+ return endpointTreeNode(b.server);
148606
+ } catch {
148607
+ return void 0;
148608
+ }
148609
+ })()
148594
148610
  };
148595
148611
  });
148596
148612
  const recentLogs = logBuffer.entries.slice(-logLimit).map((entry) => ({
@@ -173607,8 +173623,38 @@ var PumpType = PumpDevice.with(
173607
173623
  PumpOnOffServer,
173608
173624
  PumpConfigurationAndControlServer2
173609
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
+ );
173610
173652
  function PumpEndpoint(homeAssistantEntity) {
173611
- return PumpType.set({ homeAssistantEntity });
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 });
173612
173658
  }
173613
173659
 
173614
173660
  // src/matter/endpoints/legacy/remote/index.ts
@@ -177628,8 +177674,37 @@ var ValveEndpointType = WaterValveDevice.with(
177628
177674
  HomeAssistantEntityBehavior,
177629
177675
  ValveServer
177630
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
+ );
177631
177702
  function ValveDevice(homeAssistantEntity) {
177632
- return ValveEndpointType.set({ homeAssistantEntity });
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 });
177633
177708
  }
177634
177709
 
177635
177710
  // src/matter/endpoints/legacy/water-heater/index.ts