Skip to content

Commit

Permalink
Merge pull request #614 from natekspencer/cleanup
Browse files Browse the repository at this point in the history
Handle cleanup of config entry
  • Loading branch information
JurajNyiri authored Jun 28, 2024
2 parents 88949f3 + 88995b5 commit 34e16a1
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions custom_components/tapo_control/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,8 @@ async def async_remove_entry(hass: HomeAssistant, entry: ConfigEntry) -> None:
LOGGER.debug("Deleting hot storage files for entity " + entry_id + "...")
deleteDir(hotDirPath)

# Remove the entry data
hass.data[DOMAIN].pop(entry_id, None)

async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
if PYTAPO_REQUIRED_VERSION != PYTAPO_VERSION:
Expand Down Expand Up @@ -513,10 +515,12 @@ async def async_update_data():
and hass.data[DOMAIN][entry.entry_id]["mediaSyncScheduled"] is False
):
hass.data[DOMAIN][entry.entry_id]["mediaSyncScheduled"] = True
async_track_time_interval(
hass,
mediaSync,
timedelta(seconds=60),
entry.async_on_unload(
async_track_time_interval(
hass,
mediaSync,
timedelta(seconds=60),
)
)
elif (
hass.data[DOMAIN][entry.entry_id]["initialMediaScanRunning"]
Expand Down

0 comments on commit 34e16a1

Please sign in to comment.