Skip to content

Commit

Permalink
- added support for unloading the coordinator on setup if one already…
Browse files Browse the repository at this point in the history
… exists
  • Loading branch information
simbaja committed Dec 1, 2024
1 parent 8d2acf3 commit d96e5e8
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions custom_components/ge_home/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,22 @@ async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry):


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Set up the ge_home component."""
"""Set up ge_home from a config entry."""
hass.data.setdefault(DOMAIN, {})

"""Set up ge_home from a config entry."""
#try to get existing coordinator
existing: GeHomeUpdateCoordinator = dict.get(hass.data[DOMAIN],entry.entry_id)

coordinator = GeHomeUpdateCoordinator(hass, entry)
hass.data[DOMAIN][entry.entry_id] = coordinator

# try to unload the existing coordinator
try:
if existing:
await coordinator.async_reset()
except:
_LOGGER.warning("Could not reset existing coordinator.")

try:
if not await coordinator.async_setup():
return False
Expand Down

0 comments on commit d96e5e8

Please sign in to comment.