change door polling to use 200 status code and increase graceful timeout time
All checks were successful
Build and push image for doorman-homeassistant / docker (push) Successful in 25s
Build and push Doorman UI / API / docker (push) Successful in 1m23s
Build and push image for doorman-homeassistant / deploy-gitainer (push) Successful in 22s

This commit is contained in:
Martin Dimitrov 2024-11-11 19:14:20 -08:00
parent 01fce99766
commit cb9b011013
2 changed files with 6 additions and 6 deletions

View File

@ -37,7 +37,7 @@ exports.handler = async function(context, event, callback) {
}
response
.setStatusCode(401)
.setStatusCode(200)
.appendHeader('Content-Type', 'application/json')
.setBody({
status: "CLOSED",

View File

@ -9,7 +9,7 @@ const http = require('http');
/**
* Helper function to do an HTTP request and just await transmission, but not await a response.
* ref: https://www.sensedeep.com/blog/posts/stories/lambda-fast-http.html
* @param {*} url - the URL to do HTTP request to
* @param url - the URL to do HTTP request to
* @returns promise signalling HTTP request has been transmitted
*/
async function lambdaFastHttp(url) {
@ -102,10 +102,10 @@ exports.handler = async function(context, event, callback) {
const unlockPromise = new Promise((resolve, reject) => {
intervals.push(setInterval(() => {
fetch(context.DOORMAN_URL + `/api/door/status?door=${config.door}`)
.then(async res => {
if (res.status === 200) {
.then(res => res.json())
.then(async body => {
if (body?.status === "OPEN") {
clearInterval(intervals[0]);
const body = await res.json();
const twiml = new Twilio.twiml.VoiceResponse();
doorOpenTwiml(twiml, config);
if (!discordLock) {
@ -148,7 +148,7 @@ exports.handler = async function(context, event, callback) {
invokeId, "GracefulFallbackPromise: dropping out of the race, unlock is already notifying discord users"
);
}
}, 6000));
}, 8000));
});
const ungracefulFallbackPromise = new Promise((resolve, reject) => {