@riddix/hamh 2.1.0-alpha.613 → 2.1.0-alpha.614
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.
package/dist/backend/cli.js
CHANGED
|
@@ -147183,8 +147183,7 @@ var init_debounce_context = __esm({
|
|
|
147183
147183
|
});
|
|
147184
147184
|
}
|
|
147185
147185
|
unregisterAll() {
|
|
147186
|
-
const
|
|
147187
|
-
for (const key of keys3) {
|
|
147186
|
+
for (const key of [...this.debouncers.keys()]) {
|
|
147188
147187
|
this.unregister(key);
|
|
147189
147188
|
}
|
|
147190
147189
|
}
|
|
@@ -147282,6 +147281,33 @@ var init_retry = __esm({
|
|
|
147282
147281
|
}
|
|
147283
147282
|
});
|
|
147284
147283
|
|
|
147284
|
+
// src/utils/send-ha-message.ts
|
|
147285
|
+
function sendHaMessage(connection, message, timeoutMs = HA_MESSAGE_TIMEOUT_MS) {
|
|
147286
|
+
let timer;
|
|
147287
|
+
const timeout = new Promise((_, reject) => {
|
|
147288
|
+
timer = setTimeout(() => {
|
|
147289
|
+
reject(
|
|
147290
|
+
new Error(
|
|
147291
|
+
`HA message '${message.type}' timed out after ${timeoutMs}ms`
|
|
147292
|
+
)
|
|
147293
|
+
);
|
|
147294
|
+
}, timeoutMs);
|
|
147295
|
+
});
|
|
147296
|
+
return Promise.race([
|
|
147297
|
+
connection.sendMessagePromise(message),
|
|
147298
|
+
timeout
|
|
147299
|
+
]).finally(() => {
|
|
147300
|
+
if (timer) clearTimeout(timer);
|
|
147301
|
+
});
|
|
147302
|
+
}
|
|
147303
|
+
var HA_MESSAGE_TIMEOUT_MS;
|
|
147304
|
+
var init_send_ha_message = __esm({
|
|
147305
|
+
"src/utils/send-ha-message.ts"() {
|
|
147306
|
+
"use strict";
|
|
147307
|
+
HA_MESSAGE_TIMEOUT_MS = 3e4;
|
|
147308
|
+
}
|
|
147309
|
+
});
|
|
147310
|
+
|
|
147285
147311
|
// src/services/home-assistant/home-assistant-actions.ts
|
|
147286
147312
|
import { callService } from "home-assistant-js-websocket";
|
|
147287
147313
|
var defaultConfig, HomeAssistantActions;
|
|
@@ -147291,6 +147317,7 @@ var init_home_assistant_actions = __esm({
|
|
|
147291
147317
|
init_service();
|
|
147292
147318
|
init_debounce_context();
|
|
147293
147319
|
init_retry();
|
|
147320
|
+
init_send_ha_message();
|
|
147294
147321
|
init_diagnostic_event_bus();
|
|
147295
147322
|
defaultConfig = {
|
|
147296
147323
|
retryAttempts: 3,
|
|
@@ -147433,8 +147460,7 @@ var init_home_assistant_actions = __esm({
|
|
|
147433
147460
|
};
|
|
147434
147461
|
}
|
|
147435
147462
|
fireEvent(eventType, eventData) {
|
|
147436
|
-
|
|
147437
|
-
connection.sendMessagePromise({
|
|
147463
|
+
sendHaMessage(this.client.connection, {
|
|
147438
147464
|
type: "fire_event",
|
|
147439
147465
|
event_type: eventType,
|
|
147440
147466
|
event_data: eventData
|
|
@@ -147879,7 +147905,7 @@ WARNING: ${includeIdentity ? "This backup contains sensitive Matter identity dat
|
|
|
147879
147905
|
router.post("/restart", async (_, res) => {
|
|
147880
147906
|
res.json({ message: "Restarting application..." });
|
|
147881
147907
|
setTimeout(() => {
|
|
147882
|
-
process.
|
|
147908
|
+
process.kill(process.pid, "SIGTERM");
|
|
147883
147909
|
}, 500);
|
|
147884
147910
|
});
|
|
147885
147911
|
router.get("/snapshots", async (_, res) => {
|
|
@@ -151527,13 +151553,18 @@ var WebApi = class extends Service {
|
|
|
151527
151553
|
if (this.server) {
|
|
151528
151554
|
return;
|
|
151529
151555
|
}
|
|
151530
|
-
this.server = await new Promise((resolve6) => {
|
|
151556
|
+
this.server = await new Promise((resolve6, reject) => {
|
|
151531
151557
|
const server = this.app.listen(this.props.port, () => {
|
|
151532
151558
|
this.log.info(
|
|
151533
151559
|
`HTTP server (API ${this.props.webUiDist ? "& Web App" : "only"}) listening on port ${this.props.port}`
|
|
151534
151560
|
);
|
|
151535
151561
|
resolve6(server);
|
|
151536
151562
|
});
|
|
151563
|
+
server.on("error", (err) => {
|
|
151564
|
+
reject(
|
|
151565
|
+
err.code === "EADDRINUSE" ? new Error(`Port ${this.props.port} already in use`) : err
|
|
151566
|
+
);
|
|
151567
|
+
});
|
|
151537
151568
|
});
|
|
151538
151569
|
this.wsApi.attach(this.server, this.props.basePath);
|
|
151539
151570
|
}
|
|
@@ -152594,23 +152625,24 @@ function logStartupMemoryGuard(log) {
|
|
|
152594
152625
|
init_retry();
|
|
152595
152626
|
|
|
152596
152627
|
// src/services/home-assistant/api/get-registry.ts
|
|
152628
|
+
init_send_ha_message();
|
|
152597
152629
|
async function getRegistry(connection) {
|
|
152598
|
-
return
|
|
152630
|
+
return sendHaMessage(connection, {
|
|
152599
152631
|
type: "config/entity_registry/list"
|
|
152600
152632
|
});
|
|
152601
152633
|
}
|
|
152602
152634
|
async function getDeviceRegistry(connection) {
|
|
152603
|
-
return connection
|
|
152635
|
+
return sendHaMessage(connection, {
|
|
152604
152636
|
type: "config/device_registry/list"
|
|
152605
152637
|
});
|
|
152606
152638
|
}
|
|
152607
152639
|
async function getLabelRegistry(connection) {
|
|
152608
|
-
return connection
|
|
152640
|
+
return sendHaMessage(connection, {
|
|
152609
152641
|
type: "config/label_registry/list"
|
|
152610
152642
|
});
|
|
152611
152643
|
}
|
|
152612
152644
|
async function getAreaRegistry(connection) {
|
|
152613
|
-
return connection
|
|
152645
|
+
return sendHaMessage(connection, {
|
|
152614
152646
|
type: "config/area_registry/list"
|
|
152615
152647
|
});
|
|
152616
152648
|
}
|
|
@@ -180424,6 +180456,7 @@ var BridgeEndpointManager = class extends Service {
|
|
|
180424
180456
|
// src/services/bridges/bridge-registry.ts
|
|
180425
180457
|
init_dist();
|
|
180426
180458
|
init_esm();
|
|
180459
|
+
init_send_ha_message();
|
|
180427
180460
|
import { callService as callService2 } from "home-assistant-js-websocket";
|
|
180428
180461
|
import { keys as keys2, pickBy as pickBy2, values as values3 } from "lodash-es";
|
|
180429
180462
|
var BridgeRegistry = class _BridgeRegistry {
|
|
@@ -180795,7 +180828,7 @@ var BridgeRegistry = class _BridgeRegistry {
|
|
|
180795
180828
|
if (!this.client) return [];
|
|
180796
180829
|
if (!(supportedFeatures & VacuumDeviceFeature.CLEAN_AREA)) return [];
|
|
180797
180830
|
try {
|
|
180798
|
-
const entry = await this.client.connection
|
|
180831
|
+
const entry = await sendHaMessage(this.client.connection, {
|
|
180799
180832
|
type: "config/entity_registry/get",
|
|
180800
180833
|
entity_id: entityId
|
|
180801
180834
|
});
|
|
@@ -180809,7 +180842,7 @@ var BridgeRegistry = class _BridgeRegistry {
|
|
|
180809
180842
|
}
|
|
180810
180843
|
let validSegmentIds;
|
|
180811
180844
|
try {
|
|
180812
|
-
const segmentsResponse = await this.client.connection
|
|
180845
|
+
const segmentsResponse = await sendHaMessage(this.client.connection, {
|
|
180813
180846
|
type: "vacuum/get_segments",
|
|
180814
180847
|
entity_id: entityId
|
|
180815
180848
|
});
|