jeffschubert / homebridge-daikin-oneplus

Homebridge plugin to control a Daikin One+ thermostat
Apache License 2.0
18 stars 7 forks source link

“No token for request” error #5

Closed jonnyborbs closed 2 years ago

jonnyborbs commented 2 years ago

After installing the latest build of the plugin to Homebridge, I'm seeing the following error:

It isn't clear why it's throwing a bad token response as the username and password provided in the config are valid

02/08/2021, 21:44:08] [Daikin One+] Error with token response: []
[02/08/2021, 21:44:08] [Daikin One+] { message: 'NotAuthorizedException' } []
[02/08/2021, 21:44:08] [Daikin One+] 400 []
[02/08/2021, 21:44:08] [Daikin One+] {
  'content-type': 'application/json',
  'content-length': '36',
  connection: 'close',
  date: 'Tue, 03 Aug 2021 04:44:08 GMT',
  'x-amzn-requestid': '<redacted>',
  'access-control-allow-origin': '*',
  'access-control-allow-headers': 'Content-Type,Authorization,X-Api-Key',
  'x-amz-apigw-id': '<redacted>',
  'access-control-allow-methods': 'DELETE,GET,OPTIONS,POST,PUT',
  'x-amzn-trace-id': 'Root=1-<redacted>;Sampled=0',
  'x-cache': 'Error from cloudfront',
  via: '1.1 a2f3f72865ff056225454005e6fdaae6.cloudfront.net (CloudFront)',
  'x-amz-cf-pop': 'LAX50-C3',
  'x-amz-cf-id': '<redacted>'
} []
[02/08/2021, 21:44:08] [Daikin One+] No token for request: https://api.daikinskyport.com/locations []
[02/08/2021, 21:44:08] [Daikin One+] No token for request: https://api.daikinskyport.com/devices []
[02/08/2021, 21:44:08] [Daikin One+] Unable to retrieve token. []
(node:4835) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'length' of undefined
    at DaikinApi.Initialize (/usr/local/lib/node_modules/homebridge-daikin-oneplus/src/daikinapi.ts:47:59)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at DaikinOnePlusPlatform.discoverDevices (/usr/local/lib/node_modules/homebridge-daikin-oneplus/src/platform.ts:100:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:4835) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:4835) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
jonnyborbs commented 2 years ago

Update: unchecking the "Include Device Name" box allowed this to work normally, but that seems like a bug to me. In a multi-zone configuration, that's an important capability otherwise all the thermostats show up with the same name in HomeKit

jeffschubert commented 2 years ago

I'll need to retest locally with it on to ensure there's not something obvious going on when including the device name. I've had that turned off lately on mine as I only have a single thermostat. I wouldn't be surprised if I introduced a bug accidentally.

jonnyborbs commented 2 years ago

Thanks! That would be very much appreciated. I can sorta backprobe the thermostats via serial number to see which is which, but definitely having the device name translate into Homebridge would be the preferred route

jeffschubert commented 2 years ago

Can you try turning that option back on, save, and restart homebridge? The error you encountered isn't related to that option specifically. It's a more general issue where a failure to get the token initially isn't handled properly. Since it worked the after you unset the option, it should work with it on. I was able to confirm on my setup that the option works as expected if it gets the token. If turning it back on works for you, feel free to close this out. I'll create a bug specifically for handling token issues during initialization.

jonnyborbs commented 2 years ago

Spot on, that worked great. I thought I had tried doing that already but maybe I was wrong! Thanks for the replies and the plugin!