@riddix/hamh 2.1.0-alpha.615 → 2.1.0-alpha.616

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.
@@ -11896,7 +11896,7 @@ var init_ServerAddress = __esm({
11896
11896
  return Diagnostic.squash(...diagnostic);
11897
11897
  }
11898
11898
  ServerAddress2.diagnosticFor = diagnosticFor;
11899
- function isEqual(a, b) {
11899
+ function isEqual2(a, b) {
11900
11900
  if (a.type !== b.type) {
11901
11901
  return false;
11902
11902
  }
@@ -11908,7 +11908,7 @@ var init_ServerAddress = __esm({
11908
11908
  }
11909
11909
  return false;
11910
11910
  }
11911
- ServerAddress2.isEqual = isEqual;
11911
+ ServerAddress2.isEqual = isEqual2;
11912
11912
  function healthOf(health) {
11913
11913
  if (health.unhealthyAt === void 0) {
11914
11914
  return health;
@@ -146105,6 +146105,7 @@ var init_clusters2 = __esm({
146105
146105
  ClusterId3["bridgedDeviceBasicInformation"] = "bridgedDeviceBasicInformation";
146106
146106
  ClusterId3["airQuality"] = "airQuality";
146107
146107
  ClusterId3["booleanState"] = "booleanState";
146108
+ ClusterId3["booleanStateConfiguration"] = "booleanStateConfiguration";
146108
146109
  ClusterId3["carbonDioxideConcentrationMeasurement"] = "carbonDioxideConcentrationMeasurement";
146109
146110
  ClusterId3["carbonMonoxideConcentrationMeasurement"] = "carbonMonoxideConcentrationMeasurement";
146110
146111
  ClusterId3["colorControl"] = "colorControl";
@@ -147038,10 +147039,13 @@ var init_color_converter = __esm({
147038
147039
  }
147039
147040
  /**
147040
147041
  * Convert Color Tempareture from Mireds to Kelvin
147041
- * @param temperatureMireds Temperature in Mireds
147042
- * @return Temperature in Kelvin
147042
+ * @param temperatureMireds Temperature in Mireds (must be finite and > 0)
147043
+ * @return Temperature in Kelvin, or null if the input is 0 / negative / non-finite
147043
147044
  */
147044
147045
  static temperatureMiredsToKelvin(temperatureMireds) {
147046
+ if (!Number.isFinite(temperatureMireds) || temperatureMireds <= 0) {
147047
+ return null;
147048
+ }
147045
147049
  return 1e6 / temperatureMireds;
147046
147050
  }
147047
147051
  /**
@@ -152332,23 +152336,30 @@ var BridgeService = class extends Service {
152332
152336
  }
152333
152337
  }
152334
152338
  async stopAll() {
152335
- for (const bridge of this.bridges) {
152336
- try {
152337
- await bridge.stop();
152338
- this.onBridgeChanged?.(bridge.id);
152339
- } catch (e) {
152340
- this.log.error(`Failed to stop bridge ${bridge.id}:`, e);
152341
- }
152342
- }
152339
+ await Promise.all(
152340
+ this.bridges.map(async (bridge) => {
152341
+ try {
152342
+ await bridge.stop();
152343
+ this.onBridgeChanged?.(bridge.id);
152344
+ } catch (e) {
152345
+ this.log.error(`Failed to stop bridge ${bridge.id}:`, e);
152346
+ }
152347
+ })
152348
+ );
152343
152349
  }
152344
152350
  async restartAll() {
152345
- for (const bridge of this.bridges) {
152346
- try {
152347
- await bridge.stop();
152348
- } catch (e) {
152349
- this.log.error(`Failed to stop bridge ${bridge.id} during restart:`, e);
152350
- }
152351
- }
152351
+ await Promise.all(
152352
+ this.bridges.map(async (bridge) => {
152353
+ try {
152354
+ await bridge.stop();
152355
+ } catch (e) {
152356
+ this.log.error(
152357
+ `Failed to stop bridge ${bridge.id} during restart:`,
152358
+ e
152359
+ );
152360
+ }
152361
+ })
152362
+ );
152352
152363
  const sortedBridges = [...this.bridges].sort((a, b) => {
152353
152364
  const priorityA = a.data.priority ?? 100;
152354
152365
  const priorityB = b.data.priority ?? 100;
@@ -152769,19 +152780,15 @@ var HomeAssistantRegistry = class extends Service {
152769
152780
  }
152770
152781
  });
152771
152782
  }
152772
- const entityRegistry = await getRegistry(connection);
152773
- const statesList = await getStates(connection);
152774
- const deviceRegistry = await getDeviceRegistry(connection);
152775
- let labels = [];
152776
- try {
152777
- labels = await getLabelRegistry(connection);
152778
- } catch {
152779
- }
152780
- let areas = [];
152781
- try {
152782
- areas = await getAreaRegistry(connection);
152783
- } catch {
152784
- }
152783
+ const [entityRegistry, statesList, deviceRegistry, labels, areas] = await Promise.all([
152784
+ getRegistry(connection),
152785
+ getStates(connection),
152786
+ getDeviceRegistry(connection),
152787
+ getLabelRegistry(connection).catch(() => []),
152788
+ getAreaRegistry(connection).catch(
152789
+ () => []
152790
+ )
152791
+ ]);
152785
152792
  const hash2 = createHash("md5");
152786
152793
  for (const e of entityRegistry) {
152787
152794
  hash2.update(
@@ -168081,6 +168088,7 @@ init_dist();
168081
168088
  init_esm();
168082
168089
  init_home_assistant_entity_behavior();
168083
168090
  import debounce5 from "debounce";
168091
+ import { isEqual } from "lodash-es";
168084
168092
 
168085
168093
  // src/matter/endpoints/entity-endpoint.ts
168086
168094
  init_esm7();
@@ -170505,13 +170513,15 @@ var ContactSensorType = ContactSensorDevice.with(
170505
170513
  BasicInformationServer2,
170506
170514
  IdentifyServer2,
170507
170515
  HomeAssistantEntityBehavior,
170508
- BooleanStateServer2({ inverted: true })
170516
+ BooleanStateServer2({ inverted: true }),
170517
+ BooleanStateConfigurationServer
170509
170518
  );
170510
170519
  var ContactSensorWithBatteryType = ContactSensorDevice.with(
170511
170520
  BasicInformationServer2,
170512
170521
  IdentifyServer2,
170513
170522
  HomeAssistantEntityBehavior,
170514
170523
  BooleanStateServer2({ inverted: true }),
170524
+ BooleanStateConfigurationServer,
170515
170525
  PowerSourceServer2({
170516
170526
  getBatteryPercent: (entity, agent) => {
170517
170527
  const homeAssistant = agent.get(HomeAssistantEntityBehavior);
@@ -170717,7 +170727,8 @@ var RainSensorType = RainSensorDevice.with(
170717
170727
  BasicInformationServer2,
170718
170728
  IdentifyServer2,
170719
170729
  HomeAssistantEntityBehavior,
170720
- BooleanStateServer2()
170730
+ BooleanStateServer2(),
170731
+ BooleanStateConfigurationServer
170721
170732
  );
170722
170733
 
170723
170734
  // ../../node_modules/.pnpm/@matter+main@0.16.11/node_modules/@matter/main/dist/esm/forwards/behaviors/smoke-co-alarm.js
@@ -170807,7 +170818,8 @@ var WaterFreezeDetectorType = WaterFreezeDetectorDevice.with(
170807
170818
  BasicInformationServer2,
170808
170819
  IdentifyServer2,
170809
170820
  HomeAssistantEntityBehavior,
170810
- BooleanStateServer2()
170821
+ BooleanStateServer2(),
170822
+ BooleanStateConfigurationServer
170811
170823
  );
170812
170824
 
170813
170825
  // src/matter/endpoints/legacy/binary-sensor/water-leak-detector.ts
@@ -170816,7 +170828,8 @@ var WaterLeakDetectorType = WaterLeakDetectorDevice.with(
170816
170828
  BasicInformationServer2,
170817
170829
  IdentifyServer2,
170818
170830
  HomeAssistantEntityBehavior,
170819
- BooleanStateServer2()
170831
+ BooleanStateServer2(),
170832
+ BooleanStateConfigurationServer
170820
170833
  );
170821
170834
 
170822
170835
  // src/matter/endpoints/legacy/binary-sensor/index.ts
@@ -171450,6 +171463,8 @@ var ThermostatServerBase = class extends FullFeaturedBase {
171450
171463
  default:
171451
171464
  return allOff;
171452
171465
  }
171466
+ default:
171467
+ return allOff;
171453
171468
  }
171454
171469
  }
171455
171470
  clampControlSequence(value) {
@@ -171621,7 +171636,10 @@ var hvacActionToRunningMode = {
171621
171636
  [ClimateHvacAction.preheating]: Thermostat3.ThermostatRunningMode.Heat,
171622
171637
  [ClimateHvacAction.defrosting]: Thermostat3.ThermostatRunningMode.Heat,
171623
171638
  [ClimateHvacAction.heating]: Thermostat3.ThermostatRunningMode.Heat,
171624
- [ClimateHvacAction.drying]: Thermostat3.ThermostatRunningMode.Heat,
171639
+ // Drying has no dedicated Matter RunningMode; reporting Heat made Apple
171640
+ // Home display "Heating to …" during dehumidification. Off is neutral and
171641
+ // getRunningState() downgrades it to FanOnly/Dry via systemMode.
171642
+ [ClimateHvacAction.drying]: Thermostat3.ThermostatRunningMode.Off,
171625
171643
  [ClimateHvacAction.cooling]: Thermostat3.ThermostatRunningMode.Cool,
171626
171644
  [ClimateHvacAction.fan]: Thermostat3.ThermostatRunningMode.Off,
171627
171645
  [ClimateHvacAction.idle]: Thermostat3.ThermostatRunningMode.Off,
@@ -172242,7 +172260,7 @@ function WindowCoveringServer2(config10) {
172242
172260
  }
172243
172261
 
172244
172262
  // src/matter/endpoints/legacy/cover/behaviors/cover-position-utils.ts
172245
- function adjustPositionForReading(position, flags2, matterSemantics) {
172263
+ function adjustPosition(position, flags2, matterSemantics) {
172246
172264
  if (position == null) {
172247
172265
  return null;
172248
172266
  }
@@ -172255,18 +172273,11 @@ function adjustPositionForReading(position, flags2, matterSemantics) {
172255
172273
  }
172256
172274
  return position;
172257
172275
  }
172276
+ function adjustPositionForReading(position, flags2, matterSemantics) {
172277
+ return adjustPosition(position, flags2, matterSemantics);
172278
+ }
172258
172279
  function adjustPositionForWriting(position, flags2, matterSemantics) {
172259
- if (position == null) {
172260
- return null;
172261
- }
172262
- const skipInversion = flags2?.coverDoNotInvertPercentage === true || flags2?.coverUseHomeAssistantPercentage === true || matterSemantics;
172263
- if (flags2?.coverSwapOpenClose === true && !skipInversion) {
172264
- return position;
172265
- }
172266
- if (!skipInversion) {
172267
- return 100 - position;
172268
- }
172269
- return position;
172280
+ return adjustPosition(position, flags2, matterSemantics);
172270
172281
  }
172271
172282
 
172272
172283
  // src/matter/endpoints/legacy/cover/behaviors/cover-window-covering-server.ts
@@ -172808,12 +172819,16 @@ function FanDevice2(homeAssistantEntity) {
172808
172819
  IdentifyServer2,
172809
172820
  BasicInformationServer2,
172810
172821
  HomeAssistantEntityBehavior,
172822
+ GroupsServer,
172823
+ ScenesManagementServer,
172811
172824
  FanOnOffServer,
172812
172825
  DefaultPowerSourceServer
172813
172826
  ) : OnOffPlugInUnitDevice.with(
172814
172827
  IdentifyServer2,
172815
172828
  BasicInformationServer2,
172816
172829
  HomeAssistantEntityBehavior,
172830
+ GroupsServer,
172831
+ ScenesManagementServer,
172817
172832
  FanOnOffServer
172818
172833
  );
172819
172834
  return onOffDevice.set({ homeAssistantEntity });
@@ -172842,6 +172857,7 @@ function FanDevice2(homeAssistantEntity) {
172842
172857
  IdentifyServer2,
172843
172858
  BasicInformationServer2,
172844
172859
  HomeAssistantEntityBehavior,
172860
+ GroupsServer,
172845
172861
  FanOnOffServer,
172846
172862
  FanFanControlServer.with(...features2),
172847
172863
  DefaultPowerSourceServer
@@ -172849,6 +172865,7 @@ function FanDevice2(homeAssistantEntity) {
172849
172865
  IdentifyServer2,
172850
172866
  BasicInformationServer2,
172851
172867
  HomeAssistantEntityBehavior,
172868
+ GroupsServer,
172852
172869
  FanOnOffServer,
172853
172870
  FanFanControlServer.with(...features2)
172854
172871
  );
@@ -173161,9 +173178,12 @@ var ColorControlServerBase = class extends FeaturedBase7 {
173161
173178
  ...skipColorTemp ? {} : { colorTemperatureMireds: effectiveMireds }
173162
173179
  });
173163
173180
  }
173181
+ const writingHueSat = this.features.hueSaturation && !skipHueSat;
173182
+ const writingColorTemp = !skipColorTemp && newColorMode === ColorControl3.ColorMode.ColorTemperatureMireds;
173183
+ const shouldPublishColorMode = writingHueSat && newColorMode !== ColorControl3.ColorMode.ColorTemperatureMireds || writingColorTemp;
173164
173184
  applyPatchState(this.state, {
173165
- ...skipColorTemp && skipHueSat ? {} : { colorMode: newColorMode },
173166
- ...this.features.hueSaturation && !skipHueSat ? {
173185
+ ...shouldPublishColorMode ? { colorMode: newColorMode } : {},
173186
+ ...writingHueSat ? {
173167
173187
  currentHue: hue,
173168
173188
  currentSaturation: saturation
173169
173189
  } : {}
@@ -173181,6 +173201,9 @@ var ColorControlServerBase = class extends FeaturedBase7 {
173181
173201
  this.agent
173182
173202
  );
173183
173203
  const targetKelvin = ColorConverter.temperatureMiredsToKelvin(targetMireds);
173204
+ if (targetKelvin == null) {
173205
+ return;
173206
+ }
173184
173207
  if (currentKelvin === targetKelvin) {
173185
173208
  return;
173186
173209
  }
@@ -173368,6 +173391,8 @@ var ColorTemperatureLightType = ColorTemperatureLightDevice.with(
173368
173391
  IdentifyServer2,
173369
173392
  BasicInformationServer2,
173370
173393
  HomeAssistantEntityBehavior,
173394
+ GroupsServer,
173395
+ ScenesManagementServer,
173371
173396
  LightOnOffServer,
173372
173397
  LightLevelControlServer,
173373
173398
  LightColorControlServer.with("ColorTemperature")
@@ -173379,6 +173404,8 @@ var DimmableLightType = DimmableLightDevice.with(
173379
173404
  IdentifyServer2,
173380
173405
  BasicInformationServer2,
173381
173406
  HomeAssistantEntityBehavior,
173407
+ GroupsServer,
173408
+ ScenesManagementServer,
173382
173409
  LightOnOffServer,
173383
173410
  LightLevelControlServer
173384
173411
  );
@@ -173386,6 +173413,8 @@ var DimmableLightWithBatteryType = DimmableLightDevice.with(
173386
173413
  IdentifyServer2,
173387
173414
  BasicInformationServer2,
173388
173415
  HomeAssistantEntityBehavior,
173416
+ GroupsServer,
173417
+ ScenesManagementServer,
173389
173418
  LightOnOffServer,
173390
173419
  LightLevelControlServer,
173391
173420
  DefaultPowerSourceServer
@@ -173406,6 +173435,8 @@ var ExtendedColorLightType = (supportsColorControl, supportsTemperature, hasBatt
173406
173435
  IdentifyServer2,
173407
173436
  BasicInformationServer2,
173408
173437
  HomeAssistantEntityBehavior,
173438
+ GroupsServer,
173439
+ ScenesManagementServer,
173409
173440
  LightOnOffServer,
173410
173441
  LightLevelControlServer,
173411
173442
  LightColorControlServer.with(...features2),
@@ -173416,6 +173447,8 @@ var ExtendedColorLightType = (supportsColorControl, supportsTemperature, hasBatt
173416
173447
  IdentifyServer2,
173417
173448
  BasicInformationServer2,
173418
173449
  HomeAssistantEntityBehavior,
173450
+ GroupsServer,
173451
+ ScenesManagementServer,
173419
173452
  LightOnOffServer,
173420
173453
  LightLevelControlServer,
173421
173454
  LightColorControlServer.with(...features2)
@@ -173428,12 +173461,16 @@ var OnOffLightType = OnOffLightDevice.with(
173428
173461
  IdentifyServer2,
173429
173462
  BasicInformationServer2,
173430
173463
  HomeAssistantEntityBehavior,
173464
+ GroupsServer,
173465
+ ScenesManagementServer,
173431
173466
  LightOnOffServer
173432
173467
  );
173433
173468
  var OnOffLightWithBatteryType = OnOffLightDevice.with(
173434
173469
  IdentifyServer2,
173435
173470
  BasicInformationServer2,
173436
173471
  HomeAssistantEntityBehavior,
173472
+ GroupsServer,
173473
+ ScenesManagementServer,
173437
173474
  LightOnOffServer,
173438
173475
  DefaultPowerSourceServer
173439
173476
  );
@@ -176477,6 +176514,8 @@ var DimmablePlugInUnitType = DimmablePlugInUnitDevice.with(
176477
176514
  IdentifyServer2,
176478
176515
  BasicInformationServer2,
176479
176516
  HomeAssistantEntityBehavior,
176517
+ GroupsServer,
176518
+ ScenesManagementServer,
176480
176519
  LightOnOffServer,
176481
176520
  LightLevelControlServer
176482
176521
  );
@@ -176488,12 +176527,16 @@ var SwitchEndpointType = OnOffPlugInUnitDevice.with(
176488
176527
  BasicInformationServer2,
176489
176528
  IdentifyServer2,
176490
176529
  HomeAssistantEntityBehavior,
176530
+ GroupsServer,
176531
+ ScenesManagementServer,
176491
176532
  SwitchOnOffServer
176492
176533
  );
176493
176534
  var SwitchWithBatteryEndpointType = OnOffPlugInUnitDevice.with(
176494
176535
  BasicInformationServer2,
176495
176536
  IdentifyServer2,
176496
176537
  HomeAssistantEntityBehavior,
176538
+ GroupsServer,
176539
+ ScenesManagementServer,
176497
176540
  SwitchOnOffServer,
176498
176541
  DefaultPowerSourceServer
176499
176542
  );
@@ -179762,7 +179805,7 @@ var LegacyEndpoint = class _LegacyEndpoint extends EntityEndpoint {
179762
179805
  async updateStates(states) {
179763
179806
  const state = states[this.entityId] ?? {};
179764
179807
  const mappedChanged = this.hasMappedEntityChanged(states);
179765
- if (!mappedChanged && state.state === this.lastState?.state && JSON.stringify(state.attributes) === JSON.stringify(this.lastState?.attributes)) {
179808
+ if (!mappedChanged && state.state === this.lastState?.state && isEqual(state.attributes, this.lastState?.attributes)) {
179766
179809
  return;
179767
179810
  }
179768
179811
  if (mappedChanged) {