dkerr64 / homebridge-yolink

Apache License 2.0
12 stars 2 forks source link

YoLink API rate limit problems #85

Closed dkerr64 closed 9 months ago

dkerr64 commented 9 months ago

YoLink cloud server API rate limits break control of devices...

Initialization of plugin starts fine...

[11/23/2023, 9:30:27 AM] [YoLink] Restarting child bridge...
[11/23/2023, 9:30:27 AM] Got SIGTERM, shutting down child bridge process...
[11/23/2023, 9:30:32 AM] [YoLink] Child bridge process ended
[11/23/2023, 9:30:32 AM] [YoLink] Process Ended. Code: 143, Signal: null
[11/23/2023, 9:30:39 AM] [YoLink] Restarting Process...
[11/23/2023, 9:30:39 AM] [YoLink] Launched child bridge with PID 367215
[11/23/2023, 9:30:39 AM] Registering platform 'homebridge-yolink.YoLink'
[11/23/2023, 9:30:39 AM] [YoLink] Loaded homebridge-yolink v1.4.1-beta.0 child bridge successfully
[11/23/2023, 9:30:39 AM] Loaded 19 cached accessories from cachedAccessories.0E8E94C528AC.
[11/23/2023, 9:30:39 AM] [YoLink] YoLink plugin for HomeBridge version 1.4.1-beta.0 (c) 2022 David A. Kerr
Please report all bugs at https://github.com/dkerr64/homebridge-yolink/issues

[11/23/2023, 9:30:39 AM] [YoLink] Login to YoLink API with credentials from config
[11/23/2023, 9:30:39 AM] Homebridge v1.7.0 (HAP v0.11.1) (YoLink) is running on port 37497.
[11/23/2023, 9:30:40 AM] [YoLink] Starting interval timer to refresh accessToken every 6480 seconds
[11/23/2023, 9:30:40 AM] [YoLink] Hide Hydrometer service because config.[d88b4c01000472db].hide is set to "hydro"
[11/23/2023, 9:30:40 AM] [YoLink] Device Garage Door Front (d88b4c010003f905) assigned to a garage door
[11/23/2023, 9:30:40 AM] [YoLink] Device Garage Door Sensor (d88b4c0200067636) assigned to a garage door
[11/23/2023, 9:30:40 AM] [YoLink] Not registering device Power Strip (d88b4c0100029741) as config 'hide=true'
[11/23/2023, 9:30:40 AM] [YoLink] Not registering device YoLink Hub (d88b4c1603008c02) as config 'hide=true'
[11/23/2023, 9:30:40 AM] [YoLink] Setting interval timer to check for new devices every 600 seconds
[11/23/2023, 9:30:40 AM] [YoLink] Create MQTT client to connect to YoLink message service
[11/23/2023, 9:30:41 AM] [YoLink] MQTT subscribed: yl-home/d3d51dfc169c4f7aa02b1bf5901a92db/+/report
[11/23/2023, 9:30:41 AM] [YoLink] Battery level for Mailbox (d88b4c0100042d52) is: 25%

But 7 devices report a can't connect error...

[11/23/2023, 9:30:45 AM] [YoLink] Recirculating Fan (d88b4c010004e637) YoLink API error code: 000201 Can't connect to Device (Outlet.getState)
[11/23/2023, 9:30:45 AM] [YoLink] T-Mobile Modem (d88b4c0100044287) YoLink API error code: 000201 Can't connect to Device (Outlet.getState)
[11/23/2023, 9:30:45 AM] [YoLink] Door Lock (d88b4c0100036498) YoLink API error code: 000201 Can't connect to Device (Lock.getState)
[11/23/2023, 9:30:45 AM] [YoLink] Towel Heater (d88b4c010004e62b) YoLink API error code: 000201 Can't connect to Device (Outlet.getState)
[11/23/2023, 9:30:45 AM] [YoLink] YoLink Dimmer (d88b4c0100051ec7) YoLink API error code: 000201 Can't connect to Device (Dimmer.getState)
[11/23/2023, 9:30:45 AM] [YoLink] Water Main Valve (d88b4c01000369a3) YoLink API error code: 000201 Can't connect to Device (Manipulator.getState)
[11/23/2023, 9:30:45 AM] [YoLink] Garage Door Front (d88b4c010003f905) YoLink API error code: 000201 Can't connect to Device (GarageDoor.getState)

First retry after 15 seconds, down to 6 devices failing...

