mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 07:07:28 +00:00
Fix Vicare cleanup token file on uninstall (#95992)
This commit is contained in:
parent
5249660a6a
commit
e68832a889
@ -2,8 +2,10 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Callable
|
from collections.abc import Callable
|
||||||
|
from contextlib import suppress
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
|
|
||||||
from PyViCare.PyViCare import PyViCare
|
from PyViCare.PyViCare import PyViCare
|
||||||
from PyViCare.PyViCareDevice import Device
|
from PyViCare.PyViCareDevice import Device
|
||||||
@ -25,6 +27,7 @@ from .const import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
_TOKEN_FILENAME = "vicare_token.save"
|
||||||
|
|
||||||
|
|
||||||
@dataclass()
|
@dataclass()
|
||||||
@ -64,7 +67,7 @@ def vicare_login(hass, entry_data):
|
|||||||
entry_data[CONF_USERNAME],
|
entry_data[CONF_USERNAME],
|
||||||
entry_data[CONF_PASSWORD],
|
entry_data[CONF_PASSWORD],
|
||||||
entry_data[CONF_CLIENT_ID],
|
entry_data[CONF_CLIENT_ID],
|
||||||
hass.config.path(STORAGE_DIR, "vicare_token.save"),
|
hass.config.path(STORAGE_DIR, _TOKEN_FILENAME),
|
||||||
)
|
)
|
||||||
return vicare_api
|
return vicare_api
|
||||||
|
|
||||||
@ -93,4 +96,9 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
if unload_ok:
|
if unload_ok:
|
||||||
hass.data[DOMAIN].pop(entry.entry_id)
|
hass.data[DOMAIN].pop(entry.entry_id)
|
||||||
|
|
||||||
|
with suppress(FileNotFoundError):
|
||||||
|
await hass.async_add_executor_job(
|
||||||
|
os.remove, hass.config.path(STORAGE_DIR, _TOKEN_FILENAME)
|
||||||
|
)
|
||||||
|
|
||||||
return unload_ok
|
return unload_ok
|
||||||
|
Loading…
x
Reference in New Issue
Block a user