OpenWonderLabs / homebridge-switchbot

The Homebridge SwitchBot plugin allows you to access your SwitchBot Device(s) from HomeKit. Homebridge.
https://openwonderlabs.github.io/homebridge-switchbot/
ISC License
242 stars 53 forks source link

Bug: Failed to Discover Devices after adding/updating the devices #789

Closed pinhao1994 closed 1 year ago

pinhao1994 commented 1 year ago

Describe the Bug

The devices are not able to be found after adding/updating the children's devices.

I updated the existing device "switchbot bot" with different "device refresh rate".

I added a new device "switchbot bot" for the another new-buy bot.

After restarting the hb, the hb cannot find any devices nor hk showing any switchbot devices.

I have check the issue list, it seems that the below issue are similar

Please help solve the bug, thank you =)

To Reproduce

Not sure

Expected Behavior

The homebridge-switchbot plugin should be able to get all the devices.

Relevant Log Output

[02/08/2023, 12:17:11] [SwitchBot] Bot: Bot Light Unknown statusCode: 500, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug

[02/08/2023, 12:17:11] [SwitchBot] Bot: Bot Light failed openAPIRefreshStatus with OpenAPI Connection, Error Message: "Cannot read properties of undefined (reading 'power')"

[03/08/2023, 03:19:53] [SwitchBot] Bot: Bot Light failed openAPIRefreshStatus with OpenAPI Connection, Error Message: "Connect Timeout Error"

[03/08/2023, 03:20:03] [SwitchBot] Bot: Bot Light failed openAPIRefreshStatus with OpenAPI Connection, Error Message: "Connect Timeout Error"

[03/08/2023, 03:20:13] [SwitchBot] Bot: Bot Light failed openAPIRefreshStatus with OpenAPI Connection, Error Message: "Connect Timeout Error"

[03/08/2023, 03:20:23] [SwitchBot] Bot: Bot Light failed openAPIRefreshStatus with OpenAPI Connection, Error Message: "Connect Timeout Error"

[03/08/2023, 03:20:26] [SwitchBot] Bot: Bot Light failed openAPIRefreshStatus with OpenAPI Connection, Error Message: "getaddrinfo ENOTFOUND api.switch-bot.com"

[03/08/2023, 03:20:33] [SwitchBot] Bot: Bot Light failed openAPIRefreshStatus with OpenAPI Connection, Error Message: "getaddrinfo ENOTFOUND api.switch-bot.com"

[03/08/2023, 03:20:43] [SwitchBot] Bot: Bot Light failed openAPIRefreshStatus with OpenAPI Connection, Error Message: "getaddrinfo ENOTFOUND api.switch-bot.com"

[03/08/2023, 03:20:53] [SwitchBot] Bot: Bot Light failed openAPIRefreshStatus with OpenAPI Connection, Error Message: "getaddrinfo ENOTFOUND api.switch-bot.com"

[03/08/2023, 03:21:03] [SwitchBot] Bot: Bot Light failed openAPIRefreshStatus with OpenAPI Connection, Error Message: "getaddrinfo ENOTFOUND api.switch-bot.com"

[03/08/2023, 03:21:13] [SwitchBot] Bot: Bot Light failed openAPIRefreshStatus with OpenAPI Connection, Error Message: "getaddrinfo ENOTFOUND api.switch-bot.com"

[03/08/2023, 03:21:23] [SwitchBot] Bot: Bot Light failed openAPIRefreshStatus with OpenAPI Connection, Error Message: "getaddrinfo ENOTFOUND api.switch-bot.com"

[03/08/2023, 03:21:33] [SwitchBot] Bot: Bot Light failed openAPIRefreshStatus with OpenAPI Connection, Error Message: "getaddrinfo ENOTFOUND api.switch-bot.com"

[03/08/2023, 03:21:43] [SwitchBot] Bot: Bot Light failed openAPIRefreshStatus with OpenAPI Connection, Error Message: "getaddrinfo ENOTFOUND api.switch-bot.com"

[03/08/2023, 03:21:53] [SwitchBot] Bot: Bot Light failed openAPIRefreshStatus with OpenAPI Connection, Error Message: "getaddrinfo ENOTFOUND api.switch-bot.com"

[03/08/2023, 03:22:03] [SwitchBot] Bot: Bot Light failed openAPIRefreshStatus with OpenAPI Connection, Error Message: "getaddrinfo ENOTFOUND api.switch-bot.com"

[03/08/2023, 03:22:13] [SwitchBot] Child bridge process ended

[03/08/2023, 03:22:13] [SwitchBot] Process Ended. Code: 1, Signal: null

[03/08/2023, 03:22:30] [SwitchBot] Initializing SwitchBot platform...

[03/08/2023, 03:22:30] [SwitchBot] Initializing child bridge 0E:84:DC:C8:E2:AF

[03/08/2023, 03:22:31] [SwitchBot] Launched child bridge with PID 4131

[03/08/2023, 03:22:35] [SwitchBot] Loaded @switchbot/homebridge-switchbot v2.6.2 child bridge successfully

[03/08/2023, 03:22:35] [SwitchBot] Platform Config: {"logging":"standard","refreshRate":30}

[04/08/2023, 01:15:57] [SwitchBot] Initializing SwitchBot platform...

[04/08/2023, 01:15:57] [SwitchBot] Initializing child bridge 0E:84:DC:C8:E2:AF

[04/08/2023, 01:15:59] [SwitchBot] Launched child bridge with PID 6361

[04/08/2023, 01:16:02] [SwitchBot] Loaded @switchbot/homebridge-switchbot v2.7.1 child bridge successfully

[04/08/2023, 01:16:02] [SwitchBot] Platform Config: {"logging":"standard","refreshRate":30}

[04/08/2023, 01:16:07] [SwitchBot] Total SwitchBot Devices Found: 2

[04/08/2023, 01:16:07] [SwitchBot] Restoring existing accessory from cache: Air Conditioner DeviceID: 02-202307122218-42893239

[04/08/2023, 01:16:07] [SwitchBot] Air Conditioner: Air Conditioner Config: {"connectionType":"OpenAPI"}

[04/08/2023, 01:16:07] [SwitchBot] Total IR Devices Found: 1

[04/08/2023, 01:16:07] [SwitchBot] Restoring existing accessory from cache: Bot Light DeviceID: C13832304461

[04/08/2023, 01:16:07] [SwitchBot] Bot: Bot Light Config: {"mode":"press","deviceType":"switch","connectionType":"OpenAPI","logging":"standard","refreshRate":10,"offline":false}

