homebridge-plugins / homebridge-resideo

The Homebridge Resideo plugin allows you to access your Resideo devices from HomeKit.
ISC License
37 stars 8 forks source link

Bug: "Failed to refresh access token: Bad Request" even after relinking #634

Closed tebasham closed 2 years ago

tebasham commented 2 years ago

Describe The Bug

"Request failed with status code 400","name":"Error","stack":"Error: Request failed with status code 400

To Reproduce

Issue is intermittent, restarting the child bridge will temporarily resolve

Expected behavior

No error

Relevant log output

[06/01/2022, 13:23:42] [HoneywellHome] [DEBUG] The client has issued an invalid request. This is commonly used to specify validation errors in a request payload.
[06/01/2022, 13:23:42] [HoneywellHome] Failed to refresh access token, Error: {"message":"Request failed with status code 400","name":"Error","stack":"Error: Request failed with status code 400\n    at createError (/usr/local/lib/node_modules/homebridge-honeywell-home/node_modules/axios/lib/core/createError.js:16:15)\n    at settle (/usr/local/lib/node_modules/homebridge-honeywell-home/node_modules/axios/lib/core/settle.js:17:12)\n    at IncomingMessage.handleStreamEnd (/usr/local/lib/node_modules/homebridge-honeywell-home/node_modules/axios/lib/adapters/http.js:293:11)\n    at IncomingMessage.emit (node:events:402:35)\n    at endReadableNT (node:internal/streams/readable:1343:12)\n    at processTicksAndRejections (node:internal/process/task_queues:83:21)","config":{"transitional":{"silentJSONParsing":true,"forcedJSONParsing":true,"clarifyTimeoutError":false},"transformRequest":[null],"transformResponse":[null],"timeout":0,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","maxContentLength":-1,"maxBodyLength":-1,"headers":{"Accept":"application/json, text/plain, */*","Content-Type":"application/x-www-form-urlencoded","User-Agent":"axios/0.24.0","Content-Length":71},"url":"https://api.honeywell.com/oauth2/token","method":"post","auth":{"username":"XXXXXX","password":"XXXXXX"},"data":"grant_type=refresh_token&refresh_token=XXXXXX","responseType":"json"},"status":400}
[06/01/2022, 13:33:42] [HoneywellHome] Failed to refresh access token: Bad Request
[06/01/2022, 13:33:42] [HoneywellHome] [DEBUG] The client has issued an invalid request. This is commonly used to specify validation errors in a request payload.
[06/01/2022, 13:33:42] [HoneywellHome] Failed to refresh access token, Error: {"message":"Request failed with status code 400","name":"Error","stack":"Error: Request failed with status code 400\n    at createError (/usr/local/lib/node_modules/homebridge-honeywell-home/node_modules/axios/lib/core/createError.js:16:15)\n    at settle (/usr/local/lib/node_modules/homebridge-honeywell-home/node_modules/axios/lib/core/settle.js:17:12)\n    at IncomingMessage.handleStreamEnd (/usr/local/lib/node_modules/homebridge-honeywell-home/node_modules/axios/lib/adapters/http.js:293:11)\n    at IncomingMessage.emit (node:events:402:35)\n    at endReadableNT (node:internal/streams/readable:1343:12)\n    at processTicksAndRejections (node:internal/process/task_queues:83:21)","config":{"transitional":{"silentJSONParsing":true,"forcedJSONParsing":true,"clarifyTimeoutError":false},"transformRequest":[null],"transformResponse":[null],"timeout":0,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","maxContentLength":-1,"maxBodyLength":-1,"headers":{"Accept":"application/json, text/plain, */*","Content-Type":"application/x-www-form-urlencoded","User-Agent":"axios/0.24.0","Content-Length":71},"url":"https://api.honeywell.com/oauth2/token","method":"post","auth":{"username":"XXXXXXX","password":"XXXXXXX"},"data":"grant_type=refresh_token&refresh_token=XXXXXXX","responseType":"json"},"status":400}

Config for homebridge-honeywell-home

{
    "bridge": {
        "name": "Homebridge A5A8",
        "username": "XXXXXX",
        "port": 51646,
        "pin": "XXXXXX",
        "bind": [
            "wlan0"
        ],
        "advertiser": "ciao"
    },
    "accessories": [
        {
            "name": "PurpleAirSensor",
            "sensor": 87327,
            "conversion": "None",
            "averages": "10m",
            "aqiInsteadOfDensity": true,
            "accessory": "PurpleAirSensor",
            "_bridge": {
                "username": "XXXXXX",
                "port": 46736
            }
        }
    ],
    "platforms": [
        {
            "name": "Config",
            "port": 8581,
            "auth": "form",
            "theme": "auto",
            "tempUnits": "f",
            "lang": "auto",
            "platform": "config"
        },
        {
            "email": "XXXXXX",
            "password": "XXXXXX",
            "platform": "myQ",
            "_bridge": {
                "username": "XXXXXX",
                "port": 33874
            }
        },
        {
            "name": "HoneywellHome",
            "credentials": {
                "consumerKey": "XXXXXX",
                "consumerSecret": "XXXXXX",
                "refreshToken": "XXXXXX",
                "notice": "Keep your tokens a secret!"
            },
            "options": {
                "devices": [
                    {
                        "deviceID": "LCC-48A2E613017F",
                        "deviceClass": "Thermostat",
                        "thermostat": {
                            "thermostatSetpointStatus": "TemporaryHold"
                        }
                    }
                ],
                "debug": "debug"
            },
            "_bridge": {
                "username": "XXXXXX",
                "port": 38882
            },
            "platform": "HoneywellHome"
        }
    ],
    "disabledPlugins": [
        "homebridge-platform-wemo"
    ]
}

Screenshots

No response

Device & Model

T5, FW 4.0.0.0

Node.js Version

16.13.1

NPM Version

8.3.0

Homebridge Version

1.3.9

Homebridge Honeywell Home Plugin Version

11.2.0

Homebridge Config UI X Plugin Version

4.41.5

Operating System

Raspbian GNU/Linux Buster (10)

tebasham commented 2 years ago

Error does return on latest beta, 11.2.1-beta.5

[06/01/2022, 13:53:42] [HoneywellHome] Failed to refresh access token: Bad Request
[06/01/2022, 13:53:42] [HoneywellHome] [DEBUG] The client has issued an invalid request. This is commonly used to specify validation errors in a request payload.
[06/01/2022, 13:53:42] [HoneywellHome] Failed to refresh access token, Error: {"message":"Request failed with status code 400","name":"Error","stack":"Error: Request failed with status code 400\n    at createError (/usr/local/lib/node_modules/homebridge-honeywell-home/node_modules/axios/lib/core/createError.js:16:15)\n    at settle (/usr/local/lib/node_modules/homebridge-honeywell-home/node_modules/axios/lib/core/settle.js:17:12)\n    at IncomingMessage.handleStreamEnd (/usr/local/lib/node_modules/homebridge-honeywell-home/node_modules/axios/lib/adapters/http.js:293:11)\n    at IncomingMessage.emit (node:events:402:35)\n    at endReadableNT (node:internal/streams/readable:1343:12)\n    at processTicksAndRejections (node:internal/process/task_queues:83:21)","config":{"transitional":{"silentJSONParsing":true,"forcedJSONParsing":true,"clarifyTimeoutError":false},"transformRequest":[null],"transformResponse":[null],"timeout":0,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","maxContentLength":-1,"maxBodyLength":-1,"headers":{"Accept":"application/json, text/plain, */*","Content-Type":"application/x-www-form-urlencoded","User-Agent":"axios/0.24.0","Content-Length":71},"url":"https://api.honeywell.com/oauth2/token","method":"post","auth":{"username":"XXXXXX","password":"XXXXXX"},"data":"grant_type=refresh_token&refresh_token=XXXXXX","responseType":"json"},"status":400}
donavanbecker commented 2 years ago

@tebasham Have you relinked your account?

tebasham commented 2 years ago

Yes account has been relinked, it resolves for a while sometimes up to 24 hours but the error returns.

donavanbecker commented 2 years ago

@tebasham, I can't reproduce, I feel like this is a Honeywell issue.

donavanbecker commented 2 years ago

What kind of router do you have?

tebasham commented 2 years ago

AmpliFi HD Mesh FW: 3.6.0.

The issue was reproducing for a time on the beta, but has since stopped. I suspect you may be correct in that it was a Honeywell issue.

Thank you for looking into it.

onelight17 commented 2 years ago

@tebasham I got the same/similar error as well and am also using the AmpliFI Mesh. Not sure if that is related to do that though. It happened after I restarted homebridge, was working fine before that. Current running 11.3.3.

[1/16/2022, 4:14:47 PM] [HoneywellHome] Thermostat: Main Level failed to pushChanges, Bad Request
[1/16/2022, 4:14:47 PM] [HoneywellHome] Thermostat: Main Level failed to pushChanges, Error Message: "Request failed with status code 400"
[1/16/2022, 4:14:47 PM] [HoneywellHome] [DEBUG] The client has issued an invalid request. This is commonly used to specify validation errors in a request payload.
[1/16/2022, 4:14:47 PM] [HoneywellHome] Thermostat: Main Level Error: {"message":"Request failed with status code 400","name":"Error","stack":"Error: Request failed with status code 400\n    at createError (/usr/lib/node_modules/homebridge-honeywell-home/node_modules/axios/lib/core/createError.js:16:15)\n    at settle (/usr/lib/node_modules/homebridge-honeywell-home/node_modules/axios/lib/core/settle.js:17:12)\n    at IncomingMessage.handleStreamEnd (/usr/lib/node_modules/homebridge-honeywell-home/node_modules/axios/lib/adapters/http.js:293:11)\n    at IncomingMessage.emit (events.js:412:35)\n    at endReadableNT (internal/streams/readable.js:1334:12)\n    at processTicksAndRejections (internal/process/task_queues.js:82:21)","config":{"transitional":{"silentJSONParsing":true,"forcedJSONParsing":true,"clarifyTimeoutError":false},"transformRequest":[null],"transformResponse":[null],"timeout":0,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","maxContentLength":-1,"maxBodyLength":-1,"headers":{"Accept":"application/json, text/plain, */*","Content-Type":"application/json","Authorization":"Bearer xxxxxx","User-Agent":"axios/0.24.0","Content-Length":122},"responseType":"json","params":{"locationId":3181581,"apikey":"xxxxx"},"method":"post","url":"https://api.honeywell.com/v2/devices/thermostats/LCC-48A2E6160BC5","data":"{\"mode\":\"Cool\",\"thermostatSetpointStatus\":\"PermanentHold\",\"autoChangeoverActive\":true,\"coolSetpoint\":78,\"heatSetpoint\":73}"},"status":400}