fix homeassistnat
Some checks failed
Build and push Doorman UI / API / docker (push) Has been cancelled
Build and push image for doorman-homeassistant / docker (push) Failing after 4s
Build and push image for doorman-homeassistant / deploy-gitainer (push) Has been skipped

This commit is contained in:
Martin Dimitrov 2024-12-12 18:59:30 -08:00
parent 8b436e1ad5
commit 77c4a7599a

View File

@ -1,8 +1,8 @@
import { serve } from "bun"; import { serve } from "bun";
import { Hono } from "hono"; import { Hono } from "hono";
import { prettyJSON } from "hono/pretty-json"; import { prettyJSON } from "hono/pretty-json";
import { createDDBClient, getDoorConfigCommand, getLockStatusCommand, isLockOpen } from "../../doorman-api/src/utils/ddb";
import * as ddb from "../../doorman-api/deprecated-functions/common/ddb.private"; import { DoorStatus } from "../../doorman-api/src/types/DoorStatus";
const app = new Hono(); const app = new Hono();
@ -16,17 +16,17 @@ app.get("/api/door/info", async (c) => {
}, 400); }, 400);
} }
const client = ddb.createDDBClient(Bun.env); const client = createDDBClient(Bun.env as any);
const config = await client.send(ddb.getDoorConfigCommand(door)); const config = await client.send(getDoorConfigCommand(door));
if (!config.Item) { if (!config.Item) {
return c.json({ return c.json({
err: "This buzzer is not registered properly", err: "This buzzer is not registered properly",
}, 404); }, 404);
} }
return await client.send(ddb.getLockStatusCommand(door)) return await client.send(getLockStatusCommand(door))
.then(async (lock) => { .then(async (lock) => {
const status = ddb.isLockOpen(lock) ? "OPEN": "CLOSED"; const status = isLockOpen(lock) ? DoorStatus.OPEN: "CLOSED";
return c.json({ return c.json({
id: door, id: door,
status, status,