[04/08/2023, 01:16:07] [SwitchBot] Bot: Bot Light Displaying as Switch

[04/08/2023, 01:16:14] [SwitchBot] Bot: Bot Light Set On: true

[04/08/2023, 01:16:29] [SwitchBot] Bot: Bot Light Set On: true

[04/08/2023, 01:29:04] [SwitchBot] Bot: Bot Light Set On: true

[04/08/2023, 10:41:50] [SwitchBot] Bot: Bot Light Set On: true

[04/08/2023, 22:18:28] [SwitchBot] Bot: Bot Light Set On: true

[04/08/2023, 22:50:57] [SwitchBot] Bot: Bot Light Set On: true

[06/08/2023, 00:07:39] [SwitchBot] Bot: Bot Light Set On: true

[06/08/2023, 00:17:50] [SwitchBot] Bot: Bot Light Set On: true

[06/08/2023, 10:42:14] [SwitchBot] Bot: Bot Light failed openAPIRefreshStatus with OpenAPI Connection, Error Message: "Cannot read properties of undefined (reading 'power')"

[06/08/2023, 19:25:51] [SwitchBot] Bot: Bot Light failed openAPIRefreshStatus with OpenAPI Connection, Error Message: "Cannot read properties of undefined (reading 'power')"

[07/08/2023, 01:29:29] [SwitchBot] Bot: Bot Light Set On: true

[08/08/2023, 22:25:06] [SwitchBot] Bot: Bot Light Set On: true

[09/08/2023, 21:00:04] [SwitchBot] Bot: Bot Light Unknown statusCode: 500, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug

[09/08/2023, 21:00:04] [SwitchBot] Bot: Bot Light failed openAPIRefreshStatus with OpenAPI Connection, Error Message: "Cannot read properties of undefined (reading 'power')"

[11/08/2023, 01:32:33] [SwitchBot] Bot: Bot Light Set On: true

[11/08/2023, 09:55:28] [SwitchBot] Initializing SwitchBot platform...

[11/08/2023, 09:55:28] [SwitchBot] Initializing child bridge 0E:84:DC:C8:E2:AF

[11/08/2023, 09:55:30] [SwitchBot] Launched child bridge with PID 19374

[11/08/2023, 09:55:33] [SwitchBot] Loaded @switchbot/homebridge-switchbot v2.7.1 child bridge successfully

[11/08/2023, 09:55:33] [SwitchBot] Platform Config: {"logging":"standard","refreshRate":30}

[11/08/2023, 09:55:35] [SwitchBot] Total SwitchBot Devices Found: 3

[11/08/2023, 09:55:35] [SwitchBot] Restoring existing accessory from cache: Air Conditioner DeviceID: 02-202307122218-42893239

[11/08/2023, 09:55:35] [SwitchBot] Air Conditioner: Air Conditioner Config: {"connectionType":"OpenAPI"}

[11/08/2023, 09:55:35] [SwitchBot] Total IR Devices Found: 1

[11/08/2023, 09:55:35] [SwitchBot] Restoring existing accessory from cache: Bot Light DeviceID: C13832304461

[11/08/2023, 09:55:35] [SwitchBot] Adding new accessory: Bot Door Bot DeviceID: CFF4619C509D

[11/08/2023, 09:55:35] [SwitchBot] Bot: Bot Light Config: {"mode":"press","deviceType":"switch","connectionType":"OpenAPI","logging":"standard","refreshRate":10,"offline":false}

[11/08/2023, 09:55:35] [SwitchBot] Bot: Bot Light Displaying as Switch

[11/08/2023, 09:55:35] [SwitchBot] Bot: Bot Door Config: {"mode":"switch","deviceType":"switch","connectionType":"OpenAPI","refreshRate":10}

[11/08/2023, 09:55:35] [SwitchBot] Bot: Bot Door Displaying as Switch

[11/08/2023, 09:56:38] [SwitchBot] Bot: Bot Door Set On: true

[11/08/2023, 09:56:54] [SwitchBot] Bot: Bot Door Set On: false

[11/08/2023, 09:56:58] [SwitchBot] Bot: Bot Door Set On: true

[11/08/2023, 09:57:09] [SwitchBot] Bot: Bot Door Set On: false

[11/08/2023, 09:57:22] [SwitchBot] Bot: Bot Door Set On: true

[11/08/2023, 09:57:38] [SwitchBot] Bot: Bot Door Set On: false

[11/08/2023, 09:59:18] [SwitchBot] Bot: Bot Door Set On: true

[11/08/2023, 09:59:24] [SwitchBot] Bot: Bot Door Set On: false

[11/08/2023, 10:02:06] [SwitchBot] Bot: Bot Door Set On: true

[11/08/2023, 10:02:22] [SwitchBot] Bot: Bot Door Set On: false

[11/08/2023, 14:57:50] [SwitchBot] Bot: Bot Door Set On: true

[11/08/2023, 14:59:55] [SwitchBot] Bot: Bot Door Set On: false

[11/08/2023, 23:03:34] [SwitchBot] Bot: Bot Door Set On: true

[11/08/2023, 23:03:47] [SwitchBot] Bot: Bot Door Set On: false

[11/08/2023, 23:05:09] [SwitchBot] Initializing SwitchBot platform...

[11/08/2023, 23:05:09] [SwitchBot] Initializing child bridge 0E:84:DC:C8:E2:AF

[11/08/2023, 23:05:11] [SwitchBot] Launched child bridge with PID 20503

[11/08/2023, 23:05:14] [SwitchBot] Loaded @switchbot/homebridge-switchbot v2.7.1 child bridge successfully

[11/08/2023, 23:05:15] [SwitchBot] Platform Config: {"logging":"standard","refreshRate":30}

[11/08/2023, 23:10:29] [SwitchBot] Initializing SwitchBot platform...

[11/08/2023, 23:10:29] [SwitchBot] Initializing child bridge 0E:84:DC:C8:E2:AF

[11/08/2023, 23:10:31] [SwitchBot] Launched child bridge with PID 20599

[11/08/2023, 23:10:35] [SwitchBot] Loaded @switchbot/homebridge-switchbot v2.7.1 child bridge successfully

[11/08/2023, 23:10:35] [SwitchBot] Platform Config: {"logging":"standard","refreshRate":30}

[11/08/2023, 23:13:53] [SwitchBot] Restarting child bridge...

[11/08/2023, 23:13:58] [SwitchBot] Child bridge process ended

[11/08/2023, 23:13:58] [SwitchBot] Process Ended. Code: 143, Signal: null

