Closed mrlightison closed 3 weeks ago
Just adding a +1 to this - seeing the same thing in my instance. Let me know if there are any helpful details I can provide.
Sorry nothing I can do about this. This is all the SwitchBot API. SwitchBot will have to resolve this.
And no I don't work for switchBot, I just manage this plugin.
I just updated to 3.4.0 from 2.12.1 and had this error. I rolled back to 2.12.1 and things are fine again.
I see a ton of these and my blinds do not operate reliably anymore:
Maybe a backoff/retry loop in there?
[4/30/2024, 6:19:34 AM] [SwitchBot] Blind Tilt: Blind 1 Internal Server Error, An unexpected error on the SmartThings servers has occurred. These errors should be rare, statusCode: 500 [4/30/2024, 6:19:34 AM] [SwitchBot] Blind Tilt: Blind 1 Unknown statusCode: undefined, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug [4/30/2024, 6:19:34 AM] [SwitchBot] Blind Tilt: Blind 2 Internal Server Error, An unexpected error on the SmartThings servers has occurred. These errors should be rare, statusCode: 500 [4/30/2024, 6:19:34 AM] [SwitchBot] Blind Tilt: Blind 2 Unknown statusCode: undefined, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug [4/30/2024, 6:19:34 AM] [SwitchBot] Blind Tilt: Blind 3 Internal Server Error, An unexpected error on the SmartThings servers has occurred. These errors should be rare, statusCode: 500 [4/30/2024, 6:19:34 AM] [SwitchBot] Blind Tilt: Blind 3 Unknown statusCode: undefined, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug [4/30/2024, 6:19:34 AM] [SwitchBot] Blind Tilt: Blind 4 Internal Server Error, An unexpected error on the SmartThings servers has occurred. These errors should be rare, statusCode: 500 [4/30/2024, 6:19:34 AM] [SwitchBot] Blind Tilt: Blind 4 Unknown statusCode: undefined, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug [4/30/2024, 6:19:54 AM] [HttpWebHooks] Change HomeKit value for temperature sensor to '25.625'. [4/30/2024, 6:19:58 AM] [Lutron] Button /button/178 on Pico remote Jeremy office Controller Pico got action Press [4/30/2024, 6:19:58 AM] [Lutron] Button /button/178 on Pico remote Jeremy office Controller Pico got action Release [4/30/2024, 6:19:59 AM] [Lutron] button /button/178 got a short press [4/30/2024, 6:20:02 AM] [HttpWebHooks] Change HomeKit value for temperature sensor to '20.013'. [4/30/2024, 6:20:03 AM] [HttpWebHooks] Change HomeKit value for humidity sensor to '49.95829564303247'. [4/30/2024, 6:20:03 AM] [HttpWebHooks] Change HomeKit value for temperature sensor to '19.910'. [4/30/2024, 6:20:03 AM] [HttpWebHooks] Change HomeKit value for humidity sensor to '92.4650363188'. [4/30/2024, 6:20:07 AM] [HttpWebHooks] Change HomeKit value for humidity sensor to '25.73'. [4/30/2024, 6:20:31 AM] [SwitchBot] Blind Tilt: Blind 1 Checking Status ... [4/30/2024, 6:20:33 AM] [SwitchBot] Blind Tilt: Blind 2 Internal Server Error, An unexpected error on the SmartThings servers has occurred. These errors should be rare, statusCode: 500 [4/30/2024, 6:20:33 AM] [SwitchBot] Blind Tilt: Blind 2 Unknown statusCode: undefined, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug [4/30/2024, 6:20:34 AM] [HttpWebHooks] Change HomeKit value for temperature sensor to '25.5625'. [4/30/2024, 6:20:34 AM] [SwitchBot] Blind Tilt: Blind 2 Checking Status ... [4/30/2024, 6:20:36 AM] [SwitchBot] Blind Tilt: Blind 4 Checking Status ... [4/30/2024, 6:20:48 AM] [SwitchBot] Blind Tilt: Blind 2 Internal Server Error, An unexpected error on the SmartThings servers has occurred. These errors should be rare, statusCode: 500 [4/30/2024, 6:20:48 AM] [SwitchBot] Blind Tilt: Blind 2 Unknown statusCode: undefined, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug [4/30/2024, 6:20:54 AM] [SwitchBot] Blind Tilt: Blind 1 Internal Server Error, An unexpected error on the SmartThings servers has occurred. These errors should be rare, statusCode: 500 [4/30/2024, 6:20:54 AM] [SwitchBot] Blind Tilt: Blind 1 Unknown statusCode: undefined, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug [4/30/2024, 6:20:54 AM] [SwitchBot] Blind Tilt: Blind 1 Checking Status ... [4/30/2024, 6:20:56 AM] [SwitchBot] Blind Tilt: Blind 2 Internal Server Error, An unexpected error on the SmartThings servers has occurred. These errors should be rare, statusCode: 500 [4/30/2024, 6:20:56 AM] [SwitchBot] Blind Tilt: Blind 2 Unknown statusCode: undefined, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug [4/30/2024, 6:21:01 AM] [HttpWebHooks] Change HomeKit value for temperature sensor to '20.018'. [4/30/2024, 6:21:01 AM] [HttpWebHooks] Change HomeKit value for humidity sensor to '49.807790798316574'.
I just updated to 3.4.0 from 2.12.1 and had this error. I rolled back to 2.12.1 and things are fine again.
I am thinking about rolling back as well. Maybe older version of this plugin is using an older version of Switchbot API?
The alternate option I suppose is to look at the new Switchbot Hub that supports Matter
The alternate option I suppose is to look at the new Switchbot Hub that supports Matter
I bought the new Hub when it was released specifically for this purpose, but it's unfortunately useless for me because the Switchbot Bots / Button Pushers will only show up in HomeKit (through Matter) as a Light Switch. So it defeats the whole purpose of the Bot and the different types of Press States etc. Switchbot says it's a Matter limitation right now.
I just updated to 3.4.0 from 2.12.1 and had this error. I rolled back to 2.12.1 and things are fine again.
I am thinking about rolling back as well. Maybe older version of this plugin is using an older version of Switchbot API?
I just rolled back from 3.4.0 to 2.12.1 and I now have access to my tilt blinds again. I thought it might be a hangup from switching from a docker(container) instance of homebridge to native on DS7, but it seems that's coincidental timing
I tried 2.12.1 and see the same lack of errors and better reliability.... of what its worth
Thank you very much y'all, 2.12.1 also saved my bacon.
Reverting to v3.1.3 also worked for me. After reverting the errors disappeared and IR worked again.
For what it's worth, I reverted to 2.12.1
and I'm still seeing the 500 error with my SwitchBot curtains. Only getting it when attempting to change state (i.e. open/close). I get 200s back when polling their status. Seems to just be my curtains though- I have a SwitchBot which has been working fine despite the curtain issue.
[5/2/2024, 4:39:36 AM] [SwitchBot] [DEBUG] Curtain: Curtains deviceStatus: {"message":"Internal server error"}
[5/2/2024, 4:39:36 AM] [SwitchBot] [DEBUG] Curtain: Curtains deviceStatus body: undefined
[5/2/2024, 4:39:36 AM] [SwitchBot] [DEBUG] Curtain: Curtains deviceStatus statusCode: undefined
[5/2/2024, 4:39:36 AM] [SwitchBot] Curtain: Curtains Unknown statusCode: 500, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug
[5/2/2024, 4:39:36 AM] [SwitchBot] Curtain: Curtains Unknown statusCode: undefined, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug
Edit: Also reset my developer token from the app and no dice.
I also reverted to 2.12.1 and I'm still seeing the 500 error with my Smart Lock Series 1.
This is an issue directly with Switchbot API v1.1. I've tested it myself on Postman and I saw the same 500 status code.
I did the same test on Switchbot API v1.0 and that seemed to be working. Haven't received any 500 status code but I did not test it that much since I have Curtain 3 and it only works with Switchbot API v1.1 What I saw was if you try to do the request again after a while it succeeds. So I implemented a retry mechanism myself and it worked. Received status code 100 after several tries.
Nice @sametguzeldev, would you be willing to submit a PR?
I am not a typescript expert at all 😄 I only changed it for Curtain device and modified openAPIRefreshStatus method just to test the theory. I think it would be better if we can wrap the request function completely and handle this retry mechanism directly inside the request and put maximumRetry and delayBetweenRetries inside config settings or something. Here is the code that I modified. But this is a bad practice to apply one by one to all devices and all openApi methods.
async openAPIRefreshStatus(): Promise<void> {
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIRefreshStatus`);
let retryCount = 0;
const maxRetries = 5; // Maximum number of retries
const delayBetweenRetries = 5000; // Delay between retries in milliseconds
while (retryCount < maxRetries) {
try {
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/status`, {
headers: this.platform.generateHeaders(),
});
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
const deviceStatus: any = await body.json();
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
+ `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
this.OpenAPI_CurrentPosition = deviceStatus.body.slidePosition;
this.OpenAPI_InMotion = deviceStatus.body.moving;
this.OpenAPI_CurrentAmbientLightLevel = deviceStatus.body.brightness;
this.OpenAPI_BatteryLevel = deviceStatus.body.battery;
this.OpenAPI_FirmwareRevision = deviceStatus.body.version;
this.openAPIparseStatus();
this.updateHomeKitCharacteristics();
break;
} else {
this.statusCode(statusCode);
this.statusCode(deviceStatus.statusCode);
if (statusCode === 500) {
retryCount++;
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName}statusCode: ${statusCode} Attempt ${retryCount} of ${maxRetries}`);
await sleep(delayBetweenRetries);
}
}
} catch (e: any) {
retryCount++;
this.apiError(e);
this.errorLog(
`${this.device.deviceType}: ${this.accessory.displayName} failed openAPIRefreshStatus with ${this.device.connectionType}` +
` Connection, Error Message: ${JSON.stringify(e.message)}`,
);
}
}
}
Thanks, I will see what I can do
@donavanbecker Since I saw every device has access to platform, I wrote this function to platform.ts file. (logs can be removed) For some reason when I build the library locally, the plugin's config does not open for me visually so I put maxRetries and delayBetweenRetries inside this function. I am also making it retry even if an error happens, maybe we could just break the loop there as well.
async retryRequest(url: string | URL | UrlObject,
options?: { dispatcher?: Dispatcher } & Omit<Dispatcher.RequestOptions,
'origin' | 'path' | 'method'> & Partial<Pick<Dispatcher.RequestOptions, 'method'>>): Promise<{ body: any; statusCode: number }> {
let retryCount = 0;
const maxRetries = 5; // Maximum number of retries
const delayBetweenRetries = 3000; // Delay between retries in milliseconds
while (retryCount < maxRetries) {
try {
const { body, statusCode } = await request(url, options);
if (statusCode === 200 || statusCode === 100) {
return { body, statusCode };
} else {
this.debugLog(`Received status code: ${statusCode}`);
}
} catch (error: any) {
this.errorLog(`Error making request: ${error.message}`);
}
retryCount++;
this.debugLog(`Retry attempt ${retryCount} of ${maxRetries}`);
await sleep(delayBetweenRetries);
}
return { body: null, statusCode: -1 };
}
then I made all devices to call this method. For example for openAPIRefreshStatus, it became from
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/status`, {
headers: this.platform.generateHeaders(),
});
to
const { body, statusCode } = await this.platform.retryRequest(`${Devices}/${this.device.deviceId}/status`, {
headers: this.platform.generateHeaders(),
});
I'll be running it like this on my environment for now. Maybe this could give you some kind of idea to how to implement it better.
Thanks @sametguzeldev, I have added this to the latest beta. maxRetries and delayBetweenRetries are both customizable in the config.
I've been getting these unknown statuscode errors constantly across all my devices (meters, curtains, etc.) on v3.4.0. (had opened a separate issue a while ago). The latest beta V3.5.0-beta22 seems to have fixed it.
Thanks!
Been following this for a while. Thanks for the input and progress so far! The 500 errors are now gone. However, after updating to the newest beta’s .22 and .23 my curtains are unresponsive.
Fresh install from 3.4.0 will detect the hub mini and curtains after inputting token with intermittent issues and 500 errors
Updating from 3.4.0 to the beta’s results in the curtains being unresponsive.
Fresh beta install .22 and .23 will not detect the hub mini and curtains
Same for me with the Smart Lock. The 500 errors are solved, but newest betas .22 and .23 cause the Lock to become entirely unresponsive. Similar troubleshooting re: version installations yields the same result. Fresh install from 3.4.0 will detect the hub mini and curtains after inputting token with intermittent issues and 500 errorsUpdating from 3.4.0 to the beta’s results in the curtains being unresponsive.Fresh beta install .22 and .23 will not detect the hub mini and curtainsOn May 7, 2024, at 3:27 AM, Ave87 @.***> wrote: Been following this for a while. Thanks for the input and progress so far! The 500 errors are now gone. However, after updating to the newest beta’s .22 and .23 my curtains are unresponsive. Fresh install from 3.4.0 will detect the hub mini and curtains after inputting token with intermittent issues and 500 errors Updating from 3.4.0 to the beta’s results in the curtains being unresponsive. Fresh beta install .22 and .23 will not detect the hub mini and curtains
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>
I am not using the latest beta. I am still using my own solution and I can confirm my Smart Lock and my Curtain 3 are still working. If you want @donavanbecker I can install the beta version and see how it interacts with my devices? I can enable debug and check it out.
500 errors gone, but curtains unresponsive on the latest betas as ave87 posted.
I am not using the latest beta. I am still using my own solution and I can confirm my Smart Lock and my Curtain 3 are still working. If you want @donavanbecker I can install the beta version and see how it interacts with my devices? I can enable debug and check it out.
Yes please
500 errors gone, but curtains unresponsive on the latest betas as ave87 posted.
Do you have logs?
Yes. Logs attached. I've enabled debug logging. Logs don't seem to show much. Not only are my curtains unresponsive, but even my meters don't seem to be updating.
@switchbot_homebridge-switchbot.log (1).txt
Yes. Logs attached. I've enabled debug logging. Logs don't seem to show much. Not only are my curtains unresponsive, but even my meters don't seem to be updating. @switchbot_homebridge-switchbot.log (1).txt
I think you need to run it for a while for it to trigger openAPIRefreshStatus and also try execute some stuff on the curtain. If this log is sent after you've tried to execute some stuff on the curtain device, than the request is not going through at all
From my testing, sometimes even 5 tries are not enough. (Max tries = 5, delay = 3 seconds)
This is from my own solution. I'll try the beta now.
@donavanbecker I can confirm nothing is responding. I don't see any request log to anything in debug mode when using the latest beta.
maxRetries are configurable per device, so you can set a different max on each one.
I don't even see the discovery running at all. When I rolled back to 3.4.0 version, I saw these logs. But on beta version, never saw these logs at all.
[5/7/2024, 8:33:09 PM] [SwitchBot] Discovered Contact Sensor: xxx
[5/7/2024, 8:33:09 PM] [SwitchBot] Discovered Bot: xxx
[5/7/2024, 8:33:09 PM] [SwitchBot] Device: Main Keypad with Device Type: Keypad Touch, is currently not supported.
[5/7/2024, 8:33:09 PM] [SwitchBot] Submit Feature Requests Here: https://tinyurl.com/SwitchBotFeatureRequest
[5/7/2024, 8:33:09 PM] [SwitchBot] Discovered Smart Lock: xxx
[5/7/2024, 8:33:09 PM] [SwitchBot] Discovered Hub Mini: xxx
[5/7/2024, 8:33:09 PM] [SwitchBot] Discovered Meter: xxx
[5/7/2024, 8:33:09 PM] [SwitchBot] Discovered Curtain3 Bedroom Curtain: xxx
[5/7/2024, 8:33:09 PM] [SwitchBot] Discovered Meter: xxx
[5/7/2024, 8:33:09 PM] [SwitchBot] Discovered Bot: xxx
[5/7/2024, 8:33:09 PM] [SwitchBot] Discovered Hub Mini: xxx
[5/7/2024, 8:33:09 PM] [SwitchBot] Discovered Hub Mini: xxx
[5/7/2024, 8:33:09 PM] [SwitchBot] Discovered Motion Sensor: xxx
[5/7/2024, 8:33:09 PM] [SwitchBot] Discovered Contact Sensor: xxx
[5/7/2024, 8:33:09 PM] [SwitchBot] Total SwitchBot Devices Found: 13
Yes. Logs attached. I've enabled debug logging. Logs don't seem to show much. Not only are my curtains unresponsive, but even my meters don't seem to be updating. @switchbot_homebridge-switchbot.log (1).txt
I think you need to run it for a while for it to trigger openAPIRefreshStatus and also try execute some stuff on the curtain. If this log is sent after you've tried to execute some stuff on the curtain device, than the request is not going through at all
Looks like nothing is getting through at all. No matter how many times I try to manipulate the curtains
So I just increased "Max Retries for OpenAPI" in advanced settings from 5 to 15, restarted the bridge and I'm back in action!
log excerpt: [07/05/2024, 14:52:59] [SwitchBot] Launched child bridge with PID 497782 [07/05/2024, 14:53:02] Registering platform '@switchbot/homebridge-switchbot.SwitchBot' [07/05/2024, 14:53:02] [SwitchBot] Loaded @switchbot/homebridge-switchbot v3.5.0-beta.23 child bridge successfully [07/05/2024, 14:53:02] Loaded 9 cached accessories from cachedAccessories.0E524B5C18A9. [07/05/2024, 14:53:02] [SwitchBot] [DEBUG] Platform Config: {"logging":"debug"} [07/05/2024, 14:53:02] [SwitchBot] [DEBUG] Using Config Logging: debug [07/05/2024, 14:53:02] [SwitchBot] [DEBUG] Plugin Version: 3.5.0-beta.23 [07/05/2024, 14:53:02] [SwitchBot] [DEBUG] Finished initializing platform: SwitchBot [07/05/2024, 14:53:02] [SwitchBot] [DEBUG] Verifying Config [07/05/2024, 14:53:02] [SwitchBot] [DEBUG] Platform Config: {"logging":"debug"} [07/05/2024, 14:53:02] [SwitchBot] [DEBUG] Using Default Refresh Rate (2 minutes). [07/05/2024, 14:53:02] [SwitchBot] [DEBUG] Using Default Push Rate. [07/05/2024, 14:53:02] [SwitchBot] [DEBUG] Using Default Delay Between Retries. [07/05/2024, 14:53:02] [SwitchBot] [DEBUG] Config OK [07/05/2024, 14:53:02] [SwitchBot] [DEBUG] Loading accessory from cache: Outdoor Meter SwB [07/05/2024, 14:53:02] [SwitchBot] [DEBUG] Loading accessory from cache: Dining Room SwB [07/05/2024, 14:53:02] [SwitchBot] [DEBUG] Loading accessory from cache: Bedroom SwBP [07/05/2024, 14:53:02] [SwitchBot] [DEBUG] Loading accessory from cache: Motion Sensor 2E [07/05/2024, 14:53:02] [SwitchBot] [DEBUG] Loading accessory from cache: Small Bathroom SwB [07/05/2024, 14:53:02] [SwitchBot] [DEBUG] Loading accessory from cache: Main Bathroom SwB [07/05/2024, 14:53:02] [SwitchBot] [DEBUG] Loading accessory from cache: Living Room SwBP [07/05/2024, 14:53:02] [SwitchBot] [DEBUG] Loading accessory from cache: Office SwBP [07/05/2024, 14:53:02] [SwitchBot] [DEBUG] Loading accessory from cache: Living Room Curtain [07/05/2024, 14:53:02] [SwitchBot] [DEBUG] Executed didFinishLaunching callback [07/05/2024, 14:53:02] Homebridge v1.8.1 (HAP v0.12.0) (SwitchBot) is running on port 55335. [07/05/2024, 14:53:03] [SwitchBot] [DEBUG] statusCode: 200 [07/05/2024, 14:53:03] [SwitchBot] [DEBUG] devicesAPI: {"statusCode":100,"body":{"deviceList":[{"deviceId":"C3C2 2D5491D3","deviceName":"Living Room Hub 2","deviceType":"Hub 2","enableCloudService":true,"hubDeviceId":"000000000000"},{"deviceId": "C93E0238D1B2","deviceName":"Curtain B2","deviceType":"Curtain","hubDeviceId":"000000000000","curtainDevicesIds":["FD1E6D06B532","C9 3E0238D1B2"],"calibrate":false,"group":true,"master":false,"openDirection":"right"},{"deviceId":"CFD41B916DA3","deviceName":"Outdoor Meter SwB","deviceType":"WoIOSensor","enableCloudService":true,"hubDeviceId":"C3C22D5491D3"},{"deviceId":"E0C8750159BB","deviceName ":"Dining Room SwB","deviceType":"Meter","enableCloudService":true,"hubDeviceId":"C3C22D5491D3"},{"deviceId":"E3D163DE2E31","deviceN ame":"Bedroom SwBP","deviceType":"MeterPlus","enableCloudService":true,"hubDeviceId":"C3C22D5491D3"},{"deviceId":"EBA08112E12E","dev iceName":"Motion Sensor 2E","deviceType":"Motion Sensor","enableCloudService":true,"hubDeviceId":"C3C22D5491D3"},{"deviceId":"F1BAF4 B4E58E","deviceName":"Small Bathroom SwB","deviceType":"Meter","enableCloudService":true,"hubDeviceId":"C3C22D5491D3"},{"deviceId":"
Setting the retries to 15 resulted in my curtains being discovered again. They are now responsive and mostly functional again.
This morning the curtains remained closed when they should be open. In the log there was another 500 error again. So previously mentioned fixes did not completely solve the issues
Confirmed from my side too, the beta is not working at all. I'm now using native SwitchBot automations and app until this gets solved.
I had the same issue, using an Smart Lock and Hub 2:
Node.js Version: v20.12.1 Homebridge Version: v1.8.1 Homebridge Switchbot Plugin Version: v3.4.0 Smart Lock Firmware Version: V6.6
BUT it got fixed yesterday night after an update of the Smart Lock firmware to version V6.8.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been closed as no further activity has occurred.
Describe the Bug
When attempting to interact with WoIOSensor (Kitchen Sensor) and Smart Lock (LightBolt) devices using the homebridge-switchbot plugin, I receive an "Internal Server Error" with a status code of 500. Additionally, an "Unknown statusCode: undefined" error is logged. This suggests an unexpected error on the SmartThings servers.
To Reproduce
Expected Behavior
The plugin should successfully interact with the WoIOSensor and Smart Lock devices without encountering server errors.
Relevant Log Output
Config for homebridge-switchbot
Screenshots
No response
Device and Model
Outdoor Thermohygrometer, SmartLock
Node.js Version
v20.12.1
NPM Version
v10.5.0
Homebridge Version
v1.7.0
Homebridge Switchbot Plugin Version
v3.4.0
Homebridge Config UI X Plugin Version
v4.56.1
Operating System
macOS