Skip to content

Commit

Permalink
fix: auto reload when extended entity discovery is enabled (#1254)
Browse files Browse the repository at this point in the history
* Automatically reload the integration when extended entity discovery is enabled.

* fix: reload only after all values processed

Co-authored-by: Alan Tse <[email protected]>
  • Loading branch information
blm126 and alandtse authored Apr 19, 2021
1 parent 0920a7d commit 8a8f8ee
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions custom_components/alexa_media/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1186,6 +1186,7 @@ async def update_listener(hass, config_entry):
"""Update when config_entry options update."""
account = config_entry.data
email = account.get(CONF_EMAIL)
reload_needed: bool = False
for key, old_value in hass.data[DATA_ALEXAMEDIA]["accounts"][email][
"options"
].items():
Expand All @@ -1198,6 +1199,10 @@ async def update_listener(hass, config_entry):
old_value,
hass.data[DATA_ALEXAMEDIA]["accounts"][email]["options"][key],
)
if key == CONF_EXTENDED_ENTITY_DISCOVERY:
reload_needed = True
if reload_needed:
await hass.config_entries.async_reload(config_entry.entry_id)


async def test_login_status(hass, config_entry, login) -> bool:
Expand Down

0 comments on commit 8a8f8ee

Please sign in to comment.