[11/08/2023, 23:14:05] [SwitchBot] Restarting Process...

[11/08/2023, 23:14:06] [SwitchBot] Launched child bridge with PID 20667

[11/08/2023, 23:14:09] [SwitchBot] Loaded @switchbot/homebridge-switchbot v2.7.1 child bridge successfully

[11/08/2023, 23:14:09] [SwitchBot] Platform Config: {"logging":"standard","refreshRate":30}

[11/08/2023, 23:15:53] [SwitchBot] Initializing SwitchBot platform...

[11/08/2023, 23:15:53] [SwitchBot] Initializing child bridge 0E:84:DC:C8:E2:AF

[11/08/2023, 23:15:54] [SwitchBot] Launched child bridge with PID 20841

[11/08/2023, 23:15:58] [SwitchBot] Loaded @switchbot/homebridge-switchbot v2.7.1 child bridge successfully

[11/08/2023, 23:15:58] [SwitchBot] Platform Config: {"logging":"standard","refreshRate":30}

[11/08/2023, 23:16:18] [SwitchBot] Initializing SwitchBot platform...

[11/08/2023, 23:16:18] [SwitchBot] Initializing child bridge 0E:84:DC:C8:E2:AF

[11/08/2023, 23:16:19] [SwitchBot] Launched child bridge with PID 20908

[11/08/2023, 23:16:23] [SwitchBot] Loaded @switchbot/homebridge-switchbot v2.7.1 child bridge successfully

[11/08/2023, 23:16:23] [SwitchBot] Platform Config: {"logging":"standard","refreshRate":30}

[11/08/2023, 23:17:30] [SwitchBot] Initializing SwitchBot platform...

[11/08/2023, 23:17:30] [SwitchBot] Initializing child bridge 0E:84:DC:C8:E2:AF

[11/08/2023, 23:17:31] [SwitchBot] Launched child bridge with PID 21004

[11/08/2023, 23:17:35] [SwitchBot] Loaded @switchbot/homebridge-switchbot v2.7.1 child bridge successfully

[11/08/2023, 23:17:35] [SwitchBot] Platform Config: {"logging":"standard","refreshRate":30}

[11/08/2023, 23:19:34] [SwitchBot] Initializing SwitchBot platform...

[11/08/2023, 23:19:34] [SwitchBot] Initializing child bridge 0E:84:DC:C8:E2:AF

[11/08/2023, 23:19:35] [SwitchBot] Launched child bridge with PID 21477

[11/08/2023, 23:19:39] [SwitchBot] Loaded @switchbot/homebridge-switchbot v2.7.1 child bridge successfully

[11/08/2023, 23:19:39] [SwitchBot] Platform Config: {"logging":"standard","refreshRate":30}

[11/08/2023, 23:27:21] [SwitchBot] Initializing SwitchBot platform...

[11/08/2023, 23:28:50] [SwitchBot] Initializing SwitchBot platform...

[11/08/2023, 23:28:50] [SwitchBot] Initializing child bridge 0E:D2:C4:22:57:08

[11/08/2023, 23:28:52] [SwitchBot] Launched child bridge with PID 21790

[11/08/2023, 23:28:55] [SwitchBot] Loaded @switchbot/homebridge-switchbot v2.7.1 child bridge successfully

[11/08/2023, 23:31:56] [SwitchBot] Initializing SwitchBot platform...

[11/08/2023, 23:31:56] [SwitchBot] Initializing child bridge 0E:D2:C4:22:57:08

[11/08/2023, 23:31:58] [SwitchBot] Launched child bridge with PID 21871

[11/08/2023, 23:32:01] [SwitchBot] Loaded @switchbot/homebridge-switchbot v2.7.1 child bridge successfully

[11/08/2023, 23:39:55] [SwitchBot] Initializing SwitchBot platform...

[11/08/2023, 23:39:55] [SwitchBot] Initializing child bridge 0E:71:DC:1D:3A:41

[11/08/2023, 23:39:57] [SwitchBot] Launched child bridge with PID 22534

[11/08/2023, 23:40:00] [SwitchBot] Loaded @switchbot/homebridge-switchbot v2.7.1 child bridge successfully

[11/08/2023, 23:41:50] [SwitchBot] Restarting child bridge...

[11/08/2023, 23:41:55] [SwitchBot] Child bridge process ended

[11/08/2023, 23:41:55] [SwitchBot] Process Ended. Code: 143, Signal: null

[11/08/2023, 23:42:02] [SwitchBot] Restarting Process...

[11/08/2023, 23:42:03] [SwitchBot] Launched child bridge with PID 22585

[11/08/2023, 23:42:06] [SwitchBot] Loaded @switchbot/homebridge-switchbot v2.7.1 child bridge successfully

[11/08/2023, 23:44:11] [SwitchBot] Initializing SwitchBot platform...

[11/08/2023, 23:44:11] [SwitchBot] Initializing child bridge 0E:71:DC:1D:3A:41

[11/08/2023, 23:44:13] [SwitchBot] Launched child bridge with PID 23104

[11/08/2023, 23:44:16] [SwitchBot] Loaded @switchbot/homebridge-switchbot v2.8.0-beta.12 child bridge successfully

[11/08/2023, 23:28:17] [SwitchBot] Initializing SwitchBot platform...

[11/08/2023, 23:28:17] [SwitchBot] Initializing child bridge 0E:71:DC:1D:3A:41

[11/08/2023, 23:28:18] [SwitchBot] Launched child bridge with PID 818

[11/08/2023, 23:47:10] [SwitchBot] Loaded @switchbot/homebridge-switchbot v2.8.0-beta.12 child bridge successfully

[12/08/2023, 00:06:47] [SwitchBot] Initializing SwitchBot platform...

[12/08/2023, 00:06:47] [SwitchBot] Initializing child bridge 0E:71:DC:1D:3A:41

[12/08/2023, 00:06:49] [SwitchBot] Launched child bridge with PID 918

[12/08/2023, 00:06:53] [SwitchBot] Loaded @switchbot/homebridge-switchbot v2.8.0-beta.12 child bridge successfully

[12/08/2023, 00:18:03] [SwitchBot] Initializing SwitchBot platform...

[12/08/2023, 00:18:03] [SwitchBot] Initializing child bridge 0E:71:DC:1D:3A:41

[12/08/2023, 00:18:05] [SwitchBot] Launched child bridge with PID 1147

[12/08/2023, 00:18:08] [SwitchBot] Loaded @switchbot/homebridge-switchbot v2.8.0-beta.12 child bridge successfully

