mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Use a unique cache folder per Velbus config entry (#79792)
This commit is contained in:
parent
2d9f39d406
commit
458f3d4d13
@ -2,6 +2,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import shutil
|
||||
|
||||
from velbusaio.controller import Velbus
|
||||
import voluptuous as vol
|
||||
@ -12,6 +13,7 @@ from homeassistant.core import HomeAssistant, ServiceCall
|
||||
from homeassistant.helpers import device_registry
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.device_registry import DeviceEntry
|
||||
from homeassistant.helpers.storage import STORAGE_DIR
|
||||
|
||||
from .const import (
|
||||
CONF_INTERFACE,
|
||||
@ -64,7 +66,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
|
||||
controller = Velbus(
|
||||
entry.data[CONF_PORT],
|
||||
cache_dir=hass.config.path(".storage/velbuscache/"),
|
||||
cache_dir=hass.config.path(STORAGE_DIR, f"velbuscache-{entry.entry_id}"),
|
||||
)
|
||||
hass.data[DOMAIN][entry.entry_id] = {}
|
||||
hass.data[DOMAIN][entry.entry_id]["cntrl"] = controller
|
||||
@ -138,6 +140,10 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||
await hass.data[DOMAIN][entry.entry_id]["cntrl"].stop()
|
||||
hass.data[DOMAIN].pop(entry.entry_id)
|
||||
await hass.async_add_executor_job(
|
||||
shutil.rmtree,
|
||||
hass.config.path(STORAGE_DIR, f"velbuscache-{entry.entry_id}"),
|
||||
)
|
||||
if not hass.data[DOMAIN]:
|
||||
hass.data.pop(DOMAIN)
|
||||
hass.services.async_remove(DOMAIN, SERVICE_SCAN)
|
||||
|
Loading…
x
Reference in New Issue
Block a user