LaggAt / hacs-govee

A HACS repository for Govee light integration
MIT License
270 stars 63 forks source link

API Limit Keeps getting hit #190

Open Dawe5ome opened 1 day ago

Dawe5ome commented 1 day ago

Version of the custom_component

2023.11.1

Configuration

I am running HA on a Raspberry Pi 5 using docker (as I have other integrations working on my pi).

I have 10 lights that I am controlling, they are:

My set up of the lights looks like this:

Here are the settings I have with it: image image

Describe the bug

The API limit of 10000 requests every 24 hours keeps being initialized. However this only happens when I assign my lights to an automation. If I leave my lights just as their own then I typically don't have issues besides the odd disconnect. I decided today would be a good day to test out an automation for turning on my lights if my home state changes from 0 to 1 person coming home. Then I hit the API limit.

What is the point of having Govee on HA if every time I try to do anything somewhat smart with HA it just hits the limit and I can no longer use it. It has less functionality currently than my Google Home and that thing is absolutely brutal.

Debug log

2024-11-21 16:30:07.707 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-11-21 16:30:07.707 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration govee which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-11-21 16:30:09.702 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to load_verify_locations with args (<ssl.SSLContext object at 0x7ffe9abfb6d0>, '/usr/local/lib/python3.12/site-packages/certifi/cacert.pem', None, None) inside the event loop by custom integration 'govee' at custom_components/govee/__init__.py, line 53: hub = await Govee.create( (offender: /usr/local/lib/python3.12/ssl.py, line 708: context.load_verify_locations(cafile, capath, cadata)), please create a bug report at https://github.com/LaggAt/hacs-govee/issues
For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#load_verify_locations
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/src/homeassistant/homeassistant/__main__.py", line 223, in <module>
    sys.exit(main())
  File "/usr/src/homeassistant/homeassistant/__main__.py", line 209, in main
    exit_code = runner.run(runtime_conf)
  File "/usr/src/homeassistant/homeassistant/runner.py", line 189, in run
    return loop.run_until_complete(setup_and_run_hass(runtime_config))
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 674, in run_until_complete
    self.run_forever()
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 641, in run_forever
    self._run_once()
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1990, in _run_once
    handle._run()
  File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/src/homeassistant/homeassistant/setup.py", line 165, in async_setup_component
    result = await _async_setup_component(hass, domain, config)
  File "/usr/src/homeassistant/homeassistant/setup.py", line 461, in _async_setup_component
    await asyncio.gather(
  File "/usr/src/homeassistant/homeassistant/setup.py", line 463, in <genexpr>
    create_eager_task(
  File "/usr/src/homeassistant/homeassistant/util/async_.py", line 45, in create_eager_task
    return Task(coro, loop=loop, name=name, eager_start=True)
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 783, in async_setup_locked
    await self.async_setup(hass, integration=integration)
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 546, in async_setup
    await self.__async_setup_with_context(hass, integration)
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 635, in __async_setup_with_context
    result = await component.async_setup_entry(hass, self)
  File "/config/custom_components/govee/__init__.py", line 53, in async_setup_entry
    hub = await Govee.create(

2024-11-21 16:30:10.029 WARNING (MainThread) [custom_components.govee] API is back online.
2024-11-21 16:30:10.030 WARNING (MainThread) [govee_api_laggat.api] Rate limit exceeded, check if other devices also utilize the govee API
2024-11-21 16:30:10.030 WARNING (MainThread) [custom_components.govee] Could not connect to Govee API: API: API-Error 429: {"message":"rate limited! the limit is 10000 requests every 24 hours. X-RateLimit-Reset in Http Response Header shows the reset time."}
2024-11-21 16:30:10.030 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry govee for govee
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 635, in __async_setup_with_context
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/govee/__init__.py", line 67, in async_setup_entry
    await hub.rate_limit_delay()
          ^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Govee' object has no attribute 'rate_limit_delay'. Did you mean: 'rate_limit_reset'?
2024-11-21 16:30:13.281 ERROR (Thread-6) [pychromecast.socket_client] [Bedroom TV(192.168.2.14):8009] Failed to connect to service MDNSServiceInfo(name='Chromecast-51579980351f5acc98270a4eb03d1e61._googlecast._tcp.local.'), retrying in 5.0s
shunopoli commented 8 hours ago

I am having this same issue. Any resolution?

jlexster2024 commented 7 hours ago

I just started using HA and added this to it and got the same thing. How do I know what constitutes an API call? I have all govee light bulbs at this point and want to use them in automation.