@riddix/hamh 2.1.0-alpha.735 → 2.1.0-alpha.736

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.
@@ -124663,8 +124663,8 @@ var init_bridge_config_schema = __esm({
124663
124663
  default: false
124664
124664
  },
124665
124665
  serverMode: {
124666
- title: "Server Mode (for Robot Vacuums)",
124667
- description: "Expose the device as a standalone Matter device instead of a bridged device. This is required for Apple Home to properly support Siri voice commands for Robot Vacuums. IMPORTANT: Only ONE device should be in this bridge when server mode is enabled.",
124666
+ title: "Server Mode (standalone device)",
124667
+ description: "Expose the entity as a standalone Matter device instead of a bridged device. Works for any supported device type, e.g. robot vacuums need it for Apple Home Siri voice commands. IMPORTANT: Only ONE device should be in this bridge when server mode is enabled.",
124668
124668
  type: "boolean",
124669
124669
  default: false
124670
124670
  },
@@ -124822,7 +124822,10 @@ var init_create_bridge_request_schema = __esm({
124822
124822
  "../common/dist/schemas/create-bridge-request-schema.js"() {
124823
124823
  "use strict";
124824
124824
  init_bridge_config_schema();
124825
- createBridgeRequestSchema = bridgeConfigSchema;
124825
+ createBridgeRequestSchema = {
124826
+ ...bridgeConfigSchema,
124827
+ required: ["name", "filter"]
124828
+ };
124826
124829
  }
124827
124830
  });
124828
124831
 
@@ -130502,11 +130505,13 @@ var BridgeService = class extends Service {
130502
130505
  return this.bridges.find((bridge) => bridge.id === id);
130503
130506
  }
130504
130507
  async create(request) {
130505
- if (this.portUsed(request.port)) {
130506
- throw new Error(`Port already in use: ${request.port}`);
130508
+ const port = request.port ?? this.getNextAvailablePort();
130509
+ if (this.portUsed(port)) {
130510
+ throw new Error(`Port already in use: ${port}`);
130507
130511
  }
130508
130512
  const bridge = await this.addBridge({
130509
130513
  ...request,
130514
+ port,
130510
130515
  id: crypto3.randomUUID().replace(/-/g, ""),
130511
130516
  basicInformation: this.props.basicInformation
130512
130517
  });
@@ -164105,20 +164110,20 @@ var ServerModeVacuumEndpoint = class _ServerModeVacuumEndpoint extends EntityEnd
164105
164110
 
164106
164111
  // src/services/bridges/server-mode-endpoint-manager.ts
164107
164112
  var ServerModeEndpointManager = class extends Service {
164108
- constructor(serverNode, client, registry2, mappingStorage, bridgeId, log) {
164113
+ constructor(serverNode, client, registry2, mappingStorage, dataProvider, log) {
164109
164114
  super("ServerModeEndpointManager");
164110
164115
  this.serverNode = serverNode;
164111
164116
  this.client = client;
164112
164117
  this.registry = registry2;
164113
164118
  this.mappingStorage = mappingStorage;
164114
- this.bridgeId = bridgeId;
164119
+ this.dataProvider = dataProvider;
164115
164120
  this.log = log;
164116
164121
  }
164117
164122
  serverNode;
164118
164123
  client;
164119
164124
  registry;
164120
164125
  mappingStorage;
164121
- bridgeId;
164126
+ dataProvider;
164122
164127
  log;
164123
164128
  entityIds = [];
164124
164129
  unsubscribe;
@@ -164135,7 +164140,7 @@ var ServerModeEndpointManager = class extends Service {
164135
164140
  return this.deviceEndpoint;
164136
164141
  }
164137
164142
  getEntityMapping(entityId) {
164138
- return this.mappingStorage.getMapping(this.bridgeId, entityId);
164143
+ return this.mappingStorage.getMapping(this.dataProvider.id, entityId);
164139
164144
  }
164140
164145
  computeMappingFingerprint(mapping) {
164141
164146
  if (!mapping) return "";
@@ -164186,6 +164191,10 @@ var ServerModeEndpointManager = class extends Service {
164186
164191
  this.entityIds = this.registry.entityIds;
164187
164192
  if (this.entityIds.length === 0) {
164188
164193
  this.log.warn("Server mode bridge has no entities configured");
164194
+ this._failedEntities.push({
164195
+ entityId: this.dataProvider.filter?.include?.[0]?.value ?? "(no entity configured)",
164196
+ reason: "No Home Assistant entity matched this bridge's filter. Check for typos or renamed/removed entities."
164197
+ });
164189
164198
  return;
164190
164199
  }
164191
164200
  if (this.entityIds.length > 1) {
@@ -164206,6 +164215,10 @@ var ServerModeEndpointManager = class extends Service {
164206
164215
  this.log.warn(
164207
164216
  `The only entity in server mode bridge is disabled: ${entityId}`
164208
164217
  );
164218
+ this._failedEntities.push({
164219
+ entityId,
164220
+ reason: "The configured entity is disabled for this bridge."
164221
+ });
164209
164222
  return;
164210
164223
  }
164211
164224
  const currentFp = this.computeMappingFingerprint(mapping);
@@ -164286,9 +164299,10 @@ var ServerModeEndpointManager = class extends Service {
164286
164299
  const reason = e instanceof Error ? e.message : String(e);
164287
164300
  this.log.error(`Failed to create server mode device ${entityId}:`, e);
164288
164301
  this._failedEntities.push({ entityId, reason });
164289
- }
164290
- if (this.unsubscribe) {
164291
- this.startObserving();
164302
+ } finally {
164303
+ if (this.unsubscribe) {
164304
+ this.startObserving();
164305
+ }
164292
164306
  }
164293
164307
  }
164294
164308
  async updateStates(states) {
@@ -164482,7 +164496,7 @@ var BridgeEnvironmentFactory = class extends BridgeFactory {
164482
164496
  await env.load(HomeAssistantClient),
164483
164497
  env.get(BridgeRegistry),
164484
164498
  await env.load(EntityMappingStorage),
164485
- dataProvider.id,
164499
+ dataProvider,
164486
164500
  loggerService.get("ServerModeEndpointManager")
164487
164501
  );
164488
164502
  class ServerModeBridgeWithEnvironment extends ServerModeBridge {