@riddix/hamh 2.1.0-alpha.601 → 2.1.0-alpha.603

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.
@@ -145640,11 +145640,11 @@ var init_service = __esm({
145640
145640
  constructor(serviceName) {
145641
145641
  this.serviceName = serviceName;
145642
145642
  }
145643
- construction = new Promise((resolve6) => {
145643
+ construction = new Promise((resolve6, reject) => {
145644
145644
  setImmediate(() => {
145645
145645
  const init = this.initialize?.bind(this) ?? (async () => {
145646
145646
  });
145647
- init().then(resolve6);
145647
+ init().then(resolve6, reject);
145648
145648
  });
145649
145649
  });
145650
145650
  };
@@ -152597,9 +152597,9 @@ var HomeAssistantRegistry = class extends Service {
152597
152597
  }
152598
152598
  async reload() {
152599
152599
  return await withRetry(() => this.fetchRegistries(), {
152600
- maxAttempts: 5,
152600
+ maxAttempts: 10,
152601
152601
  baseDelayMs: 2e3,
152602
- maxDelayMs: 15e3,
152602
+ maxDelayMs: 3e4,
152603
152603
  onRetry: (attempt, error, delayMs) => {
152604
152604
  logger145.warn(
152605
152605
  `Registry fetch failed (attempt ${attempt}), retrying in ${delayMs}ms:`,
@@ -152610,6 +152610,26 @@ var HomeAssistantRegistry = class extends Service {
152610
152610
  }
152611
152611
  async fetchRegistries() {
152612
152612
  const connection = this.client.connection;
152613
+ if (!connection.connected) {
152614
+ logger145.debug("Connection not ready, waiting for reconnect...");
152615
+ await new Promise((resolve6) => {
152616
+ const timeout = setTimeout(() => {
152617
+ connection.removeEventListener("ready", onReady);
152618
+ resolve6();
152619
+ }, 3e4);
152620
+ const onReady = () => {
152621
+ clearTimeout(timeout);
152622
+ connection.removeEventListener("ready", onReady);
152623
+ resolve6();
152624
+ };
152625
+ connection.addEventListener("ready", onReady);
152626
+ if (connection.connected) {
152627
+ clearTimeout(timeout);
152628
+ connection.removeEventListener("ready", onReady);
152629
+ resolve6();
152630
+ }
152631
+ });
152632
+ }
152613
152633
  const entityRegistry = await getRegistry(connection);
152614
152634
  const statesList = await getStates(connection);
152615
152635
  const deviceRegistry = await getDeviceRegistry(connection);
@@ -182355,9 +182375,7 @@ function registerFinalErrorHandlers() {
182355
182375
  });
182356
182376
  }
182357
182377
  async function startHandler(startOptions, webUiDist) {
182358
- Object.assign(globalThis, {
182359
- WebSocket: globalThis.WebSocket ?? ws.WebSocket
182360
- });
182378
+ Object.assign(globalThis, { WebSocket: ws.WebSocket });
182361
182379
  patchLevelControlTlv();
182362
182380
  const options = new Options({ ...startOptions, webUiDist });
182363
182381
  const rootEnv = configureDefaultEnvironment(options);