RobertD502 / home-assistant-iocare

Home Assistant custom component for monitoring and controlling Coway Airmega Purifiers
MIT License
50 stars 8 forks source link

Coway IoCare now Rate Limiting #54

Open matthewpucc opened 6 days ago

matthewpucc commented 6 days ago

Recently, I have been getting an error message "Your request has been blocked due to exceeding the API rate limit. (Excessive requests)"

I think the code needs to update the polling rate or implement backoff.

RobertD502 commented 6 days ago

How many devices do you have on your account? I have 3 and have noticed that this seems to be short-lived and correlated to when they have temporary server stability issues (app is also acting up at the same time).

If you want to manually change the polling frequency, change the DEFAULT_SCAN_INTERVAL variable in const.py.

gh69 commented 6 days ago

I've just noticed this error today as well. I also have 3 devices with no changes to my setup in the last several months. I just updated my DEFAULT_SCAN_INTERVAL from 30 to 45...so we'll see what happens.

matthewpucc commented 6 days ago

I only have 2 devices. @RobertD502 have you seen this recently? I've been rate limited the last 18 hours and multiple times over the last week. I'm giving a go at configurable intervals but won't have much time to dedicate to it till tomorrow or monday.

matthewpucc commented 6 days ago

@gh69 report back on if that helps. I was going to give 120s a go since I don't really need that granular of metrics.

gh69 commented 6 days ago

@matthewpucc I'm not sure how long I'll have to wait to fall off of their rate-limit block-list but hopefully by tomorrow I should know whether or not such a small change made any difference. If not, I'll just keep bumping it up until it does. I'll let you know what I find. @RobertD502 Do you have a recommended alternative scan interval value?

matthewpucc commented 6 days ago

My plan was to leave it off overnight entirely in hopes of falling off the rate limiting radar. I'll post back if that worked.

randomstring commented 6 days ago

I have two devices and have been seeing this issue as well. When I go to use the app, I'm forced to log in again and I get a pop-up saying "This service is restricted due to unauthorized use. Please contact customer service. (Error code:F0101)"

I'm changing the scan interval to 60s and see if that helps.

randomstring commented 6 days ago

After a HA restart I saw that the integration startup was failing with the same Error code F0101, and mentions exceeding the API rate limit (unlike the iphone app). The integration setup retry interval is pretty short, maybe < 30s, thus probably perpetuating the API rate limit exception. Possibly indefinitely. Is there some sort of increasing back off interval algorithm into the integration startup? I would hope that HA might have that baked in and not rely on every integration to re-implement it. I temporarily disabled the plugin and will re-enable this afternoon and hope I've cleared the API rate limiting.

Has anyone tried contacting support at Coway? I know, I know, what are the chances you'll end up communicating with someone who knows what you're talking about, but worth a try?

matthewpucc commented 6 days ago

I had success with leaving it off overnight and re-enabling. I'm going to set the polling to a 300s interval and see how the day goes.

gh69 commented 6 days ago

I didn't turn mine off last night...just updated the scan interval from 30 to 45 and left it running and today I'm back to normal with no errors.

matthewpucc commented 6 days ago

noice. if you see any issues today, let me know. i may drop the polling rate to 90s or something

randomstring commented 6 days ago

The crazy thing is, when I log into the iPhone app it still asks me first if I want to change my password before it kicks me out with the F0101 error. What is wrong with these people?

matthewpucc commented 6 days ago

@randomstring , have you tried disabling the integration for a bit?

randomstring commented 5 days ago

@randomstring , have you tried disabling the integration for a bit?

I did. 2 hours later, still blocked. Maybe I can infer how long the API rate limiting is (there could be a couple ways they track API rate). It might be queries per day and clear at midnight (UTC? server's timezone?)

randomstring commented 5 days ago

Back online. It took between 2-6 hrs to escape the API rate limit jail.

RobertD502 commented 5 days ago

It finally hit me as well....except I can't even log into the app. Best thing to do, for now, is to disable the integration and give it a few hours. In the meantime, change the scan interval found in const.py to a higher value, save it, and restart Home Assistant. This way, when you re-enable the integration at a later time, the integration will use the new polling interval.

All of this is pretty odd, given that I recall their app has a setting where you can have the app refresh (poll) every 5 seconds.