[12/08/2023, 00:20:49] [SwitchBot] Initializing SwitchBot platform...

[12/08/2023, 00:20:49] [SwitchBot] Initializing child bridge 0E:71:DC:1D:3A:41

[12/08/2023, 00:20:51] [SwitchBot] Launched child bridge with PID 1295

[12/08/2023, 00:20:54] [SwitchBot] Loaded @switchbot/homebridge-switchbot v2.8.0-beta.12 child bridge successfully

[12/08/2023, 00:23:28] [SwitchBot] Initializing SwitchBot platform...

[12/08/2023, 00:23:28] [SwitchBot] Initializing child bridge 0E:71:DC:1D:3A:41

[12/08/2023, 00:23:30] [SwitchBot] Launched child bridge with PID 1470

[12/08/2023, 00:23:33] [SwitchBot] Loaded @switchbot/homebridge-switchbot v2.8.0-beta.12 child bridge successfully

[12/08/2023, 00:24:23] [SwitchBot] Initializing SwitchBot platform...

[12/08/2023, 00:24:23] [SwitchBot] Initializing child bridge 0E:71:DC:1D:3A:41

[12/08/2023, 00:24:25] [SwitchBot] Launched child bridge with PID 1564

[12/08/2023, 00:24:28] [SwitchBot] Loaded @switchbot/homebridge-switchbot v2.8.0-beta.12 child bridge successfully

[12/08/2023, 00:25:55] [SwitchBot] Initializing SwitchBot platform...

[12/08/2023, 00:25:55] [SwitchBot] Initializing child bridge 0E:71:DC:1D:3A:41

[12/08/2023, 00:25:57] [SwitchBot] Launched child bridge with PID 1702

[12/08/2023, 00:26:00] [SwitchBot] Loaded @switchbot/homebridge-switchbot v2.8.0-beta.12 child bridge successfully

[12/08/2023, 00:32:09] [SwitchBot] Initializing SwitchBot platform...

[12/08/2023, 00:32:09] [SwitchBot] Initializing child bridge 0E:71:DC:1D:3A:41

[12/08/2023, 00:32:12] [SwitchBot] Launched child bridge with PID 1817

[12/08/2023, 00:32:15] [SwitchBot] Loaded @switchbot/homebridge-switchbot v2.8.0-beta.12 child bridge successfully

[12/08/2023, 00:50:22] [SwitchBot] Initializing SwitchBot platform...

[12/08/2023, 00:50:22] [SwitchBot] Platform Config: {"logging":"standard","refreshRate":15}

[12/08/2023, 00:53:37] [SwitchBot] Initializing SwitchBot platform...

[12/08/2023, 00:53:37] [SwitchBot] Platform Config: {"logging":"standard","refreshRate":15}

[12/08/2023, 00:55:25] [SwitchBot] Initializing SwitchBot platform...

[12/08/2023, 00:55:25] [SwitchBot] Initializing child bridge 0E:55:D6:94:91:A4

[12/08/2023, 00:55:27] [SwitchBot] Launched child bridge with PID 3691

[12/08/2023, 00:55:30] [SwitchBot] Loaded @switchbot/homebridge-switchbot v2.7.1 child bridge successfully

[12/08/2023, 00:55:30] [SwitchBot] Platform Config: {"logging":"standard","refreshRate":15}

[12/08/2023, 01:00:21] [SwitchBot] Initializing SwitchBot platform...

[12/08/2023, 01:00:21] [SwitchBot] Initializing child bridge 0E:55:D6:94:91:A4

[12/08/2023, 01:00:23] [SwitchBot] Launched child bridge with PID 3825

[12/08/2023, 01:00:27] [SwitchBot] Loaded @switchbot/homebridge-switchbot v2.7.1 child bridge successfully

[12/08/2023, 01:00:27] [SwitchBot] [DEBUG] Using Config Logging: debug

[12/08/2023, 01:00:27] [SwitchBot] [DEBUG] Finished initializing platform:

[12/08/2023, 01:00:27] [SwitchBot] Platform Config: {"logging":"debug","refreshRate":15}

[12/08/2023, 01:00:27] [SwitchBot] [DEBUG] Config OK

[12/08/2023, 01:00:27] [SwitchBot] [DEBUG] Using Default Push Rate.

[12/08/2023, 01:00:28] [SwitchBot] [DEBUG] Executed didFinishLaunching callback

[12/08/2023, 01:00:31] [SwitchBot] [DEBUG] Devices: {}

[12/08/2023, 01:00:31] [SwitchBot] [DEBUG] Request successful, statusCode: 200

[12/08/2023, 01:00:31] [SwitchBot] [DEBUG] Headers: {"date":"Fri, 11 Aug 2023 17:00:31 GMT","content-type":"application/json","content-length":"73","connection":"keep-alive","x-amzn-requestid":"f8c76a1c-190e-48cb-8bf7-d31a6fa2c66a","x-amz-apigw-id":"JgVfbHvMIAMEJBQ=","x-amzn-trace-id":"Root=1-64d6692f-61b99ffe79141ea3564ae157;Sampled=0;lineage=c8c2b0f2:0|bf95bacf:0"}

[12/08/2023, 01:00:31] [SwitchBot] [DEBUG] SwitchBot Device Config Set: [{"deviceId":"CF:F4:61:9C:50:9D","configDeviceName":"Bot Door","configDeviceType":"Bot","connectionType":"OpenAPI","bot":{"mode":"switch","deviceType":"switch"},"firmware":"V6.3","refreshRate":15,"logging":"debug"},{"deviceId":"C1:38:32:30:44:61","configDeviceName":"Bot Light","configDeviceType":"Bot","connectionType":"OpenAPI","bot":{"mode":"press","deviceType":"switch"},"firmware":"V6.5","refreshRate":15,"external":false,"logging":"debug"}]

[12/08/2023, 01:00:31] [SwitchBot] [DEBUG] Failed to Discover Devices, Error Message: "Cannot read property 'map' of undefined", Submit Bugs Here: https://tinyurl.com/SwitchBotBug

[12/08/2023, 01:00:31] [SwitchBot] [DEBUG] Failed to Discover Devices, Error: TypeError: Cannot read property 'map' of undefined

[12/08/2023, 01:05:43] [SwitchBot] Initializing SwitchBot platform...

[12/08/2023, 01:05:43] [SwitchBot] Initializing child bridge 0E:55:D6:94:91:A4

[12/08/2023, 01:05:44] [SwitchBot] Launched child bridge with PID 4018

[12/08/2023, 01:05:48] [SwitchBot] Loaded @switchbot/homebridge-switchbot v2.7.1 child bridge successfully

