mikakoivisto / controlmyspa-ha-mqtt

GNU General Public License v3.0
11 stars 4 forks source link

"failed to login", null tokenData error causes add-on to terminate #17

Closed jkrall closed 3 months ago

jkrall commented 3 months ago

HA docker add-on log shows the following error:

(node:135) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.
(Use `node --trace-warnings ...` to show where the warning was created)
2024-05-26T23:01:28.835Z app:info MQTT connection established
failed to login
/usr/src/app/lib/spa.js:34
      }, (self.client.tokenData.expires_in - 60) * 1000);
                                ^

TypeError: Cannot read properties of null (reading 'expires_in')
    at Spa.<anonymous> (/usr/src/app/lib/spa.js:34:33)
    at Spa.emit (node:events:531:35)
    at /usr/src/app/lib/spa.js:24:12
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v20.13.1

I get this every time I start the add-on, and it dies immediately.

In another issue thread, I saw that you mentioned having to fork controlmyspa.js to deal with an API change. Is this possibly related? I'm a software engineer, so I'm happy to help figure this out if you need a hand... but I wasn't sure where to even get started here. Have you run across this issue?

jkrall commented 3 months ago

Closing this — I believe it was caused by my version of the addon not picking up your recent changes, where you forked the controlmyspa library. For whatever reason, my local version didn't update and was still running on the published dependent package. Seems to be working after an uninstall and fresh install.