Skip to content

Commit

Permalink
Fix async_forward_entry_setup warning #15 #16
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed Dec 8, 2024
1 parent 8272b41 commit 928d199
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
19 changes: 7 additions & 12 deletions custom_components/gyverlamp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from homeassistant.core import HomeAssistant

DOMAIN = "gyverlamp"
PLATFORMS = ["light"]


async def async_setup(hass, hass_config):
Expand All @@ -11,23 +12,17 @@ async def async_setup(hass, hass_config):


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
# migrate data (after first setup) to options
if entry.data:
hass.config_entries.async_update_entry(entry, data={}, options=entry.data)
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)

# add options handler
entry.add_update_listener(async_update_options)

# forward to light setup
coro = hass.config_entries.async_forward_entry_setup(entry, "light")
hass.async_create_task(coro)
if not entry.update_listeners:
entry.add_update_listener(async_update_options)

return True


async def async_update_options(hass: HomeAssistant, config_entry: ConfigEntry):
await hass.config_entries.async_reload(config_entry.entry_id)
async def async_update_options(hass: HomeAssistant, entry: ConfigEntry):
await hass.config_entries.async_reload(entry.entry_id)


async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
return await hass.config_entries.async_forward_entry_unload(entry, "light")
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
2 changes: 1 addition & 1 deletion custom_components/gyverlamp/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async def async_step_user(self, user_input=None):
if user_input is not None:
host = user_input[CONF_HOST]
user_input[CONF_EFFECTS] = parse_effects(user_input[CONF_EFFECTS])
return self.async_create_entry(title=host, data=user_input)
return self.async_create_entry(title=host, data={}, options=user_input)

effects = ",".join(EFFECTS)
return self.async_show_form(
Expand Down

0 comments on commit 928d199

Please sign in to comment.