From 4f842014ee96506c3198a2da373b91067b8eec9d Mon Sep 17 00:00:00 2001 From: Khole Date: Thu, 30 Jun 2022 22:47:02 +0100 Subject: [PATCH] Add ability to forget hive device when removing integration (#74144) --- homeassistant/components/hive/__init__.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/hive/__init__.py b/homeassistant/components/hive/__init__.py index 52cf7f719e6..3693f0183ce 100644 --- a/homeassistant/components/hive/__init__.py +++ b/homeassistant/components/hive/__init__.py @@ -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]]: