SteffeyDev / homebridge-hyundai-bluelink

Homebridge plugin for Hyundai BlueLink
Apache License 2.0
26 stars 13 forks source link

Client Error GotError #353

Closed networkneil closed 9 months ago

networkneil commented 1 year ago

Describe The Bug: Unable to connect to Hyundai Telematics API

To Reproduce:

  1. Adding the Plugin
  2. User settings
  3. save the configuration
  4. Homebridge dashboard shows the API error.

I tried using the same login on the Hyundai app and myhyundai website, both worked as expected.

Expected behavior: The Dashboard should show its able to connect to Hyundai Telematics API and be able to perform various Vehicle tasks such as to lock and unlock Logs:

Client Error GotError [RequestError]: write EPROTO C0C78E174B7F0000:error:0A000152:SSL routines:final_renegotiate:unsafe legacy renegotiation disabled:../deps/openssl/openssl/ssl/statem/extensions.c:922:

    at ClientRequest.<anonymous> (/var/lib/homebridge/node_modules/homebridge-hyundai-bluelink/node_modules/got/source/request-as-event-emitter.js:178:14)
    at Object.onceWrapper (node:events:628:26)
    at ClientRequest.emit (node:events:525:35)
    at ClientRequest.origin.emit (/var/lib/homebridge/node_modules/homebridge-hyundai-bluelink/node_modules/@szmarczak/http-timer/source/index.js:37:11)
    at TLSSocket.socketErrorListener (node:_http_client:502:9)
    at TLSSocket.emit (node:events:513:28)
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at processTicksAndRejections (node:internal/process/task_queues:82:21) {
  code: 'EPROTO',
  host: 'api.telematics.hyundaiusa.com',
  hostname: 'api.telematics.hyundaiusa.com',
  method: 'POST',
  path: '/v2/ac/oauth/token',
  socketPath: undefined,
  protocol: 'https:',
  url: 'https://api.telematics.hyundaiusa.com/v2/ac/oauth/token',
  gotOptions: {
    path: '/v2/ac/oauth/token',
    protocol: 'https:',
    slashes: true,
    auth: null,
    host: 'api.telematics.hyundaiusa.com',
    port: null,
    hostname: 'api.telematics.hyundaiusa.com',
    hash: null,
    search: null,
    query: null,
    pathname: '/v2/ac/oauth/token',
    href: 'https://api.telematics.hyundaiusa.com/v2/ac/oauth/token',
    retry: {
      retries: [Function (anonymous)],
      methods: [Set],
      statusCodes: [Set],
      errorCodes: [Set]
    },
    headers: {
      'user-agent': 'PostmanRuntime/7.26.10',
      client_id: 'REDACTED',
      client_secret: 'REDACTED',
      accept: 'application/json',
      'accept-encoding': 'gzip, deflate',
      'content-type': 'application/json',
      'content-length': 71
    },
    hooks: {
      beforeRequest: [],
      beforeRedirect: [],
      beforeRetry: [],
      afterResponse: [],
      beforeError: [],
      init: []
    },
    decompress: true,
    throwHttpErrors: true,
    followRedirect: true,
    stream: false,
    form: false,
    json: true,
    cache: false,
    useElectronNet: false,
    method: 'POST',
    body: '{"username":"REDACTED","password":"REDACTED"}'
  }
}

Plugin Config:

{
    "credentials": {
        "username": "REDACTED",
        "password": "REDACTED",
        "region": "US",
        "brand": "hyundai",
        "pin": "REDACTED"
    },
    "vehicles": [
        {
            "vin": "REDACTED",
            "maxRange": 380
        }
    ],
    "remoteStart": {
        "airCtrl": true,
        "heating1": false,
        "defrost": false,
        "igniOnDuration": 10
    },
    "platform": "Hyundai",
    "_bridge": {
        "username": "REDACTED",
        "port": REDACTED
    }
}

Screenshots:

Environment:

networkneil commented 1 year ago

