fix homeassistnat
This commit is contained in:
parent
8b436e1ad5
commit
77c4a7599a
@ -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,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user