diff --git a/homeassistant/components/reolink/strings.json b/homeassistant/components/reolink/strings.json index d9bcc80406f3..dda68c6b4ad4 100644 --- a/homeassistant/components/reolink/strings.json +++ b/homeassistant/components/reolink/strings.json @@ -132,10 +132,6 @@ "title": "Reolink firmware update required", "description": "\"{name}\" with model \"{model}\" and hardware version \"{hw_version}\" is running an old firmware version \"{current_firmware}\", while at least firmware version \"{required_firmware}\" is required for proper operation of the Reolink integration. The firmware can be updated by pressing \"install\" in the more info dialog of the update entity of \"{name}\" from within Home Assistant. Alternatively, the latest firmware can be downloaded from the [Reolink download center]({download_link})." }, - "hub_switch_deprecated": { - "title": "Reolink Home Hub switches deprecated", - "description": "The redundant 'Record', 'Email on event', 'FTP upload', 'Push notifications', and 'Buzzer on event' switches on the Reolink Home Hub are deprecated since the new firmware no longer supports these. Please use the equally named switches under each of the camera devices connected to the Home Hub instead. To remove this issue, please adjust automations accordingly and disable the switch entities mentioned." - }, "password_too_long": { "title": "Reolink password too long", "description": "The password for \"{name}\" is more than 31 characters long, this is no longer compatible with the Reolink API. Please change the password using the Reolink app/client to a password with is shorter than 32 characters. After changing the password, fill in the new password in the Reolink Re-authentication flow to continue using this integration. The latest version of the Reolink app/client also has a password limit of 31 characters." diff --git a/homeassistant/components/reolink/switch.py b/homeassistant/components/reolink/switch.py index d5f45872661e..8431d7afb2a3 100644 --- a/homeassistant/components/reolink/switch.py +++ b/homeassistant/components/reolink/switch.py @@ -11,10 +11,8 @@ from reolink_aio.api import Chime, Host 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, issue_registry as ir from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback -from .const import DOMAIN from .entity import ( ReolinkChannelCoordinatorEntity, ReolinkChannelEntityDescription, @@ -306,56 +304,6 @@ CHIME_SWITCH_ENTITIES = ( ), ) -# Can be removed in HA 2025.4.0 -DEPRECATED_NVR_SWITCHES = [ - ReolinkNVRSwitchEntityDescription( - key="email", - cmd_key="GetEmail", - translation_key="email", - entity_category=EntityCategory.CONFIG, - supported=lambda api: api.is_hub, - value=lambda api: api.email_enabled(), - method=lambda api, value: api.set_email(None, value), - ), - ReolinkNVRSwitchEntityDescription( - key="ftp_upload", - cmd_key="GetFtp", - translation_key="ftp_upload", - entity_category=EntityCategory.CONFIG, - supported=lambda api: api.is_hub, - value=lambda api: api.ftp_enabled(), - method=lambda api, value: api.set_ftp(None, value), - ), - ReolinkNVRSwitchEntityDescription( - key="push_notifications", - cmd_key="GetPush", - translation_key="push_notifications", - entity_category=EntityCategory.CONFIG, - supported=lambda api: api.is_hub, - value=lambda api: api.push_enabled(), - method=lambda api, value: api.set_push(None, value), - ), - ReolinkNVRSwitchEntityDescription( - key="record", - cmd_key="GetRec", - translation_key="record", - entity_category=EntityCategory.CONFIG, - supported=lambda api: api.is_hub, - value=lambda api: api.recording_enabled(), - method=lambda api, value: api.set_recording(None, value), - ), - ReolinkNVRSwitchEntityDescription( - key="buzzer", - cmd_key="GetBuzzerAlarmV20", - translation_key="hub_ringtone_on_event", - icon="mdi:room-service", - entity_category=EntityCategory.CONFIG, - supported=lambda api: api.is_hub, - value=lambda api: api.buzzer_enabled(), - method=lambda api, value: api.set_buzzer(None, value), - ), -] - async def async_setup_entry( hass: HomeAssistant, @@ -389,34 +337,6 @@ async def async_setup_entry( if chime.channel is None ) - # Can be removed in HA 2025.4.0 - depricated_dict = {} - for desc in DEPRECATED_NVR_SWITCHES: - if not desc.supported(reolink_data.host.api): - continue - depricated_dict[f"{reolink_data.host.unique_id}_{desc.key}"] = desc - - entity_reg = er.async_get(hass) - reg_entities = er.async_entries_for_config_entry(entity_reg, config_entry.entry_id) - for entity in reg_entities: - # Can be removed in HA 2025.4.0 - if entity.domain == "switch" and entity.unique_id in depricated_dict: - if entity.disabled: - entity_reg.async_remove(entity.entity_id) - continue - - ir.async_create_issue( - hass, - DOMAIN, - "hub_switch_deprecated", - is_fixable=False, - severity=ir.IssueSeverity.WARNING, - translation_key="hub_switch_deprecated", - ) - entities.append( - ReolinkNVRSwitchEntity(reolink_data, depricated_dict[entity.unique_id]) - ) - async_add_entities(entities) diff --git a/tests/components/reolink/test_switch.py b/tests/components/reolink/test_switch.py index 97dfc622aed0..83840cace977 100644 --- a/tests/components/reolink/test_switch.py +++ b/tests/components/reolink/test_switch.py @@ -8,7 +8,6 @@ from reolink_aio.api import Chime from reolink_aio.exceptions import ReolinkError from homeassistant.components.reolink import DEVICE_UPDATE_INTERVAL -from homeassistant.components.reolink.const import DOMAIN from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN from homeassistant.config_entries import ConfigEntryState from homeassistant.const import ( @@ -22,9 +21,8 @@ from homeassistant.const import ( ) from homeassistant.core import HomeAssistant from homeassistant.exceptions import HomeAssistantError -from homeassistant.helpers import entity_registry as er, issue_registry as ir -from .conftest import TEST_CAM_NAME, TEST_NVR_NAME, TEST_UID +from .conftest import TEST_CAM_NAME, TEST_NVR_NAME from tests.common import MockConfigEntry, async_fire_time_changed @@ -228,141 +226,3 @@ async def test_chime_switch( {ATTR_ENTITY_ID: entity_id}, blocking=True, ) - - -@pytest.mark.parametrize( - ( - "original_id", - "capability", - ), - [ - ( - f"{TEST_UID}_record", - "recording", - ), - ( - f"{TEST_UID}_ftp_upload", - "ftp", - ), - ( - f"{TEST_UID}_push_notifications", - "push", - ), - ( - f"{TEST_UID}_email", - "email", - ), - ( - f"{TEST_UID}_buzzer", - "buzzer", - ), - ], -) -async def test_cleanup_hub_switches( - hass: HomeAssistant, - config_entry: MockConfigEntry, - reolink_host: MagicMock, - entity_registry: er.EntityRegistry, - original_id: str, - capability: str, -) -> None: - """Test entity ids that need to be migrated.""" - - def mock_supported(ch, cap): - if cap == capability: - return False - return True - - domain = Platform.SWITCH - - reolink_host.channels = [0] - reolink_host.is_hub = True - reolink_host.supported = mock_supported - - entity_registry.async_get_or_create( - domain=domain, - platform=DOMAIN, - unique_id=original_id, - config_entry=config_entry, - suggested_object_id=original_id, - disabled_by=er.RegistryEntryDisabler.USER, - ) - - assert entity_registry.async_get_entity_id(domain, DOMAIN, original_id) - - # setup CH 0 and host entities/device - with patch("homeassistant.components.reolink.PLATFORMS", [domain]): - assert await hass.config_entries.async_setup(config_entry.entry_id) - await hass.async_block_till_done() - - assert entity_registry.async_get_entity_id(domain, DOMAIN, original_id) is None - - -@pytest.mark.parametrize( - ( - "original_id", - "capability", - ), - [ - ( - f"{TEST_UID}_record", - "recording", - ), - ( - f"{TEST_UID}_ftp_upload", - "ftp", - ), - ( - f"{TEST_UID}_push_notifications", - "push", - ), - ( - f"{TEST_UID}_email", - "email", - ), - ( - f"{TEST_UID}_buzzer", - "buzzer", - ), - ], -) -async def test_hub_switches_repair_issue( - hass: HomeAssistant, - config_entry: MockConfigEntry, - reolink_host: MagicMock, - entity_registry: er.EntityRegistry, - issue_registry: ir.IssueRegistry, - original_id: str, - capability: str, -) -> None: - """Test entity ids that need to be migrated.""" - - def mock_supported(ch, cap): - if cap == capability: - return False - return True - - domain = Platform.SWITCH - - reolink_host.channels = [0] - reolink_host.is_hub = True - reolink_host.supported = mock_supported - - entity_registry.async_get_or_create( - domain=domain, - platform=DOMAIN, - unique_id=original_id, - config_entry=config_entry, - suggested_object_id=original_id, - disabled_by=None, - ) - - assert entity_registry.async_get_entity_id(domain, DOMAIN, original_id) - - # setup CH 0 and host entities/device - with patch("homeassistant.components.reolink.PLATFORMS", [domain]): - assert await hass.config_entries.async_setup(config_entry.entry_id) - await hass.async_block_till_done() - - assert entity_registry.async_get_entity_id(domain, DOMAIN, original_id) - assert (DOMAIN, "hub_switch_deprecated") in issue_registry.issues