Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions custom_components/govee/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
_, err = await hub.get_devices()
if err:
_LOGGER.warning("Could not connect to Govee API: %s", err)
await hub.rate_limit_delay()
await hub._api.rate_limit_delay()
await async_unload_entry(hass, entry)
raise PlatformNotReady()

for component in PLATFORMS:
await hass.config_entries.async_forward_entry_setup(entry, component)
# Resolve deprecation in latest HA by moving to setups vs setup
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#235 is more thorough with the addition of error logging on fail


return True

Expand Down Expand Up @@ -99,7 +99,7 @@ def _unload_component_entry(
"""Unload an entry for a specific component."""
success = False
try:
success = hass.config_entries.async_forward_entry_unload(entry, component)
success = await hass.config_entries.async_forward_entry_unload(entry, component)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will fail, the function needs to be defined as async

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried the changes manually and they seem to work but this PR making the line 96 function definition async.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gabosom odd, I could have sworn I tried that and still got errors. So did you set the def as a sync and keep the await?

I can give that another test and update the PR

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the await is added

success = await hass.config_entries.async_forward_entry_unload(entry, component)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: 'await' outside async function

After changing to async def _unload_component_entry the error goes away but 2 new errors appear

Error unloading entry govee for light
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 963, in async_unload
    result = await component.async_unload_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 703, in async_unload_entry
    return await hass.data[DATA_COMPONENT].async_unload_entry(entry)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 237, in async_unload_entry
    raise ValueError("Config entry was never loaded!")
ValueError: Config entry was never loaded!

and

Error setting up entry govee for govee
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 749, in __async_setup_with_context
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/govee/__init__.py", line 69, in async_setup_entry
    raise PlatformNotReady()
homeassistant.exceptions.PlatformNotReady: None

But I think they are caused by me currently being rate-limited.

except ValueError:
# probably ValueError: Config entry was never loaded!
return success
Expand Down