Delete KNX config storage when removing the integration (#135071)

This commit is contained in:
Matthias Alphart 2025-01-08 09:35:44 +01:00 committed by GitHub
parent f8618e65f6
commit dc1928f3eb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 2 deletions

View File

@ -91,7 +91,7 @@ from .schema import (
WeatherSchema, WeatherSchema,
) )
from .services import register_knx_services from .services import register_knx_services
from .storage.config_store import KNXConfigStore from .storage.config_store import STORAGE_KEY as CONFIG_STORAGE_KEY, KNXConfigStore
from .telegrams import STORAGE_KEY as TELEGRAMS_STORAGE_KEY, Telegrams from .telegrams import STORAGE_KEY as TELEGRAMS_STORAGE_KEY, Telegrams
from .websocket import register_panel from .websocket import register_panel
@ -226,6 +226,8 @@ async def async_remove_entry(hass: HomeAssistant, entry: ConfigEntry) -> None:
if knxkeys_filename is not None: if knxkeys_filename is not None:
with contextlib.suppress(FileNotFoundError): with contextlib.suppress(FileNotFoundError):
(storage_dir / knxkeys_filename).unlink() (storage_dir / knxkeys_filename).unlink()
with contextlib.suppress(FileNotFoundError):
(storage_dir / CONFIG_STORAGE_KEY).unlink()
with contextlib.suppress(FileNotFoundError): with contextlib.suppress(FileNotFoundError):
(storage_dir / PROJECT_STORAGE_KEY).unlink() (storage_dir / PROJECT_STORAGE_KEY).unlink()
with contextlib.suppress(FileNotFoundError): with contextlib.suppress(FileNotFoundError):

View File

@ -282,7 +282,7 @@ async def test_async_remove_entry(
patch("pathlib.Path.rmdir") as rmdir_mock, patch("pathlib.Path.rmdir") as rmdir_mock,
): ):
assert await hass.config_entries.async_remove(config_entry.entry_id) assert await hass.config_entries.async_remove(config_entry.entry_id)
assert unlink_mock.call_count == 3 assert unlink_mock.call_count == 4
rmdir_mock.assert_called_once() rmdir_mock.assert_called_once()
assert hass.config_entries.async_entries() == [] assert hass.config_entries.async_entries() == []