[11/23/2023, 9:31:04 AM] [YoLink] Recirculating Fan (d88b4c010004e637) YoLink API error code: 000201 Can't connect to Device (Outlet.getState)
[11/23/2023, 9:31:04 AM] [YoLink] Door Lock (d88b4c0100036498) YoLink API error code: 000201 Can't connect to Device (Lock.getState)
[11/23/2023, 9:31:04 AM] [YoLink] T-Mobile Modem (d88b4c0100044287) YoLink API error code: 000201 Can't connect to Device (Outlet.getState)
[11/23/2023, 9:31:04 AM] [YoLink] YoLink Dimmer (d88b4c0100051ec7) YoLink API error code: 000201 Can't connect to Device (Dimmer.getState)
[11/23/2023, 9:31:04 AM] [YoLink] Towel Heater (d88b4c010004e62b) YoLink API error code: 000201 Can't connect to Device (Outlet.getState)
[11/23/2023, 9:31:04 AM] [YoLink] Garage Door Front (d88b4c010003f905) YoLink API error code: 000201 Can't connect to Device (GarageDoor.getState)

Second retry after additional 30 seconds, still 6 devices failing...

[11/23/2023, 9:31:38 AM] [YoLink] Recirculating Fan (d88b4c010004e637) YoLink API error code: 000201 Can't connect to Device (Outlet.getState)
[11/23/2023, 9:31:38 AM] [YoLink] Door Lock (d88b4c0100036498) YoLink API error code: 000201 Can't connect to Device (Lock.getState)
[11/23/2023, 9:31:38 AM] [YoLink] T-Mobile Modem (d88b4c0100044287) YoLink API error code: 000201 Can't connect to Device (Outlet.getState)
[11/23/2023, 9:31:38 AM] [YoLink] YoLink Dimmer (d88b4c0100051ec7) YoLink API error code: 000201 Can't connect to Device (Dimmer.getState)
[11/23/2023, 9:31:38 AM] [YoLink] Towel Heater (d88b4c010004e62b) YoLink API error code: 000201 Can't connect to Device (Outlet.getState)
[11/23/2023, 9:31:39 AM] [YoLink] Garage Door Front (d88b4c010003f905) YoLink API error code: 000201 Can't connect to Device (GarageDoor.getState)

Third retry after additional 45 seconds, down to 5 devices failing...

[11/23/2023, 9:32:28 AM] [YoLink] Recirculating Fan (d88b4c010004e637) YoLink API error code: 000201 Can't connect to Device (Outlet.getState)
[11/23/2023, 9:32:28 AM] [YoLink] T-Mobile Modem (d88b4c0100044287) YoLink API error code: 000201 Can't connect to Device (Outlet.getState)
[11/23/2023, 9:32:28 AM] [YoLink] Towel Heater (d88b4c010004e62b) YoLink API error code: 000201 Can't connect to Device (Outlet.getState)
[11/23/2023, 9:32:28 AM] [YoLink] YoLink Dimmer (d88b4c0100051ec7) YoLink API error code: 000201 Can't connect to Device (Dimmer.getState)
[11/23/2023, 9:32:28 AM] [YoLink] Garage Door Front (d88b4c010003f905) YoLink API error code: 000201 Can't connect to Device (GarageDoor.getState)

Fourth retry after additional 60 seconds, down to 3 devices failing...

[11/23/2023, 9:33:32 AM] [YoLink] Recirculating Fan (d88b4c010004e637) YoLink API error code: 000201 Can't connect to Device (Outlet.getState)
[11/23/2023, 9:33:32 AM] [YoLink] T-Mobile Modem (d88b4c0100044287) YoLink API error code: 000201 Can't connect to Device (Outlet.getState)
[11/23/2023, 9:33:32 AM] [YoLink] Towel Heater (d88b4c010004e62b) YoLink API error code: 000201 Can't connect to Device (Outlet.getState)

And finally only one fails...

[11/23/2023, 9:34:36 AM] [YoLink] Towel Heater (d88b4c010004e62b) YoLink API error code: 000201 Can't connect to Device (Outlet.getState)

Next retry was successful (no error logged). Now lets try turning on the dimmer switch and adjusting brightness...