Steps already taken:

  1. Restarted the Homebride server in the UI using "Force Service Restart"
  2. Restarted the VM
  3. Followed the instructions https://github.com/SteffeyDev/homebridge-hyundai-bluelink#ssl-key-too-small
  4. Tried doing the Start and Stop using the Hyundai App and Hyundai website, both working as expected.
fratinize commented 1 year ago

Same here

carlosgamezvillegas commented 1 year ago

Same issue here. Sometimes when I restart the plug in I don't have the error but now it has been a day and still not working.

carlosgamezvillegas commented 1 year ago

Please see this post from the Bluelinky Github: https://github.com/Hacksore/bluelinky/issues/254. To work around the problem downgrading the Node to V16 is needed.

Kind regards,

drumstix1020 commented 1 year ago

I couldn't find that thread, but I figured I'd at least try downgrading to Node v16. I tried to check my current Node version to no luck, the Raspberry Pi I'm running on seems to think it isn't installed - unless it isn't installed? I just reinstalled the OS fresh and am rebuilding my Homebridge setup. Maybe Node wasn't installed along the way with Homebridge or the system? Here are my logs, if anybody can look through to see if I'm getting something different from OP --

[8/11/2023, 1:38:47 AM] [Hyundai] Client Error GotError [RequestError]: write EPROTO C0BAFE76:error:0A000152:SSL routines:final_renegotiate:unsafe legacy renegotiation disabled:../deps/openssl/openssl/ssl/statem/extensions.c:922:

    at ClientRequest.<anonymous> (/var/lib/homebridge/node_modules/homebridge-hyundai-bluelink2/node_modules/got/source/request-as-event-emitter.js:178:14)
    at Object.onceWrapper (node:events:628:26)
    at ClientRequest.emit (node:events:525:35)
    at ClientRequest.origin.emit (/var/lib/homebridge/node_modules/homebridge-hyundai-bluelink2/node_modules/@szmarczak/http-timer/source/index.js:37:11)
    at TLSSocket.socketErrorListener (node:_http_client:502:9)
    at TLSSocket.emit (node:events:513:28)
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at processTicksAndRejections (node:internal/process/task_queues:82:21) {
  code: 'EPROTO',
  host: 'api.telematics.hyundaiusa.com',
  hostname: 'api.telematics.hyundaiusa.com',
  method: 'POST',
  path: '/v2/ac/oauth/token',
  socketPath: undefined,
  protocol: 'https:',
  url: 'https://api.telematics.hyundaiusa.com/v2/ac/oauth/token',
  gotOptions: {
    path: '/v2/ac/oauth/token',
    protocol: 'https:',
    slashes: true,
    auth: null,
    host: 'api.telematics.hyundaiusa.com',
    port: null,
    hostname: 'api.telematics.hyundaiusa.com',
    hash: null,
    search: null,
    query: null,
    pathname: '/v2/ac/oauth/token',
    href: 'https://api.telematics.hyundaiusa.com/v2/ac/oauth/token',
    retry: {
      retries: [Function (anonymous)],
      methods: [Set],
      statusCodes: [Set],
      errorCodes: [Set]
    },
    headers: {
      'user-agent': 'PostmanRuntime/7.26.10',
      client_id: 'm66129Bb-em93-SPAHYN-bZ91-am4540zp19920',
      client_secret: 'v558o935-6nne-423i-baa8',
      accept: 'application/json',
      'accept-encoding': 'gzip, deflate',
      'content-type': 'application/json',
      'content-length': 70
    },
    hooks: {
      beforeRequest: [],
      beforeRedirect: [],
      beforeRetry: [],
      afterResponse: [],
      beforeError: [],
      init: []
    },
    decompress: true,
    throwHttpErrors: true,
    followRedirect: true,
    stream: false,
    form: false,
    json: true,
    cache: false,
    useElectronNet: false,
    method: 'POST',
    body: '{"username":"jakemprice@icloud.com","password":"cutwyh-2duwpo-josbuS"}'
  }
}
carlosgamezvillegas commented 1 year ago

I made some edits to the link so you might want to try again. If you have Homebridge UI installed it should be easy to identify the node version you are currently running.

I believe I used this command in Terminal to get the right node version: sudo hb-service update-node 16.13.0 IMG_2614

drumstix1020 commented 1 year ago

That did the trick! I only edited your code slightly to get the updated 16.20.1 like in your screenshot instead of 16.13.0, and it worked perfectly. So excited to try this out now that the accessory is showing up in the Home app!

fratinize commented 1 year ago

Do we really have to down grade to an, as of this month am I supported version of node? I'm sure there are lots of smart people out there that can't fix this. Wish my brain was big enough or I'd do it! If I can help the next maintainer pls reach out, I would love To get this working again with out an unsupported version of node. Ty

carlosgamezvillegas commented 1 year ago

Unfortunately, the issue is with one of the dependencies of the plug-in. The people that made Bluelinky are fine with the workaround and are not in a hurry to fix it any time soon.

You can find more information here: https://github.com/Hacksore/bluelinky/issues/254

Having an unsupported version of node is not necessarily bad u less other Homebridge have issues with it

shpress commented 11 months ago

No longer able to downgrade below 16.18.2 and still getting the same error. @drumstix1020 What code did you edit and how please help!!

carlosgamezvillegas commented 11 months ago

@shpress, you can use this command in Terminal to install a working node.js version: sudo hb-service update-node 16.20.2

If id does not want to install the version check what hombridge version you have. I think the Homebridge 1.7 requieres node.js 18 at the least

shpress commented 11 months ago

@carlosgamezvillegas So I was able t get to 16.20.2 but still getting this error homebridge-hyundai-bluelink] Status fetch error Cannot read properties of undefined (reading 'result')

carlosgamezvillegas commented 11 months ago

I just restated my hombridge to de if I got the same error but it loads just fine. Did you update anything else? Hombridge?

shpress commented 11 months ago

So I try running a command from my Apple Home App and this is what happens: [11/9/2023, 6:50:23 PM] [homebridge-hyundai-bluelink] Starting Vehicle [2023-11-09 18:50:23] info: Begin pre-authentication [11/9/2023, 6:50:28 PM] [homebridge-hyundai-bluelink] Start Response Vehicle started!

But nothing actually happens with the car. Sorry im somewhat technical but just so lost with this one.

carlosgamezvillegas commented 11 months ago

What Version of Hombridge are you using?

shpress commented 10 months ago

1.7.0

OS: Ubuntu Focal Fossa (20.04.5 LTS) Hostname: oznu-homebridge-1

carlosgamezvillegas commented 10 months ago

Probably that is the issue. Hombridge 1.7 does not support node.js 16. Try to downgrade Homebridge

shpress commented 10 months ago

Just tried that on 1.6.1 still having the same issue.

carlosgamezvillegas commented 10 months ago

I am out of ideas. The only thing left is to do a fresh installation of Homebridge 1.6 in a different device to check if that fixes the issue.

fratinize commented 10 months ago

Do we really have to down grade to an, as of this month am I supported version of node? I'm sure there are lots of smart people out there that can't fix this. Wish my brain was big enough or I'd do it! If I can help the next maintainer pls reach out, I would love To get this working again with out an unsupported version of node. Ty

I am surprised the big brains around here haven’t taken control and fixed this looks like Bluetooth k has a new interface maybe someone can attach this and fix it ty let me k ow if I can help

carlosgamezvillegas commented 10 months ago

@fratinize, like it was mentioned before, the issue is not with this plugin it is with one of the dependencies. We need that to be fix first before this plugin can be fix. The dependency is Bluelinky l, and when I reached out to them about this issue they mentioned that one of their dependencies was causing the issue.

fratinize commented 10 months ago

Ty for that info Much appreciatedSent from my iPhoneOn Dec 2, 2023, at 3:18 PM, carlosgamezvillegas @.***> wrote: @fratinize, like it was mantiene before, the issue is not with this plugin it is with one of the dependencies. We need that to be fix first before this plugin can be fix. The dependency is Bluelinky l, and when I reached out to them about this issue they mentioned that one of their dependencies was causing the issue.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>