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 response
.setStatusCode(401) .setStatusCode(200)
.appendHeader('Content-Type', 'application/json') .appendHeader('Content-Type', 'application/json')
.setBody({ .setBody({
status: "CLOSED", 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. * 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 * 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 * @returns promise signalling HTTP request has been transmitted
*/ */
async function lambdaFastHttp(url) { async function lambdaFastHttp(url) {
@ -102,10 +102,10 @@ exports.handler = async function(context, event, callback) {
const unlockPromise = new Promise((resolve, reject) => { const unlockPromise = new Promise((resolve, reject) => {
intervals.push(setInterval(() => { intervals.push(setInterval(() => {
fetch(context.DOORMAN_URL + `/api/door/status?door=${config.door}`) fetch(context.DOORMAN_URL + `/api/door/status?door=${config.door}`)
.then(async res => { .then(res => res.json())
if (res.status === 200) { .then(async body => {
if (body?.status === "OPEN") {
clearInterval(intervals[0]); clearInterval(intervals[0]);
const body = await res.json();
const twiml = new Twilio.twiml.VoiceResponse(); const twiml = new Twilio.twiml.VoiceResponse();
doorOpenTwiml(twiml, config); doorOpenTwiml(twiml, config);
if (!discordLock) { 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" invokeId, "GracefulFallbackPromise: dropping out of the race, unlock is already notifying discord users"
); );
} }
}, 6000)); }, 8000));
}); });
const ungracefulFallbackPromise = new Promise((resolve, reject) => { const ungracefulFallbackPromise = new Promise((resolve, reject) => {