Skip to content

Commit

Permalink
Update __init__.py - update and sync keys on config change
Browse files Browse the repository at this point in the history
As we are no longer allowed to modify the config entries on the fly, when a change is detected, you have to force an entry update to sync the keys
FozzieUK authored and nathanmarlor committed Nov 2, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 37239bb commit 708f47e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion custom_components/foxess_em/__init__.py
Original file line number Diff line number Diff line change
@@ -84,7 +84,12 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
_LOGGER.debug("Data %s", entry.data)

if entry_options and entry_options != entry_data:
# overwrite data with options
# overwrite data with options, force update as not allowed to access entries directly
hass.config_entries.async_update_entry(
entry,
data=entry_options,
version=BatteryManagerFlowHandler.VERSION,
)
entry_data = copy.deepcopy(dict(entry.options))
_LOGGER.debug("Config has been updated")
_LOGGER.debug("Data %s", entry.data)

0 comments on commit 708f47e

Please sign in to comment.