From 25919479672b8261bb6f5b69d935d0c0d66db021 Mon Sep 17 00:00:00 2001 From: ChrisMack Date: Wed, 15 Nov 2017 15:19:08 -0600 Subject: [PATCH] added secToken header and addtl params to http requests as per chamberlain requirements --- server/myq.service.js | 7 +++++-- smartapps/aromka/myq-controller.src/myq-controller.groovy | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/server/myq.service.js b/server/myq.service.js index cec34ff..f588462 100644 --- a/server/myq.service.js +++ b/server/myq.service.js @@ -43,7 +43,7 @@ var exports = module.exports = new function () { * @returns {string} */ function getUrl(path) { - return 'https://myqexternal.myqdevice.com' + path + '?appId=' + myQAppId + '&securityToken=' + config.securityToken + return 'https://myqexternal.myqdevice.com' + path + '?filterOn=true&format=json&nojsoncallback=1&appId=' + myQAppId + '&securityToken=' + config.securityToken } /** @@ -95,10 +95,12 @@ var exports = module.exports = new function () { url: getUrl('/api/v4/userdevicedetails/get'), headers: { 'User-Agent': 'Chamberlain/3.73', + 'Accept': '*/*', 'BrandId': '2', 'ApiVersion': '4.1', 'Culture': 'en', - 'MyQApplicationId': myQAppId + 'MyQApplicationId': myQAppId, + 'SecurityToken': config.securityToken } }, handleGetDeviceResponse) .on('error', function (e) { @@ -344,6 +346,7 @@ var exports = module.exports = new function () { * @param value */ this.processCommand = function (deviceId, command, value) { + console.log(deviceId, command); doProcessCommand(deviceId, command, value); }; diff --git a/smartapps/aromka/myq-controller.src/myq-controller.groovy b/smartapps/aromka/myq-controller.src/myq-controller.groovy index 4f4e38d..b32c39e 100644 --- a/smartapps/aromka/myq-controller.src/myq-controller.groovy +++ b/smartapps/aromka/myq-controller.src/myq-controller.groovy @@ -387,6 +387,7 @@ def exec(device, command, value, retry) { "BrandId": "2", "ApiVersion": "4.1", "Culture": "en", + "SecurityToken": atomicState.security.securityToken, "MyQApplicationId": getMyQAppId() ], body: [ @@ -394,7 +395,9 @@ def exec(device, command, value, retry) { SecurityToken: atomicState.security.securityToken, MyQDeviceId: device.currentValue('id'), AttributeName: command, - AttributeValue: value + AttributeValue: value, + Format: json, + Nojsoncallback: 1 ] ]) { response -> //check response, continue if 200 OK