[12/08/2023, 01:05:48] [SwitchBot] [DEBUG] Finished initializing platform:

[12/08/2023, 01:05:48] [SwitchBot] [DEBUG] Using Config Logging: debug

[12/08/2023, 01:05:48] [SwitchBot] Platform Config: {"logging":"debug","refreshRate":6}

[12/08/2023, 01:05:48] [SwitchBot] [DEBUG] Using Default Push Rate.

[12/08/2023, 01:05:48] [SwitchBot] [DEBUG] Config OK

[12/08/2023, 01:05:49] [SwitchBot] [DEBUG] Executed didFinishLaunching callback

[12/08/2023, 01:05:50] [SwitchBot] [DEBUG] Devices: {}

[12/08/2023, 01:05:50] [SwitchBot] [DEBUG] Request successful, statusCode: 200

[12/08/2023, 01:05:50] [SwitchBot] [DEBUG] Headers: {"date":"Fri, 11 Aug 2023 17:05:50 GMT","content-type":"application/json","content-length":"73","connection":"keep-alive","x-amzn-requestid":"56d969ef-a617-455a-bfc2-af2d4628a82c","x-amz-apigw-id":"JgWRSG56IAMEB7A=","x-amzn-trace-id":"Root=1-64d66a6e-28d5985205ff8f7b0b948d3a;Sampled=0;lineage=c8c2b0f2:0|bf95bacf:0"}

[12/08/2023, 01:05:50] [SwitchBot] [DEBUG] SwitchBot Device Config Set: [{"deviceId":"CF:F4:61:9C:50:9D","configDeviceName":"Bot Door","configDeviceType":"Bot","connectionType":"OpenAPI","bot":{"mode":"switch","deviceType":"switch"},"firmware":"V6.3","refreshRate":6,"logging":"debug"},{"deviceId":"C1:38:32:30:44:61","configDeviceName":"Bot Light","configDeviceType":"Bot","connectionType":"OpenAPI","bot":{"mode":"press","deviceType":"switch"},"firmware":"V6.5","refreshRate":15,"external":false,"logging":"debug"}]

[12/08/2023, 01:05:50] [SwitchBot] [DEBUG] Failed to Discover Devices, Error Message: "Cannot read property 'map' of undefined", Submit Bugs Here: https://tinyurl.com/SwitchBotBug

[12/08/2023, 01:05:50] [SwitchBot] [DEBUG] Failed to Discover Devices, Error: TypeError: Cannot read property 'map' of undefined

[12/08/2023, 01:07:30] [SwitchBot] Initializing SwitchBot platform...

[12/08/2023, 01:07:30] [SwitchBot] Initializing child bridge 0E:55:D6:94:91:A4

[12/08/2023, 01:07:32] [SwitchBot] Launched child bridge with PID 4153

[12/08/2023, 01:07:35] [SwitchBot] Loaded @switchbot/homebridge-switchbot v2.7.1 child bridge successfully

[12/08/2023, 01:07:35] [SwitchBot] [DEBUG] Using Config Logging: debug

[12/08/2023, 01:07:35] [SwitchBot] [DEBUG] Finished initializing platform:

[12/08/2023, 01:07:35] [SwitchBot] Platform Config: {"logging":"debug","refreshRate":6}

[12/08/2023, 01:07:35] [SwitchBot] [DEBUG] Using Default Push Rate.

[12/08/2023, 01:07:35] [SwitchBot] [DEBUG] Config OK

[12/08/2023, 01:07:36] [SwitchBot] [DEBUG] Executed didFinishLaunching callback

[12/08/2023, 01:07:39] [SwitchBot] [DEBUG] Devices: {}

[12/08/2023, 01:07:39] [SwitchBot] [DEBUG] Request successful, statusCode: 200

[12/08/2023, 01:07:39] [SwitchBot] [DEBUG] Headers: {"date":"Fri, 11 Aug 2023 17:07:39 GMT","content-type":"application/json","content-length":"73","connection":"keep-alive","x-amzn-requestid":"5a6586c7-8f35-4fbf-b95d-ca62fe871743","x-amz-apigw-id":"JgWiXGH-IAMEJ8A=","x-amzn-trace-id":"Root=1-64d66adb-1cf5dc35044e47695c5d835c;Sampled=0;lineage=c8c2b0f2:0|bf95bacf:0"}

[12/08/2023, 01:07:39] [SwitchBot] [DEBUG] SwitchBot Device Config Set: [{"deviceId":"CF:F4:61:9C:50:9D","configDeviceName":"Bot Door","configDeviceType":"Bot","connectionType":"OpenAPI","bot":{"mode":"switch","deviceType":"switch"},"firmware":"V6.3","refreshRate":6,"logging":"debug"},{"deviceId":"C1:38:32:30:44:61","configDeviceName":"Bot Light","configDeviceType":"Bot","connectionType":"OpenAPI","bot":{"mode":"press","deviceType":"switch"},"firmware":"V6.5","refreshRate":15,"external":false,"logging":"debug"}]

[12/08/2023, 01:07:39] [SwitchBot] [DEBUG] Failed to Discover Devices, Error Message: "Cannot read property 'map' of undefined", Submit Bugs Here: https://tinyurl.com/SwitchBotBug

[12/08/2023, 01:07:39] [SwitchBot] [DEBUG] Failed to Discover Devices, Error: TypeError: Cannot read property 'map' of undefined

[12/08/2023, 01:10:32] [SwitchBot] Initializing SwitchBot platform...

[12/08/2023, 01:10:32] [SwitchBot] Initializing child bridge 0E:55:D6:94:91:A4

[12/08/2023, 01:10:34] [SwitchBot] Launched child bridge with PID 5406

[12/08/2023, 01:10:37] [SwitchBot] Loaded @switchbot/homebridge-switchbot v2.7.1 child bridge successfully

[12/08/2023, 01:10:37] [SwitchBot] [DEBUG] Using Config Logging: debug

[12/08/2023, 01:10:37] [SwitchBot] [DEBUG] Finished initializing platform:

[12/08/2023, 01:10:37] [SwitchBot] Platform Config: {"logging":"debug","refreshRate":6}

[12/08/2023, 01:10:37] [SwitchBot] [DEBUG] Using Default Push Rate.

[12/08/2023, 01:10:37] [SwitchBot] [DEBUG] Config OK

[12/08/2023, 01:10:38] [SwitchBot] [DEBUG] Executed didFinishLaunching callback

[12/08/2023, 01:10:40] [SwitchBot] [DEBUG] Devices: {}

[12/08/2023, 01:10:40] [SwitchBot] [DEBUG] Request successful, statusCode: 200

[12/08/2023, 01:10:40] [SwitchBot] [DEBUG] Headers: {"date":"Fri, 11 Aug 2023 17:10:40 GMT","content-type":"application/json","content-length":"73","connection":"keep-alive","x-amzn-requestid":"ac52f94e-ee4c-446e-8c9b-78aa99a4ce66","x-amz-apigw-id":"JgW-iHJKIAMETRw=","x-amzn-trace-id":"Root=1-64d66b8f-396ff15e39a11ed262b961e4;Sampled=0;lineage=c8c2b0f2:0|bf95bacf:0"}

[12/08/2023, 01:10:40] [SwitchBot] [DEBUG] SwitchBot Device Config Set: [{"deviceId":"CF:F4:61:9C:50:9D","configDeviceName":"Bot Door","configDeviceType":"Bot","connectionType":"OpenAPI","bot":{"mode":"switch","deviceType":"switch"},"firmware":"V6.3","refreshRate":6,"logging":"debug"},{"deviceId":"C1:38:32:30:44:61","configDeviceName":"Bot Light","configDeviceType":"Bot","connectionType":"OpenAPI","bot":{"mode":"press","deviceType":"switch"},"firmware":"V6.5","refreshRate":15,"external":false,"logging":"debug"}]

[12/08/2023, 01:10:40] [SwitchBot] [DEBUG] Failed to Discover Devices, Error Message: "Cannot read properties of undefined (reading 'map')", Submit Bugs Here: https://tinyurl.com/SwitchBotBug

[12/08/2023, 01:10:40] [SwitchBot] [DEBUG] Failed to Discover Devices, Error: TypeError: Cannot read properties of undefined (reading 'map')

[12/08/2023, 01:13:54] [SwitchBot] Initializing SwitchBot platform...

[12/08/2023, 01:13:54] [SwitchBot] Initializing child bridge 0E:55:D6:94:91:A4

[12/08/2023, 01:13:56] [SwitchBot] Launched child bridge with PID 6654

[12/08/2023, 01:13:59] [SwitchBot] Loaded @switchbot/homebridge-switchbot v2.8.0-beta.12 child bridge successfully

[12/08/2023, 01:13:59] [SwitchBot] [DEBUG] Using Config Logging: debug

[12/08/2023, 01:13:59] [SwitchBot] [DEBUG] Finished initializing platform:

[12/08/2023, 01:13:59] [SwitchBot] [DEBUG] Platform Config: {"logging":"debug","refreshRate":6}

[12/08/2023, 01:13:59] [SwitchBot] [DEBUG] Using Default Push Rate.

[12/08/2023, 01:13:59] [SwitchBot] [DEBUG] Config OK

[12/08/2023, 01:14:00] [SwitchBot] [DEBUG] Executed didFinishLaunching callback

[12/08/2023, 01:14:02] [SwitchBot] [DEBUG] Devices: {}

[12/08/2023, 01:14:02] [SwitchBot] [DEBUG] Request successful, statusCode: 200

[12/08/2023, 01:14:02] [SwitchBot] [DEBUG] Headers: {"date":"Fri, 11 Aug 2023 17:14:02 GMT","content-type":"application/json","content-length":"73","connection":"keep-alive","x-amzn-requestid":"fc342878-cd12-4741-8da2-b83625fb834f","x-amz-apigw-id":"JgXeIF-7oAMFWyQ=","x-amzn-trace-id":"Root=1-64d66c5a-6efaa0f031f9a9b81e746a35;Sampled=0;lineage=c8c2b0f2:0|bf95bacf:0"}

[12/08/2023, 01:14:02] [SwitchBot] [DEBUG] SwitchBot Device Config Set: [{"deviceId":"CF:F4:61:9C:50:9D","configDeviceName":"Bot Door","configDeviceType":"Bot","connectionType":"OpenAPI","bot":{"mode":"switch","deviceType":"switch"},"firmware":"V6.3","refreshRate":6,"logging":"debug"},{"deviceId":"C1:38:32:30:44:61","configDeviceName":"Bot Light","configDeviceType":"Bot","connectionType":"OpenAPI","bot":{"mode":"press","deviceType":"switch"},"firmware":"V6.5","refreshRate":15,"external":false,"logging":"debug"}]

[12/08/2023, 01:14:02] [SwitchBot] [DEBUG] Failed to Discover Devices, Error Message: "Cannot read properties of undefined (reading 'map')", Submit Bugs Here: https://tinyurl.com/SwitchBotBug

[12/08/2023, 01:14:02] [SwitchBot] [DEBUG] Failed to Discover Devices, Error: TypeError: Cannot read properties of undefined (reading 'map')

[12/08/2023, 01:15:12] [SwitchBot] Initializing SwitchBot platform...

[12/08/2023, 01:15:12] [SwitchBot] Initializing child bridge 0E:55:D6:94:91:A4

[12/08/2023, 01:15:14] [SwitchBot] Launched child bridge with PID 6808

[12/08/2023, 01:15:17] [SwitchBot] Loaded @switchbot/homebridge-switchbot v2.8.0-beta.12 child bridge successfully

[12/08/2023, 01:15:17] [SwitchBot] [DEBUG] Using Config Logging: debug

[12/08/2023, 01:15:17] [SwitchBot] [DEBUG] Finished initializing platform:

[12/08/2023, 01:15:17] [SwitchBot] [DEBUG] Platform Config: {"logging":"debug","refreshRate":6}

[12/08/2023, 01:15:17] [SwitchBot] [DEBUG] Using Default Push Rate.

[12/08/2023, 01:15:17] [SwitchBot] [DEBUG] Config OK

[12/08/2023, 01:15:18] [SwitchBot] [DEBUG] Executed didFinishLaunching callback

[12/08/2023, 01:15:21] [SwitchBot] [DEBUG] Devices: {}

[12/08/2023, 01:15:21] [SwitchBot] [DEBUG] Request successful, statusCode: 200

[12/08/2023, 01:15:21] [SwitchBot] [DEBUG] Headers: {"date":"Fri, 11 Aug 2023 17:15:21 GMT","content-type":"application/json","content-length":"73","connection":"keep-alive","x-amzn-requestid":"df281bbc-a423-418b-a3a4-f7ba0e8f93d1","x-amz-apigw-id":"JgXqeE00IAMErWw=","x-amzn-trace-id":"Root=1-64d66ca9-162845ec48b225120501fd7b;Sampled=0;lineage=c8c2b0f2:0|bf95bacf:0"}