[11/23/2023, 9:36:12 AM] [YoLink] YoLinkAPI.setDeviceState for YoLink Dimmer (d88b4c0100051ec7): {"state":"open","brightness":28}
[11/23/2023, 9:36:13 AM] [YoLink] YoLinkAPI.setDeviceState for YoLink Dimmer (d88b4c0100051ec7): {"state":"open","brightness":3}
[11/23/2023, 9:36:15 AM] [YoLink] YoLinkAPI.setDeviceState for YoLink Dimmer (d88b4c0100051ec7): {"state":"open","brightness":33}
[11/23/2023, 9:36:17 AM] [YoLink] YoLinkAPI.setDeviceState for YoLink Dimmer (d88b4c0100051ec7): {"state":"open","brightness":33}
[11/23/2023, 9:36:21 AM] [YoLink] YoLinkAPI.setDeviceState for YoLink Dimmer (d88b4c0100051ec7): {"state":"open","brightness":35}
[11/23/2023, 9:36:22 AM] [YoLink] YoLinkAPI.setDeviceState for YoLink Dimmer (d88b4c0100051ec7): {"state":"open","brightness":44}
[11/23/2023, 9:36:41 AM] [YoLink] YoLinkAPI.setDeviceState for YoLink Dimmer (d88b4c0100051ec7): {"state":"open","brightness":43}
[11/23/2023, 9:36:41 AM] [YoLink] YoLink Dimmer (d88b4c0100051ec7) YoLink API error code: 020104 Device is busy, try again later. (Dimmer.setState)
[11/23/2023, 9:36:51 AM] [YoLink] YoLinkAPI.setDeviceState for YoLink Dimmer (d88b4c0100051ec7): {"state":"open","brightness":43}
[11/23/2023, 9:36:51 AM] [YoLink] YoLink Dimmer (d88b4c0100051ec7) YoLink API error code: 020104 Device is busy, try again later. (Dimmer.setState)
[11/23/2023, 9:37:11 AM] [YoLink] YoLinkAPI.setDeviceState for YoLink Dimmer (d88b4c0100051ec7): {"state":"open","brightness":43}
[11/23/2023, 9:37:12 AM] [YoLink] YoLink Dimmer (d88b4c0100051ec7) YoLink API error code: 020104 Device is busy, try again later. (Dimmer.setState)
[11/23/2023, 9:37:42 AM] [YoLink] YoLinkAPI.setDeviceState for YoLink Dimmer (d88b4c0100051ec7): {"state":"open","brightness":43}
[11/23/2023, 9:37:43 AM] [YoLink] YoLinkAPI.setDeviceState for YoLink Dimmer (d88b4c0100051ec7): {"state":"open","brightness":37}
[11/23/2023, 9:37:45 AM] [YoLink] YoLinkAPI.setDeviceState for YoLink Dimmer (d88b4c0100051ec7): {"state":"open","brightness":37}
[11/23/2023, 9:37:47 AM] [YoLink] YoLinkAPI.setDeviceState for YoLink Dimmer (d88b4c0100051ec7): {"state":"open","brightness":44}
[11/23/2023, 9:37:49 AM] [YoLink] YoLinkAPI.setDeviceState for YoLink Dimmer (d88b4c0100051ec7): {"state":"close","brightness":44}

The maximum of 6-per-minute-per-device rate limit completely screws up adjusting the brightness. It takes 90 seconds to turn on, adjust, turn off... something that should have taken less than 10 seconds (the amount of time I adjusted the switch in Apple Home app).

dkerr64 commented 9 months ago

@matrixd2 I'd be grateful if you could advice what causes 000201 errors, and work around for 020104 rate limit errors for devices like dimmer switches.

dkerr64 commented 9 months ago

I believe the the 000201 errors start after successfully connecting and retrieving status for 10 devices. Anything more than 10 and this error is issues. Over time, as YoLink servers allow me to connect to more devices they succeed. Unless YoLink permit more than 10 connections this problem will continue. Therefore...

  1. I will add notice to README file documenting this behavior
  2. I will increase the time between retries to 60 seconds and continue for 30 minutes before giving up !!!
matrixd2 commented 9 months ago

@dkerr64 How many node devices and hubs do you have, can you please dm me on discord and send me you hub device eui, i will take a look on you devices

dkerr64 commented 9 months ago

@dkerr64 How many node devices and hubs do you have, can you please dm me on discord and send me you hub device eui, i will take a look on you devices

@matrixd2 I have sent you a PM on discord. Thanks.

dkerr64 commented 9 months ago

Closing as this is fixed as best it can be for now.