Closed shahvo closed 10 months ago
Having this too. @iklein99 thank you for your work on this plugin. There is currently some incorrect behavior with the amount of errors getting thrown in thermostatService.ts. Basically when you throw one of those due to a bad poll or invalid temp reading, you are actually causing Homebridge to crash completely and restart.
Ex:
if (temp === null || temp === undefined) {
throw(new this.platform.api.hap.HapStatusError(this.platform.api.hap.HAPStatus.RESOURCE_DOES_NOT_EXIST));
}
All of those throws need to be caught properly and dealt with. It should not lead to a crash.
In the meantime I would advise simply clamping your error output and return the clamped result. Print a message to the console but only throw if there's some sort of unrecoverable error.
I’m going to work on that over the next couple of days. I’ll reach out to you to test it for me.
On Aug 18, 2023, at 11:13 AM, Jon Reed @.***> wrote:
Having this too. @iklein99 https://github.com/iklein99 thank you for your work on this plugin. There is currently some incorrect behavior with the amount of errors getting thrown in thermostatService.ts. Basically when you throw one of those due to a bad poll or invalid temp reading, you are actually causing Homebridge to crash completely and restart.
Ex: if (temp === null || temp === undefined) { throw(new this.platform.api.hap.HapStatusError(this.platform.api.hap.HAPStatus.RESOURCE_DOES_NOT_EXIST)); }
All of those throws need to be caught properly and dealt with. It should not lead to a crash.
In the meantime I would advise simply clamping your error output and return the clamped result. Print a message to the console but only throw if there's some sort of unrecoverable error.
— Reply to this email directly, view it on GitHub https://github.com/iklein99/homebridge-smartthings/issues/203#issuecomment-1684063982, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABG55EQBJVD3DVS3SOFAUIDXV6BA7ANCNFSM6AAAAAA3UMG6HI. You are receiving this because you were mentioned.
Excellent, will do, thanks!
Thank you and will also help with testing.
So, I believe the issue is how Homebridge is dealing with the error specifically for Thermostats. What I'm doing is proper if the device isn't returning a valid status, but for some reason, Homebridge crashes when it is a Thermostat (I tested with other devices simulating an error and it doesn't crash).
Anyway, I made a change in the latest version to just return a zero if we can't get status back from the thermostat. You should contact the developer of the device driver for the thermostat to understand why it isn't returning a valid status.
@iklein99 Thanks for the changes that has helped a lot! The issue is my thermostat is Z Wave which complicates things a bit, so it probably has a range of values it can emit that might not make sense. The polling issue specifically cropped up due to a poor Z wave signal, but with the error gone it allowed me to figure that out and fix so thank you!
While this change has helped significantly I am now noticing occasional 401s and timeouts that happen to Smartthings via the plugin in Homebridge. This usually happens overnight. The issue is that it appears the connection is not retried after it errors out and so the plugin completely stops working (requires a restart of homebridge to fix). Do you have any suggestions?
Here's a bit of the logs I'm seeing for context. Note that this is before I upgraded the plugin so the HAP status error is still shown
[8/25/2023, 10:22:36 AM] [Smartthings Plug (IK)] Z-Wave Battery Thermostat battery level LOW
[8/25/2023, 10:51:35 AM] [Smartthings Plug (IK)] Failed to request status from Z-Wave Battery Thermostat: Error: connect ETIMEDOUT 3.22.115.178:443. This is failure number 1
[8/25/2023, 10:51:35 AM] Error: HAP Status Error: -70402
at new HapStatusError (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/util/hapStatusError.ts:17:5)
at /home/pi/Documents/homebridge-smartthings/src/services/thermostatService.ts:205:18
at processTicksAndRejections (node:internal/process/task_queues:95:5)
[8/25/2023, 10:51:35 AM] [Smartthings Plug (IK)] Poll failure on Z-Wave Battery Thermostat
[8/25/2023, 10:51:35 AM] Error: HAP Status Error: -70402
at new HapStatusError (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/util/hapStatusError.ts:17:5)
at /home/pi/Documents/homebridge-smartthings/src/services/thermostatService.ts:205:18
at runNextTicks (node:internal/process/task_queues:60:5)
at listOnTimeout (node:internal/timers:538:9)
at processTimers (node:internal/timers:512:7)
[8/25/2023, 10:51:35 AM] [Smartthings Plug (IK)] Poll failure on Z-Wave Battery Thermostat
[8/25/2023, 10:51:35 AM] [Smartthings Plug (IK)] Poll failure on Z-Wave Battery Thermostat
[8/25/2023, 10:51:35 AM] [Smartthings Plug (IK)] Poll failure on Z-Wave Battery Thermostat
[8/25/2023, 10:51:35 AM] [Smartthings Plug (IK)] Poll failure on Z-Wave Battery Thermostat
[8/25/2023, 10:51:35 AM] [Smartthings Plug (IK)] Poll failure on Z-Wave Battery Thermostat
[8/25/2023, 10:51:35 AM] [Smartthings Plug (IK)] Poll failure on Z-Wave Battery Thermostat
[8/25/2023, 10:51:35 AM] [Smartthings Plug (IK)] Poll failure on Z-Wave Battery Thermostat
[8/25/2023, 10:51:35 AM] Error: HAP Status Error: -70402
at new HapStatusError (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/util/hapStatusError.ts:17:5)
at /home/pi/Documents/homebridge-smartthings/src/services/thermostatService.ts:205:18
at runNextTicks (node:internal/process/task_queues:60:5)
at listOnTimeout (node:internal/timers:538:9)
at processTimers (node:internal/timers:512:7)
[8/25/2023, 10:51:35 AM] [Smartthings Plug (IK)] Poll failure on Z-Wave Battery Thermostat
[8/25/2023, 10:51:35 AM] Error: HAP Status Error: -70402
at new HapStatusError (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/util/hapStatusError.ts:17:5)
at /home/pi/Documents/homebridge-smartthings/src/services/thermostatService.ts:205:18
at runNextTicks (node:internal/process/task_queues:60:5)
at listOnTimeout (node:internal/timers:538:9)
at processTimers (node:internal/timers:512:7)
[8/25/2023, 10:51:35 AM] [Smartthings Plug (IK)] Poll failure on Z-Wave Battery Thermostat
The issue is that in your case the SmartThings API isn’t responding and the plugin will mark it unavailable after a certain number of failures in a row. For now, maybe you can automate resting homebridge int he morning.
On Aug 26, 2023, at 4:21 PM, Jon Reed @.***> wrote:
Here's a bit of the logs I'm seeing for context. Note that this is before I upgraded the plugin so the HAP status error is still shown
[8/25/2023, 10:22:36 AM] [Smartthings Plug (IK)] Z-Wave Battery Thermostat battery level LOW [8/25/2023, 10:51:35 AM] [Smartthings Plug (IK)] Failed to request status from Z-Wave Battery Thermostat: Error: connect ETIMEDOUT 3.22.115.178:443. This is failure number 1 [8/25/2023, 10:51:35 AM] Error: HAP Status Error: -70402 at new HapStatusError (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/util/hapStatusError.ts:17:5) at /home/pi/Documents/homebridge-smartthings/src/services/thermostatService.ts:205:18 at processTicksAndRejections (node:internal/process/task_queues:95:5) [8/25/2023, 10:51:35 AM] [Smartthings Plug (IK)] Poll failure on Z-Wave Battery Thermostat [8/25/2023, 10:51:35 AM] Error: HAP Status Error: -70402 at new HapStatusError (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/util/hapStatusError.ts:17:5) at /home/pi/Documents/homebridge-smartthings/src/services/thermostatService.ts:205:18 at runNextTicks (node:internal/process/task_queues:60:5) at listOnTimeout (node:internal/timers:538:9) at processTimers (node:internal/timers:512:7) [8/25/2023, 10:51:35 AM] [Smartthings Plug (IK)] Poll failure on Z-Wave Battery Thermostat [8/25/2023, 10:51:35 AM] [Smartthings Plug (IK)] Poll failure on Z-Wave Battery Thermostat [8/25/2023, 10:51:35 AM] [Smartthings Plug (IK)] Poll failure on Z-Wave Battery Thermostat [8/25/2023, 10:51:35 AM] [Smartthings Plug (IK)] Poll failure on Z-Wave Battery Thermostat [8/25/2023, 10:51:35 AM] [Smartthings Plug (IK)] Poll failure on Z-Wave Battery Thermostat [8/25/2023, 10:51:35 AM] [Smartthings Plug (IK)] Poll failure on Z-Wave Battery Thermostat [8/25/2023, 10:51:35 AM] [Smartthings Plug (IK)] Poll failure on Z-Wave Battery Thermostat [8/25/2023, 10:51:35 AM] Error: HAP Status Error: -70402 at new HapStatusError (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/util/hapStatusError.ts:17:5) at /home/pi/Documents/homebridge-smartthings/src/services/thermostatService.ts:205:18 at runNextTicks (node:internal/process/task_queues:60:5) at listOnTimeout (node:internal/timers:538:9) at processTimers (node:internal/timers:512:7) [8/25/2023, 10:51:35 AM] [Smartthings Plug (IK)] Poll failure on Z-Wave Battery Thermostat [8/25/2023, 10:51:35 AM] Error: HAP Status Error: -70402 at new HapStatusError (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/util/hapStatusError.ts:17:5) at /home/pi/Documents/homebridge-smartthings/src/services/thermostatService.ts:205:18 at runNextTicks (node:internal/process/task_queues:60:5) at listOnTimeout (node:internal/timers:538:9) at processTimers (node:internal/timers:512:7) [8/25/2023, 10:51:35 AM] [Smartthings Plug (IK)] Poll failure on Z-Wave Battery Thermostat — Reply to this email directly, view it on GitHub https://github.com/iklein99/homebridge-smartthings/issues/203#issuecomment-1694495138, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABG55EVFKYNHDBYGFCHFCRDXXJLF5ANCNFSM6AAAAAA3UMG6HI. You are receiving this because you were mentioned.
Describe The Bug:
Bad value status and poll failure error from connected Thermostat during start up Trane thermostat connected to SmartThings
To Reproduce:
Enable plugin and see startup logs
Expected behavior:
No errors
Logs:
[Smartthings Plug (IK)] Upstairs Thermostat returned bad value for status [Smartthings Plug (IK)] Bad status from Upstairs Thermostat. Ignoring for now. [Smartthings Plug (IK)] Poll failure on Family Room Thermostat
Environment: PI4
Plugin Version:
homebridge-smartthings-ik v1.5.13
Homebridge Version: 1.6.1
Operating System: Raspbian