[12/08/2023, 01:15:21] [SwitchBot] [DEBUG] SwitchBot Device Config Set: [{"deviceId":"CF:F4:61:9C:50:9D","configDeviceName":"Bot Door","configDeviceType":"Bot","connectionType":"BLE/OpenAPI","bot":{"mode":"switch","deviceType":"switch"},"firmware":"V6.3","refreshRate":6,"logging":"debug"},{"deviceId":"C1:38:32:30:44:61","configDeviceName":"Bot Light","configDeviceType":"Bot","connectionType":"OpenAPI","bot":{"mode":"press","deviceType":"switch"},"firmware":"V6.5","refreshRate":15,"external":false,"logging":"debug"}]

[12/08/2023, 01:15:21] [SwitchBot] [DEBUG] Failed to Discover Devices, Error Message: "Cannot read properties of undefined (reading 'map')", Submit Bugs Here: https://tinyurl.com/SwitchBotBug

[12/08/2023, 01:15:21] [SwitchBot] [DEBUG] Failed to Discover Devices, Error: TypeError: Cannot read properties of undefined (reading 'map')

Config for homebridge-switchbot

{
    "bridge": {
        "name": "Bill Homebridge",
        "username": "0E:89:49:64:91:86",
        "port": 51430,
        "pin": "630-27-655"
    },
    "accessories": [],
    "platforms": [
        {
            "name": "Config",
            "port": 8581,
            "auth": "form",
            "theme": "auto",
            "tempUnits": "c",
            "lang": "auto",
            "platform": "config"
        },
        {
            "name": "SwitchBot",
            "credentials": {
                "token": "<hidden>",
                "secret": "<hidden>",
                "notice": "Keep your Token & Secret a secret!"
            },
            "options": {
                "devices": [
                    {
                        "deviceId": "CF:F4:61:9C:50:9D",
                        "configDeviceName": "Bot Door",
                        "configDeviceType": "Bot",
                        "connectionType": "BLE/OpenAPI",
                        "bot": {
                            "mode": "switch",
                            "deviceType": "switch"
                        },
                        "firmware": "V6.3",
                        "refreshRate": 6,
                        "logging": "debug"
                    },
                    {
                        "deviceId": "C1:38:32:30:44:61",
                        "configDeviceName": "Bot Light",
                        "configDeviceType": "Bot",
                        "connectionType": "OpenAPI",
                        "bot": {
                            "mode": "press",
                            "deviceType": "switch"
                        },
                        "firmware": "V6.5",
                        "refreshRate": 15,
                        "external": false,
                        "logging": "debug"
                    }
                ],
                "refreshRate": 6,
                "logging": "debug"
            },
            "_bridge": {
                "username": "0E:55:D6:94:91:A4",
                "port": 57234
            },
            "platform": "SwitchBot"
        }
    ],
    "disabledPlugins": []
}

Screenshots

image

image

image

Device and Model

SwitchBot Bot

Node.js Version

v20.5.0

NPM Version

v9.8.0

Homebridge Version

v1.6.1

Homebridge Switchbot Plugin Version

v2.8.0-beta.12

Homebridge Config UI X Plugin Version

v4.50.4

Operating System

Raspbian

ievolk commented 1 year ago

I'm having the same error.

nathennod commented 1 year ago

+1. Was working fine then stopped working for no reason. Tried everything, removing and adding the plugin but now refuses to discover any device via API.

Also tried @switchbot/homebridge-switchbot@2.8.0-beta.13

nathennod commented 1 year ago

Debug logging shows:

[SwitchBot] [DEBUG] SwitchBot Device Config Not Set: undefined [15/08/2023, 11:59:54 pm] [SwitchBot] [DEBUG] Failed to Discover Devices, Error Message: "Cannot read properties of undefined (reading 'map')", Submit Bugs Here: https://tinyurl.com/SwitchBotBug [15/08/2023, 11:59:54 pm] [SwitchBot] [DEBUG] Failed to Discover Devices, Error: TypeError: Cannot read properties of undefined (reading 'map')

donavanbecker commented 1 year ago

@mrlt8 have you experienced this at all?

mrlt8 commented 1 year ago

The batteries in my bots are all dead so I haven't encountered this, but the API is pretty flakey and the culprit seems to be:

[02/08/2023, 12:17:11] [SwitchBot] Bot: Bot Light Unknown statusCode: 500, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug

You'll probably want to assert the status code is 200 or throw an error around here to avoid the undefined message: https://github.com/OpenWonderLabs/homebridge-switchbot/blob/09ff2520b0e2c7409a371e5c5c264aee17823a7e/src/device/bot.ts#L563-L566

or at the end of the statusCode()?

something like:

    if (statusCode !== 200) {
      throw new Error(`Unexpected status code: ${statusCode}`);
    }

As for discoverDevices, that one seems to return a 200, so maybe check the length of deviceLists instead of devicesAPI.body?

https://github.com/OpenWonderLabs/homebridge-switchbot/blob/472aef8bf69434f757c7cc573dc29d2b81d7bdf6/src/platform.ts#L295-L298

Probably a good idea to also throw an error if the status code is not 200.

donavanbecker commented 1 year ago

@mrlt8, I have status code here: https://github.com/OpenWonderLabs/homebridge-switchbot/blob/472aef8bf69434f757c7cc573dc29d2b81d7bdf6/src/platform.ts#L292 So should be good with that.

donavanbecker commented 1 year ago

Pushed a beta for this:

As for discoverDevices, that one seems to return a 200, so maybe check the length of deviceLists instead of devicesAPI.body?

https://github.com/OpenWonderLabs/homebridge-switchbot/blob/472aef8bf69434f757c7cc573dc29d2b81d7bdf6/src/platform.ts#L295-L298

Can you try the latest beta:

npm version

Click here to find out how to install Beta

donavanbecker commented 1 year ago

You'll probably want to assert the status code is 200 or throw an error around here to avoid the undefined message:

https://github.com/OpenWonderLabs/homebridge-switchbot/blob/09ff2520b0e2c7409a371e5c5c264aee17823a7e/src/device/bot.ts#L563-L566

or at the end of the statusCode()?

something like:

    if (statusCode !== 200) {
      throw new Error(`Unexpected status code: ${statusCode}`);
    }

As for discoverDevices, that one seems to return a 200, so maybe check the length of deviceLists instead of devicesAPI.body?

https://github.com/OpenWonderLabs/homebridge-switchbot/blob/472aef8bf69434f757c7cc573dc29d2b81d7bdf6/src/platform.ts#L295-L298

