diff --git a/homeassistant/components/litterrobot/strings.json b/homeassistant/components/litterrobot/strings.json index b8de1c2b742b..8efa6476a85d 100644 --- a/homeassistant/components/litterrobot/strings.json +++ b/homeassistant/components/litterrobot/strings.json @@ -218,12 +218,6 @@ "message": "Invalid credentials. Please check your username and password, then try again" } }, - "issues": { - "deprecated_entity": { - "description": "The Litter-Robot entity `{entity}` is deprecated and will be removed in a future release.\nPlease update your dashboards, automations and scripts, disable `{entity}` and reload the integration/restart Home Assistant to fix this issue.", - "title": "{name} is deprecated" - } - }, "services": { "set_sleep_mode": { "description": "Sets the sleep mode and start time.", diff --git a/homeassistant/components/litterrobot/switch.py b/homeassistant/components/litterrobot/switch.py index 5015ee895586..08e02189028e 100644 --- a/homeassistant/components/litterrobot/switch.py +++ b/homeassistant/components/litterrobot/switch.py @@ -6,24 +6,13 @@ from collections.abc import Callable, Coroutine from dataclasses import dataclass from typing import Any, Generic -from pylitterbot import FeederRobot, LitterRobot, LitterRobot3, LitterRobot4, Robot +from pylitterbot import FeederRobot, LitterRobot, LitterRobot3, Robot -from homeassistant.components.switch import ( - DOMAIN as SWITCH_DOMAIN, - SwitchEntity, - SwitchEntityDescription, -) +from homeassistant.components.switch import SwitchEntity, SwitchEntityDescription from homeassistant.const import EntityCategory from homeassistant.core import HomeAssistant -from homeassistant.helpers import entity_registry as er from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback -from homeassistant.helpers.issue_registry import ( - IssueSeverity, - async_create_issue, - async_delete_issue, -) -from .const import DOMAIN from .coordinator import LitterRobotConfigEntry from .entity import LitterRobotEntity, _WhiskerEntityT, whisker_command @@ -77,54 +66,13 @@ async def async_setup_entry( ) -> None: """Set up Litter-Robot switches using config entry.""" coordinator = entry.runtime_data - entities = [ + async_add_entities( RobotSwitchEntity(robot=robot, coordinator=coordinator, description=description) for robot in coordinator.account.robots for robot_type, entity_descriptions in SWITCH_MAP.items() if isinstance(robot, robot_type) for description in entity_descriptions - ] - - ent_reg = er.async_get(hass) - - def add_deprecated_entity( - robot: LitterRobot4, - description: RobotSwitchEntityDescription, - entity_cls: type[RobotSwitchEntity], - ) -> None: - """Add deprecated entities.""" - unique_id = f"{robot.serial}-{description.key}" - if entity_id := ent_reg.async_get_entity_id(SWITCH_DOMAIN, DOMAIN, unique_id): - entity_entry = ent_reg.async_get(entity_id) - if entity_entry and entity_entry.disabled: - ent_reg.async_remove(entity_id) - async_delete_issue( - hass, - DOMAIN, - f"deprecated_entity_{unique_id}", - ) - elif entity_entry: - entities.append(entity_cls(robot, coordinator, description)) - async_create_issue( - hass, - DOMAIN, - f"deprecated_entity_{unique_id}", - breaks_in_ha_version="2026.4.0", - is_fixable=False, - severity=IssueSeverity.WARNING, - translation_key="deprecated_entity", - translation_placeholders={ - "name": f"{robot.name} {entity_entry.name or entity_entry.original_name}", - "entity": entity_id, - }, - ) - - for robot in coordinator.account.get_robots(LitterRobot4): - add_deprecated_entity( - robot, NIGHT_LIGHT_MODE_ENTITY_DESCRIPTION, RobotSwitchEntity - ) - - async_add_entities(entities) + ) class RobotSwitchEntity(LitterRobotEntity[_WhiskerEntityT], SwitchEntity): diff --git a/tests/components/litterrobot/test_switch.py b/tests/components/litterrobot/test_switch.py index 82bc8fb5156c..e61ce16abeae 100644 --- a/tests/components/litterrobot/test_switch.py +++ b/tests/components/litterrobot/test_switch.py @@ -5,7 +5,6 @@ from unittest.mock import MagicMock from pylitterbot import FeederRobot, Robot import pytest -from homeassistant.components.litterrobot import DOMAIN from homeassistant.components.switch import ( DOMAIN as SWITCH_DOMAIN, SERVICE_TURN_OFF, @@ -14,7 +13,7 @@ from homeassistant.components.switch import ( from homeassistant.const import ATTR_ENTITY_ID, STATE_OFF, STATE_ON, EntityCategory from homeassistant.core import HomeAssistant from homeassistant.exceptions import HomeAssistantError -from homeassistant.helpers import entity_registry as er, issue_registry as ir +from homeassistant.helpers import entity_registry as er from .conftest import setup_integration @@ -94,50 +93,6 @@ async def test_feeder_robot_switch( assert state.state == new_state -@pytest.mark.parametrize( - ("preexisting_entity", "disabled_by", "expected_entity", "expected_issue"), - [ - (True, None, True, True), - (True, er.RegistryEntryDisabler.USER, False, False), - (False, None, False, False), - ], -) -async def test_litterrobot_4_deprecated_switch( - hass: HomeAssistant, - mock_account_with_litterrobot_4: MagicMock, - issue_registry: ir.IssueRegistry, - entity_registry: er.EntityRegistry, - preexisting_entity: bool, - disabled_by: er.RegistryEntryDisabler, - expected_entity: bool, - expected_issue: bool, -) -> None: - """Test switch deprecation issue.""" - entity_uid = "LR4C010001-night_light_mode_enabled" - if preexisting_entity: - suggested_id = NIGHT_LIGHT_MODE_ENTITY_ID.replace(f"{SWITCH_DOMAIN}.", "") - entity_registry.async_get_or_create( - SWITCH_DOMAIN, - DOMAIN, - entity_uid, - suggested_object_id=suggested_id, - disabled_by=disabled_by, - ) - - await setup_integration(hass, mock_account_with_litterrobot_4, SWITCH_DOMAIN) - - assert ( - entity_registry.async_get(NIGHT_LIGHT_MODE_ENTITY_ID) is not None - ) is expected_entity - assert ( - issue_registry.async_get_issue( - domain=DOMAIN, - issue_id=f"deprecated_entity_{entity_uid}", - ) - is not None - ) is expected_issue - - async def test_switch_command_exception( hass: HomeAssistant, mock_account_with_side_effects: MagicMock ) -> None: