From 2fc61ead257f2c11a949bb77441a47c3937a9801 Mon Sep 17 00:00:00 2001 From: Adrian Jagielak Date: Wed, 23 Jul 2025 23:19:20 +0200 Subject: [PATCH] Fix 'delay' helper function reference error --- futurehome/src/index.ts | 5 ++--- futurehome/src/utils.ts | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/futurehome/src/index.ts b/futurehome/src/index.ts index a8ba736..4b5de41 100644 --- a/futurehome/src/index.ts +++ b/futurehome/src/index.ts @@ -6,6 +6,7 @@ import { CommandHandlers, haPublishDevice } from "./ha/publish_device"; import { haUpdateState, haUpdateStateSensorReport } from "./ha/update_state"; import { VinculumPd7Device } from "./fimp/vinculum_pd7_device"; import { haUpdateAvailability } from "./ha/update_availability"; +import { delay } from "./utils"; (async () => { const hubIp = process.env.FH_HUB_IP || "futurehome-smarthub.local"; @@ -25,15 +26,13 @@ import { haUpdateAvailability } from "./ha/update_availability"; log.info("Connected to HA broker"); if (!demoMode && (!hubUsername || !hubPassword)) { - const delay = 50; // milliseconds between each publish - const publishWithDelay = (messages: RetainedMessage[], index = 0) => { if (index >= messages.length) return; const msg = messages[index]; ha?.publish(msg.topic, '', { retain: true, qos: 2 }); - setTimeout(() => publishWithDelay(messages, index + 1), delay); + setTimeout(() => publishWithDelay(messages, index + 1), 50); // 50 milliseconds between each publish }; publishWithDelay(retainedMessages); diff --git a/futurehome/src/utils.ts b/futurehome/src/utils.ts index 3db253c..9968100 100644 --- a/futurehome/src/utils.ts +++ b/futurehome/src/utils.ts @@ -1,3 +1,3 @@ -function delay(ms: number) { +export function delay(ms: number) { return new Promise(resolve => setTimeout(resolve, ms)); }