jochem725 / homebridge-toon

Homebridge Plugin for Toon Thermostats
14 stars 8 forks source link

Losing Toon connection #3

Closed SonicRevolutions closed 7 years ago

SonicRevolutions commented 8 years ago

Homebridge is losing Toon connection after a certain amount of time. Restarting the homebridge process will login to the Toon site again and things will work as it should.

Is this a known issue?

jochem725 commented 8 years ago

@SonicRevolutions I've only been using the plugin to read the temperature lately, so I haven't noticed this issue. I've seen this issue before, but I could not replicate it so I created #2. After running some tests this week it appears reading temperature values always works, but after some time setting the temperature stops working.

Is this the same behaviour you are experiencing?

SonicRevolutions commented 8 years ago

@jochem725 once the connection is gone mine doesn't get the correct temperature info either.

jochem725 commented 8 years ago

@SonicRevolutions I think I've found the issue. I'm working on a fix, but I am unable to test it because there appears to be a failure of the Toon server. If the server issues are resolved, I'll publish a test branch so you can check if thinks work correctly again.

matthijsotterloo commented 7 years ago

@jochem725 Is the test branch ready yet?

jochem725 commented 7 years ago

@matthijsotterloo, @SonicRevolutions I've just finished a complete rewrite of the plugin, it can be found at #4 including an npm install link to test. Sometimes the connection may be unstable, since the issues at the Toon op Afstand servers still persist. Please let me know if this improves things.

matthijsotterloo commented 7 years ago

@jochem725 Great! Will try this tonight. Yesterday I kept getting the notice that it had to be initialized first. Is this a bug in the script or has it something to do with the Toon op Afstand server issues?

jochem725 commented 7 years ago

@matthijsotterloo I think a combination of both is the case. I haven't been using the plugin for a while myself, but after looking into the issues I decided it was better to rewrite the thing. I'm no longer seeing any connection issues to my Toon, so thats already a major improvement.

matthijsotterloo commented 7 years ago

@jochem725 It works! Altough I sometimes get some weird error in my console.

Error: Received invalid response from Toon +undefined at /usr/local/lib/node_modules/homebridge-toon/toon.js:148:27 at tryCatcher (/usr/local/lib/node_modules/homebridge-toon/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/usr/local/lib/node_modules/homebridge-toon/node_modules/bluebird/js/release/promise.js:510:31) at Promise._settlePromise (/usr/local/lib/node_modules/homebridge-toon/node_modules/bluebird/js/release/promise.js:567:18) at Promise._settlePromise0 (/usr/local/lib/node_modules/homebridge-toon/node_modules/bluebird/js/release/promise.js:612:10) at Promise._settlePromises (/usr/local/lib/node_modules/homebridge-toon/node_modules/bluebird/js/release/promise.js:691:18) at Promise._fulfill (/usr/local/lib/node_modules/homebridge-toon/node_modules/bluebird/js/release/promise.js:636:18) at Request._callback (/usr/local/lib/node_modules/homebridge-toon/node_modules/bluebird/js/release/nodeback.js:42:21) at Request.self.callback (/usr/local/lib/node_modules/homebridge-toon/node_modules/request/request.js:187:22) at emitTwo (events.js:106:13) at Request.emit (events.js:191:7) at Request.<anonymous> (/usr/local/lib/node_modules/homebridge-toon/node_modules/request/request.js:1048:10) at emitOne (events.js:96:13) at Request.emit (events.js:188:7) at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/homebridge-toon/node_modules/request/request.js:969:12) at emitNone (events.js:91:20)

matthijsotterloo commented 7 years ago

And now I get "{"success":false,"reason":"Display already has max number of clients: 4","errorCode":"couldNotRegisterAsListenerForDisplay"}"

jochem725 commented 7 years ago

@matthijsotterloo I have not yet encountered the first error, not sure what causes it. The second response is returned when too many applications are logged in to Toon op Afstand, mostly happens after restarting, since it does not log out if Homebridge terminates.

SonicRevolutions commented 7 years ago

Connections issues seem fixed. I also receive the invalid response error but it's working properly.

jochem725 commented 7 years ago

@matthijsotterloo @SonicRevolutions I've managed to resolved the first issue, it appears that the server sends only a header with a success statuscode, but no data if there are no changes to report. Reinstalling the fix branch should solve your issues. I was unable to resolve the Display already has max number of clients problem. It only occurs for me after multiple restarts of the plugin in a short time but I cannot prevent this.

SonicRevolutions commented 7 years ago

Works perfect for me. @matthijsotterloo close the issue?

jochem725 commented 7 years ago

If @matthijsotterloo no longer has any issues with #4, I'll publish the new version to npm.

matthijsotterloo commented 7 years ago

Yes, close the issue and push to npm! @jochem725

jochem725 commented 7 years ago

I've published the new version to npm. Thanks for helping out @SonicRevolutions, @matthijsotterloo