home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.42k stars 30.31k forks source link

Climate Honeywell component throws error about API being rate-limited #5597

Closed dimdedmid closed 7 years ago

dimdedmid commented 7 years ago

Home Assistant release (hass --version): 0.36.1 Python release (python3 --version): 3.5.2 Component/platform: climate/honeywell Dependency: Somecomfort 0.4.1 Description of problem:

I have a regular honeywell configuration that works for about a day or two. Then the component starts throwing error "somecomfort.client.APIRateLimited: You are being rate-limited. Try waiting a bit." every 2 minutes. Since then it doesn't work any more. I can't set or get current temperature or do anything else. When I restart HASS, everything comes back to normal until the next day.

HA Climate component is polling Honeywell API every minute and that parameter is hardcoded. Honeywell API FAQ states that status requests should be every 5 minutes per hour.

Our limit is designed to allow you to poll device status every 5 minutes for up to 20 devices per hour, with a little cushion to make changes. If you need a higher rate limit, please contact us: HoneywellAPISupport@honeywell.com

As a workaround I opened "..\Python\Python35\Lib\site-packages\homeassistant\components\climate\__init__.py", increased SCAN_INTERVAL to 300 seconds and restarted HASS. The issue is gone but next update will bring original code back.

Expected: Please, make SCAN_INTERVAL configurable in yaml rather than hardcoded to 60sec and add scan_interval parameter to yaml for climate component to be able to meet API rate limitation. Could you also set dependency version of somecomfort python module to 0.4.1. Now it is 0.3.2.

Problem-relevant configuration.yaml entries and steps to reproduce:

platform: honeywell
username: xxx
password: xxx
region: us

Traceback (if applicable):

Traceback (most recent call last):
File "C:\Users\Dmitry\AppData\Local\Programs\Python\Python35\lib\asyncio\tasks.py", line 241, in _step
result = coro.throw(exc)
File "C:\Users\Dmitry\AppData\Local\Programs\Python\Python35\lib\site-packages\homeassistant\helpers\entity_component.py", line 387, in updateentity_states
yield from update_coro
File "C:\Users\Dmitry\AppData\Local\Programs\Python\Python35\lib\site-packages\homeassistant\helpers\entity.py", line 216, in async_update_ha_state
yield from self.hass.loop.run_in_executor(None, self.update)
File "C:\Users\Dmitry\AppData\Local\Programs\Python\Python35\lib\asyncio\futures.py", line 361, in iter
yield self # This tells Task to wait for completion.
File "C:\Users\Dmitry\AppData\Local\Programs\Python\Python35\lib\asyncio\tasks.py", line 296, in _wakeup
future.result()
File "C:\Users\Dmitry\AppData\Local\Programs\Python\Python35\lib\asyncio\futures.py", line 274, in result
raise self._exception
File "C:\Users\Dmitry\AppData\Local\Programs\Python\Python35\lib\concurrent\futures\thread.py", line 55, in run
result = self.fn(*self.args, **self.kwargs)
File "C:\Users\Dmitry\AppData\Local\Programs\Python\Python35\lib\site-packages\homeassistant\components\climate\honeywell.py", line 279, in update
self._device.refresh()
File "C:\Users\Dmitry\AppData\Local\Programs\Python\Python35\lib\site-packages\somecomfort\client.py", line 87, in refresh
data = self.client.get_thermostat_data(self.deviceid)
File "C:\Users\Dmitry\AppData\Local\Programs\Python\Python35\lib\site-packages\somecomfort\client.py", line 449, in getthermostat_data
return self.getjson(url)
File "C:\Users\Dmitry\AppData\Local\Programs\Python\Python35\lib\site-packages\somecomfort\client.py", line 425, in getjson
return self.requestjson('get', *args, **kwargs)
File "C:\Users\Dmitry\AppData\Local\Programs\Python\Python35\lib\site-packages\somecomfort\client.py", line 417, in requestjson
raise APIRateLimited()
somecomfort.client.APIRateLimited: You are being rate-limited. Try waiting a bit.

Additional info:

pvizeli commented 7 years ago

scan_interval work on every platform. The hardcodec is only for default value... But I think the trouble need to fix on api with a data cache.

dimdedmid commented 7 years ago

Thank you @pvizeli . I will try using scan_interval. The only request left would be

Could you also set dependency version of somecomfort python module to 0.4.1. Now it is 0.3.2.

jschwalbe commented 7 years ago

I too am having this problem. Just to be clear I understand correctly, we should be adding scan_interval: 500 to the configuration.yaml file?

pvizeli commented 7 years ago

To platform yes. @dimdedmid can you make a PR with pump version to 0.4.1 after you have test it?

balloob commented 7 years ago

Please submit a PR to add a SCAN_INTERVAL value to the Honeywell platform. We are already on somecomfort 0.4.1

dimdedmid commented 7 years ago

Ok, I am taking off my request to add SCAN_INTERVAL since the generic scan_interval parameter applicable to any component does the job. I have this config running for 2 days and it doesn't cause errors in the log. I will try to test with scan_interval: 300 a bit later.

climate:
  platform: honeywell
  username: !secret thermostat_username
  password: !secret thermostat_password
  region: us
  scan_interval: 600

I would really appreciate if someone can

make a PR with pump version to 0.4.1 after you have test it

because I am a newbie here.

balloobbot commented 7 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.

Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment :+1:

balloobbot commented 7 years ago

This issue will be auto-closed because there hasn't been any activity for a few months. Feel free to open a new one if you still experience this problem 👍