From 683cc61415ffe9db37205c7dc9f4b7bb06d1e577 Mon Sep 17 00:00:00 2001 From: Paul Bottein Date: Mon, 8 Jun 2026 20:41:36 +0200 Subject: [PATCH] Remove async_remove_config_entry_device from Yoto The coordinator already removes players that left the account, so this handler could never allow a deletion. Automatic removal alone satisfies the stale-devices rule. --- homeassistant/components/yoto/__init__.py | 14 ------------- tests/components/yoto/test_init.py | 24 ----------------------- 2 files changed, 38 deletions(-) diff --git a/homeassistant/components/yoto/__init__.py b/homeassistant/components/yoto/__init__.py index 55e660fea23..efa7898eec5 100644 --- a/homeassistant/components/yoto/__init__.py +++ b/homeassistant/components/yoto/__init__.py @@ -5,7 +5,6 @@ import aiohttp from homeassistant.const import Platform from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryNotReady, OAuth2TokenRequestError -from homeassistant.helpers import device_registry as dr from homeassistant.helpers.config_entry_oauth2_flow import ( ImplementationUnavailableError, OAuth2Session, @@ -44,16 +43,3 @@ async def async_setup_entry(hass: HomeAssistant, entry: YotoConfigEntry) -> bool async def async_unload_entry(hass: HomeAssistant, entry: YotoConfigEntry) -> bool: """Unload a Yoto config entry.""" return await hass.config_entries.async_unload_platforms(entry, PLATFORMS) - - -async def async_remove_config_entry_device( - hass: HomeAssistant, - entry: YotoConfigEntry, - device_entry: dr.DeviceEntry, -) -> bool: - """Allow deleting a device whose player is no longer in the account.""" - coordinator = entry.runtime_data - return not any( - identifier[0] == DOMAIN and identifier[1] in coordinator.data - for identifier in device_entry.identifiers - ) diff --git a/tests/components/yoto/test_init.py b/tests/components/yoto/test_init.py index ff4079fa15d..28d05f02c24 100644 --- a/tests/components/yoto/test_init.py +++ b/tests/components/yoto/test_init.py @@ -7,7 +7,6 @@ from freezegun.api import FrozenDateTimeFactory import pytest from yoto_api import Device, YotoAPIError, YotoError, YotoPlayer -from homeassistant.components.yoto import async_remove_config_entry_device from homeassistant.components.yoto.const import ( DOMAIN, SCAN_INTERVAL, @@ -294,26 +293,3 @@ async def test_stale_device_removed( assert device_registry.async_get_device(identifiers={(DOMAIN, PLAYER_ID)}) is None mock_yoto_client.unsubscribe_player_events.assert_called_once_with(PLAYER_ID) - - -async def test_remove_config_entry_device( - hass: HomeAssistant, - mock_yoto_client: MagicMock, - mock_config_entry: MockConfigEntry, - device_registry: dr.DeviceRegistry, -) -> None: - """A device is removable only once its player is gone from the account.""" - await setup_integration(hass, mock_config_entry) - - present = device_registry.async_get_device(identifiers={(DOMAIN, PLAYER_ID)}) - assert present is not None - assert ( - await async_remove_config_entry_device(hass, mock_config_entry, present) - is False - ) - - gone = device_registry.async_get_or_create( - config_entry_id=mock_config_entry.entry_id, - identifiers={(DOMAIN, "gone-player")}, - ) - assert await async_remove_config_entry_device(hass, mock_config_entry, gone) is True