Probably a good idea to also throw an error if the status code is not 200.

Modified both of these with beta.18

https://github.com/OpenWonderLabs/homebridge-switchbot/blob/8aa1b4dfdc003ede00b7d8909a434192e272f081/src/platform.ts#L303 https://github.com/OpenWonderLabs/homebridge-switchbot/blob/8aa1b4dfdc003ede00b7d8909a434192e272f081/src/device/bot.ts#L566

@mrlt8, anything you would change?

mrlt8 commented 1 year ago

I would probably move the this.statusCode(statusCode); out of the if check and errorLog the statusCode:

      this.statusCode(statusCode);
      if (statusCode === 200) {
         ...
      } else {
        this.errorLog(`Failed <openAPIRefreshStatus/openAPIRefreshStatus>, statusCode: ${statusCode}`);
      }

May also want to update all the other requests to catch any non-200 requests.

Since you already have the request wrapped in a try-catch, could potentially be easier to just update the statusCode method to throw an error instead, and the try-catch block should catch that:

 async statusCode(statusCode: number): Promise<void> {
    switch (statusCode) {
      ...
      default:
        this.infoLog(
          `${this.device.deviceType}: ${this.accessory.displayName} Unknown statusCode: ` +
          `${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`,
        );
        throw new Error(`Unknown Status Code: ${statusCode}`);
    }
  }
nathennod commented 1 year ago

Hey @donavanbecker thanks for the latest beta! It is now working again!

pinhao1994 commented 1 year ago

Hi @donavanbecker thanks for the support.

I have updated to the latest version, v2.8.0-beta.19, but I still encounter the issue.

From my 3 days' observation, I found that my hb starts raising exceptions after 18:00 (UTC + 8) and it will recover after I wake up tomorrow after 8:00 (UTC + 8).

What could be the cause of making the plugin down every night?

mrlt8 commented 1 year ago

Most likely an issue on the switchbot API. Might want to report it there: https://github.com/OpenWonderLabs/SwitchBotAPI, but support seems non-existent.

donavanbecker commented 1 year ago

Or a network issue

donavanbecker commented 1 year ago

I would probably move the this.statusCode(statusCode); out of the if check and errorLog the statusCode:


      this.statusCode(statusCode);

      if (statusCode === 200) {

         ...

      } else {

        this.errorLog(`Failed <openAPIRefreshStatus/openAPIRefreshStatus>, statusCode: ${statusCode}`);

      }

May also want to update all the other requests to catch any non-200 requests.

Since you already have the request wrapped in a try-catch, could potentially be easier to just update the statusCode method to throw an error instead, and the try-catch block should catch that:


 async statusCode(statusCode: number): Promise<void> {

    switch (statusCode) {

      ...

      default:

        this.infoLog(

          `${this.device.deviceType}: ${this.accessory.displayName} Unknown statusCode: ` +

          `${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`,

        );

        throw new Error(`Unknown Status Code: ${statusCode}`);

    }

  }

@mrlt8 if you have time, wanna throw this in a PR?

mrlt8 commented 1 year ago

@pinhao1994 is getting Unknown statusCode: 500 which is an "Internal Server Error" on the API: https://github.com/OpenWonderLabs/SwitchBotAPI#standard-http-error-codes

pinhao1994 commented 1 year ago

@pinhao1994 is getting Unknown statusCode: 500 which is an "Internal Server Error" on the API: https://github.com/OpenWonderLabs/SwitchBotAPI#standard-http-error-codes

@mrlt8 Could you give me more details on this?

I believe I am a stable network connection since my other smart devices (that are not Switchbot) still work perfectly. At the time when I am writing this message, I faced the same issue again. It is quite interesting that the SwitchBotAPI always die during the night.

pinhao1994 commented 1 year ago

I wonder if this could be caused by the request limit? Since I have a short pull time period, I could reach 1000 times API calls per day which caused the error.

image

nathennod commented 1 year ago

Sounds like your theory is plausible! Mine stop working again and I have set it to 5 second API refresh rate, which would incur at least 17,280 calls per day.

mrlt8 commented 1 year ago

I didn't think so at first as the API should return a 429 error.

However, I was doing some debugging and noticed that I kept getting a 200 response in Homebridge when taking my devices offline even though I would get a 171 when making a request directly to the API:

{"statusCode":171,"body":{},"message":"No hub record,is offline"}

It turns out the plug-in was only checking HTTP response and NOT the statusCode in the json response:

https://github.com/OpenWonderLabs/homebridge-switchbot/blob/472aef8bf69434f757c7cc573dc29d2b81d7bdf6/src/device/bot.ts#L538-L543

So we could potentially be ignoring some unexpected statusCode in the json response as long as the HTTP response was 200.

donavanbecker commented 1 year ago

v2.8.0 is released

pinhao1994 commented 1 year ago

@nathennod @donavanbecker

I confirm the bug is caused by the 10k request limitation per day.

First, I increased the poll rate from 6 sec to 15 sec for 2 bots and the advanced settings. I did not face the issue after 10 pm (UTC+8). However, I meet the issue again at 7:30 am tomorrow morning, but the service recovers at 8:00 am (aka. 00:00 UTC). Therefore, I think although I have 3 poll rates to be exactly the same as 15 sec, I believe they could be polled separately and could still cause the issue. Lastly, I increase the rate to 60 sec and wish for the best.

donavanbecker commented 1 year ago

@pinhao1994 Are you setting a refreshRate for each device? You can set different rates for each device.

nathennod commented 1 year ago

I have 1 bot and I’ve set it to poll 30 seconds and so far so good!

pinhao1994 commented 1 year ago

@donavanbecker

I understand that we could set individual refreshRate for each device, but I suspect the devices are refreshed separately. That is to say, if I have one device, it could be refreshed as frequently as 9 sec which is equal to 9600 (< 10k) API calls per day.

My situation is that I have 2 switchbot bots, 1 IR for Air Conditioner, and 1 external IR for TV. Based on the settings, I could set individual refreshRate for each bot and one refreshRate in the "advanced settings" (I assume that the advanced settings refreshRate is for the IR devices".)

Now let's assume all devices will be refreshed "separately" in the background based on their refresh rates. Then, although I have max 10K API quota per day, each device could actually only be updated 10k / 4 = 2500 per day. That is to say, in the worst case, each device could only have refreshRate 86400 / 2500 ~= 35 sec.

Therefore, to optimize this part, we should first figure out the logic of refresh in the background.

donavanbecker commented 1 year ago

@pinhao1994 IR devices don't refresh data.