From 7410b8778a98d9d420edb7abed32476cf6ef8940 Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Fri, 16 May 2025 10:47:23 +0200 Subject: [PATCH] Deprecate DHW switch for SmartThings (#145011) --- .../components/smartthings/strings.json | 8 + .../components/smartthings/switch.py | 14 +- homeassistant/components/smartthings/util.py | 3 +- .../smartthings/snapshots/test_switch.ambr | 141 ------------------ tests/components/smartthings/test_switch.py | 20 ++- 5 files changed, 41 insertions(+), 145 deletions(-) diff --git a/homeassistant/components/smartthings/strings.json b/homeassistant/components/smartthings/strings.json index 66bb97e4f40..c2719c3e2f9 100644 --- a/homeassistant/components/smartthings/strings.json +++ b/homeassistant/components/smartthings/strings.json @@ -585,6 +585,14 @@ "title": "[%key:component::smartthings::issues::deprecated_switch_appliance::title%]", "description": "The switch `{entity_id}` is deprecated and a media player entity has been added to replace it.\n\nThe switch was used in the following automations or scripts:\n{items}\n\nPlease use the new media player entity in the above automations or scripts and disable the entity to fix this issue." }, + "deprecated_switch_dhw": { + "title": "Heat pump switch deprecated", + "description": "The switch `{entity_id}` is deprecated and a water heater entity has been added to replace it.\n\nPlease use the new water heater entity in the above automations or scripts and disable the entity to fix this issue." + }, + "deprecated_switch_dhw_scripts": { + "title": "[%key:component::smartthings::issues::deprecated_switch_dhw::title%]", + "description": "The switch `{entity_id}` is deprecated and a water heater entity has been added to replace it.\n\nThe switch was used in the following automations or scripts:\n{items}\n\nPlease use the new water heater entity in the above automations or scripts and disable the entity to fix this issue." + }, "deprecated_media_player": { "title": "Media player sensors deprecated", "description": "The sensor {entity_name} (`{entity_id}`) is deprecated because it has been replaced with a media player entity.\n\nPlease update your dashboards, templates to use the new media player entity and disable the entity to fix this issue." diff --git a/homeassistant/components/smartthings/switch.py b/homeassistant/components/smartthings/switch.py index 56e67ad2a13..f610a97f16e 100644 --- a/homeassistant/components/smartthings/switch.py +++ b/homeassistant/components/smartthings/switch.py @@ -152,14 +152,24 @@ async def async_setup_entry( device.device.components[MAIN].manufacturer_category in INVALID_SWITCH_CATEGORIES ) - if media_player or appliance: - issue = "media_player" if media_player else "appliance" + dhw = Capability.SAMSUNG_CE_EHS_FSV_SETTINGS in device.status[MAIN] + if media_player or appliance or dhw: + if appliance: + issue = "appliance" + version = "2025.10.0" + elif media_player: + issue = "media_player" + version = "2025.10.0" + else: + issue = "dhw" + version = "2025.12.0" if deprecate_entity( hass, entity_registry, SWITCH_DOMAIN, f"{device.device.device_id}_{MAIN}_{Capability.SWITCH}_{Attribute.SWITCH}_{Attribute.SWITCH}", f"deprecated_switch_{issue}", + version, ): entities.append( SmartThingsSwitch( diff --git a/homeassistant/components/smartthings/util.py b/homeassistant/components/smartthings/util.py index b21652ca629..7d74e22477f 100644 --- a/homeassistant/components/smartthings/util.py +++ b/homeassistant/components/smartthings/util.py @@ -19,6 +19,7 @@ def deprecate_entity( platform_domain: str, entity_unique_id: str, issue_string: str, + version: str = "2025.10.0", ) -> bool: """Create an issue for deprecated entities.""" if entity_id := entity_registry.async_get_entity_id( @@ -51,7 +52,7 @@ def deprecate_entity( hass, DOMAIN, f"{issue_string}_{entity_id}", - breaks_in_ha_version="2025.10.0", + breaks_in_ha_version=version, is_fixable=False, severity=IssueSeverity.WARNING, translation_key=translation_key, diff --git a/tests/components/smartthings/snapshots/test_switch.ambr b/tests/components/smartthings/snapshots/test_switch.ambr index d43fa207ddf..060f1d3a374 100644 --- a/tests/components/smartthings/snapshots/test_switch.ambr +++ b/tests/components/smartthings/snapshots/test_switch.ambr @@ -46,53 +46,6 @@ 'state': 'on', }) # --- -# name: test_all_entities[da_ac_ehs_01001][switch.heat_pump-entry] - EntityRegistryEntrySnapshot({ - 'aliases': set({ - }), - 'area_id': None, - 'capabilities': None, - 'config_entry_id': , - 'config_subentry_id': , - 'device_class': None, - 'device_id': , - 'disabled_by': None, - 'domain': 'switch', - 'entity_category': None, - 'entity_id': 'switch.heat_pump', - 'has_entity_name': True, - 'hidden_by': None, - 'icon': None, - 'id': , - 'labels': set({ - }), - 'name': None, - 'options': dict({ - }), - 'original_device_class': None, - 'original_icon': None, - 'original_name': None, - 'platform': 'smartthings', - 'previous_unique_id': None, - 'supported_features': 0, - 'translation_key': None, - 'unique_id': '4165c51e-bf6b-c5b6-fd53-127d6248754b_main_switch_switch_switch', - 'unit_of_measurement': None, - }) -# --- -# name: test_all_entities[da_ac_ehs_01001][switch.heat_pump-state] - StateSnapshot({ - 'attributes': ReadOnlyDict({ - 'friendly_name': 'Heat pump', - }), - 'context': , - 'entity_id': 'switch.heat_pump', - 'last_changed': , - 'last_reported': , - 'last_updated': , - 'state': 'off', - }) -# --- # name: test_all_entities[da_ref_normal_000001][switch.refrigerator_ice_maker-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ @@ -281,100 +234,6 @@ 'state': 'off', }) # --- -# name: test_all_entities[da_sac_ehs_000001_sub][switch.eco_heating_system-entry] - EntityRegistryEntrySnapshot({ - 'aliases': set({ - }), - 'area_id': None, - 'capabilities': None, - 'config_entry_id': , - 'config_subentry_id': , - 'device_class': None, - 'device_id': , - 'disabled_by': None, - 'domain': 'switch', - 'entity_category': None, - 'entity_id': 'switch.eco_heating_system', - 'has_entity_name': True, - 'hidden_by': None, - 'icon': None, - 'id': , - 'labels': set({ - }), - 'name': None, - 'options': dict({ - }), - 'original_device_class': None, - 'original_icon': None, - 'original_name': None, - 'platform': 'smartthings', - 'previous_unique_id': None, - 'supported_features': 0, - 'translation_key': None, - 'unique_id': '1f98ebd0-ac48-d802-7f62-000001200100_main_switch_switch_switch', - 'unit_of_measurement': None, - }) -# --- -# name: test_all_entities[da_sac_ehs_000001_sub][switch.eco_heating_system-state] - StateSnapshot({ - 'attributes': ReadOnlyDict({ - 'friendly_name': 'Eco Heating System', - }), - 'context': , - 'entity_id': 'switch.eco_heating_system', - 'last_changed': , - 'last_reported': , - 'last_updated': , - 'state': 'off', - }) -# --- -# name: test_all_entities[da_sac_ehs_000002_sub][switch.warmepumpe-entry] - EntityRegistryEntrySnapshot({ - 'aliases': set({ - }), - 'area_id': None, - 'capabilities': None, - 'config_entry_id': , - 'config_subentry_id': , - 'device_class': None, - 'device_id': , - 'disabled_by': None, - 'domain': 'switch', - 'entity_category': None, - 'entity_id': 'switch.warmepumpe', - 'has_entity_name': True, - 'hidden_by': None, - 'icon': None, - 'id': , - 'labels': set({ - }), - 'name': None, - 'options': dict({ - }), - 'original_device_class': None, - 'original_icon': None, - 'original_name': None, - 'platform': 'smartthings', - 'previous_unique_id': None, - 'supported_features': 0, - 'translation_key': None, - 'unique_id': '3810e5ad-5351-d9f9-12ff-000001200000_main_switch_switch_switch', - 'unit_of_measurement': None, - }) -# --- -# name: test_all_entities[da_sac_ehs_000002_sub][switch.warmepumpe-state] - StateSnapshot({ - 'attributes': ReadOnlyDict({ - 'friendly_name': 'Wärmepumpe', - }), - 'context': , - 'entity_id': 'switch.warmepumpe', - 'last_changed': , - 'last_reported': , - 'last_updated': , - 'state': 'on', - }) -# --- # name: test_all_entities[da_wm_wd_000001][switch.dryer_wrinkle_prevent-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ diff --git a/tests/components/smartthings/test_switch.py b/tests/components/smartthings/test_switch.py index 0f759d8e6b5..2be2c670faf 100644 --- a/tests/components/smartthings/test_switch.py +++ b/tests/components/smartthings/test_switch.py @@ -280,61 +280,77 @@ async def test_create_issue_with_items( @pytest.mark.parametrize( - ("device_fixture", "device_id", "suggested_object_id", "issue_string"), + ("device_fixture", "device_id", "suggested_object_id", "issue_string", "version"), [ ( "da_ks_cooktop_31001", "808dbd84-f357-47e2-a0cd-3b66fa22d584", "induction_hob", "appliance", + "2025.10.0", ), ( "da_ks_microwave_0101x", "2bad3237-4886-e699-1b90-4a51a3d55c8a", "microwave", "appliance", + "2025.10.0", ), ( "da_wm_dw_000001", "f36dc7ce-cac0-0667-dc14-a3704eb5e676", "dishwasher", "appliance", + "2025.10.0", ), ( "da_wm_sc_000001", "b93211bf-9d96-bd21-3b2f-964fcc87f5cc", "airdresser", "appliance", + "2025.10.0", ), ( "da_wm_wd_000001", "02f7256e-8353-5bdd-547f-bd5b1647e01b", "dryer", "appliance", + "2025.10.0", ), ( "da_wm_wm_000001", "f984b91d-f250-9d42-3436-33f09a422a47", "washer", "appliance", + "2025.10.0", ), ( "hw_q80r_soundbar", "afcf3b91-0000-1111-2222-ddff2a0a6577", "soundbar", "media_player", + "2025.10.0", ), ( "vd_network_audio_002s", "0d94e5db-8501-2355-eb4f-214163702cac", "soundbar_living", "media_player", + "2025.10.0", ), ( "vd_stv_2017_k", "4588d2d9-a8cf-40f4-9a0b-ed5dfbaccda1", "tv_samsung_8_series_49", "media_player", + "2025.10.0", + ), + ( + "da_sac_ehs_000002_sub", + "3810e5ad-5351-d9f9-12ff-000001200000", + "warmepumpe", + "dhw", + "2025.12.0", ), ], ) @@ -347,6 +363,7 @@ async def test_create_issue( device_id: str, suggested_object_id: str, issue_string: str, + version: str, ) -> None: """Test we create an issue when an automation or script is using a deprecated entity.""" entity_id = f"switch.{suggested_object_id}" @@ -372,6 +389,7 @@ async def test_create_issue( "entity_id": entity_id, "entity_name": suggested_object_id, } + assert issue.breaks_in_ha_version == version entity_registry.async_update_entity( entity_entry.entity_id,