From 5f2fd012647e8be144cb4384f3c2c56bcd31d73b Mon Sep 17 00:00:00 2001 From: Noah Overcash Date: Fri, 8 May 2020 17:17:12 -0400 Subject: [PATCH] Send a request to delControlPermission endpoint after a control change (mentioned in related sampsyo/wideq#80) --- lib/core/request.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/core/request.ts b/lib/core/request.ts index 1e16cff..5e602f3 100644 --- a/lib/core/request.ts +++ b/lib/core/request.ts @@ -43,6 +43,15 @@ client.interceptors.response.use((resp) => { }); const out = resp.data[constants.DATA_ROOT]; + // we must release control otherwise it bricks the stock app for a while + if (url.endsWith("rtiControl")) { + await client.post(url.replace("rtiControl", "delControlPermission"), { + [constants.DATA_ROOT]: { + deviceId: data.deviceId // this exists for control commands + } + }, { headers }); + } + if ('returnCd' in out) { const code = out.returnCd as string;