Add ability to forget hive device when removing integration (#74144)

This commit is contained in:
Khole 2022-06-30 22:47:02 +01:00 committed by GitHub
parent 269fa14721
commit 4f842014ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 1 deletions

View File

@ -7,7 +7,7 @@ import logging
from typing import Any, TypeVar
from aiohttp.web_exceptions import HTTPException
from apyhiveapi import Hive
from apyhiveapi import Auth, Hive
from apyhiveapi.helper.hive_exceptions import HiveReauthRequired
from typing_extensions import Concatenate, ParamSpec
import voluptuous as vol
@ -112,6 +112,15 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
return unload_ok
async def async_remove_entry(hass: HomeAssistant, entry: ConfigEntry) -> None:
"""Remove a config entry."""
hive = Auth(entry.data["username"], entry.data["password"])
await hive.forget_device(
entry.data["tokens"]["AuthenticationResult"]["AccessToken"],
entry.data["device_data"][1],
)
def refresh_system(
func: Callable[Concatenate[_HiveEntityT, _P], Awaitable[Any]]
) -> Callable[Concatenate[_HiveEntityT, _P], Coroutine[Any, Any, None]]: