diff --git a/homeassistant/components/smartthings/icons.json b/homeassistant/components/smartthings/icons.json index 15526dc7d88..f1034d1a55f 100644 --- a/homeassistant/components/smartthings/icons.json +++ b/homeassistant/components/smartthings/icons.json @@ -112,6 +112,12 @@ "ice_maker": { "default": "mdi:delete-variant" }, + "power_cool": { + "default": "mdi:snowflake-alert" + }, + "power_freeze": { + "default": "mdi:snowflake" + }, "sanitize": { "default": "mdi:lotion" }, diff --git a/homeassistant/components/smartthings/strings.json b/homeassistant/components/smartthings/strings.json index 2ce72dc0c95..27c0eafe811 100644 --- a/homeassistant/components/smartthings/strings.json +++ b/homeassistant/components/smartthings/strings.json @@ -578,6 +578,12 @@ "sabbath_mode": { "name": "Sabbath mode" }, + "power_cool": { + "name": "Power cool" + }, + "power_freeze": { + "name": "Power freeze" + }, "auto_cycle_link": { "name": "Auto cycle link" }, diff --git a/homeassistant/components/smartthings/switch.py b/homeassistant/components/smartthings/switch.py index 61ebc56699b..56096dc6ab5 100644 --- a/homeassistant/components/smartthings/switch.py +++ b/homeassistant/components/smartthings/switch.py @@ -48,6 +48,9 @@ class SmartThingsSwitchEntityDescription(SwitchEntityDescription): status_attribute: Attribute component_translation_key: dict[str, str] | None = None + on_key: str = "on" + on_command: Command = Command.ON + off_command: Command = Command.OFF @dataclass(frozen=True, kw_only=True) @@ -98,6 +101,25 @@ CAPABILITY_TO_SWITCHES: dict[Capability | str, SmartThingsSwitchEntityDescriptio key=Capability.SAMSUNG_CE_SABBATH_MODE, translation_key="sabbath_mode", status_attribute=Attribute.STATUS, + entity_category=EntityCategory.CONFIG, + ), + Capability.SAMSUNG_CE_POWER_COOL: SmartThingsSwitchEntityDescription( + key=Capability.SAMSUNG_CE_POWER_COOL, + translation_key="power_cool", + status_attribute=Attribute.ACTIVATED, + on_key="True", + on_command=Command.ACTIVATE, + off_command=Command.DEACTIVATE, + entity_category=EntityCategory.CONFIG, + ), + Capability.SAMSUNG_CE_POWER_FREEZE: SmartThingsSwitchEntityDescription( + key=Capability.SAMSUNG_CE_POWER_FREEZE, + translation_key="power_freeze", + status_attribute=Attribute.ACTIVATED, + on_key="True", + on_command=Command.ACTIVATE, + off_command=Command.DEACTIVATE, + entity_category=EntityCategory.CONFIG, ), Capability.SAMSUNG_CE_STEAM_CLOSET_SANITIZE_MODE: SmartThingsSwitchEntityDescription( key=Capability.SAMSUNG_CE_STEAM_CLOSET_SANITIZE_MODE, @@ -239,14 +261,14 @@ class SmartThingsSwitch(SmartThingsEntity, SwitchEntity): """Turn the switch off.""" await self.execute_device_command( self.switch_capability, - Command.OFF, + self.entity_description.off_command, ) async def async_turn_on(self, **kwargs: Any) -> None: """Turn the switch on.""" await self.execute_device_command( self.switch_capability, - Command.ON, + self.entity_description.on_command, ) @property @@ -256,7 +278,7 @@ class SmartThingsSwitch(SmartThingsEntity, SwitchEntity): self.get_attribute_value( self.switch_capability, self.entity_description.status_attribute ) - == "on" + == self.entity_description.on_key ) diff --git a/tests/components/smartthings/fixtures/device_status/da_ref_normal_000001.json b/tests/components/smartthings/fixtures/device_status/da_ref_normal_000001.json index 0c5a883b4f9..57dba2e0259 100644 --- a/tests/components/smartthings/fixtures/device_status/da_ref_normal_000001.json +++ b/tests/components/smartthings/fixtures/device_status/da_ref_normal_000001.json @@ -574,7 +574,7 @@ }, "samsungce.powerCool": { "activated": { - "value": false, + "value": true, "timestamp": "2025-01-19T21:07:55.725Z" } }, diff --git a/tests/components/smartthings/snapshots/test_switch.ambr b/tests/components/smartthings/snapshots/test_switch.ambr index be9253dd388..6d0be8b3c89 100644 --- a/tests/components/smartthings/snapshots/test_switch.ambr +++ b/tests/components/smartthings/snapshots/test_switch.ambr @@ -93,6 +93,100 @@ 'state': 'off', }) # --- +# name: test_all_entities[da_ref_normal_000001][switch.refrigerator_power_cool-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': , + 'entity_id': 'switch.refrigerator_power_cool', + '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': 'Power cool', + 'platform': 'smartthings', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'power_cool', + 'unique_id': '7db87911-7dce-1cf2-7119-b953432a2f09_main_samsungce.powerCool_activated_activated', + 'unit_of_measurement': None, + }) +# --- +# name: test_all_entities[da_ref_normal_000001][switch.refrigerator_power_cool-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'Refrigerator Power cool', + }), + 'context': , + 'entity_id': 'switch.refrigerator_power_cool', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'on', + }) +# --- +# name: test_all_entities[da_ref_normal_000001][switch.refrigerator_power_freeze-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': , + 'entity_id': 'switch.refrigerator_power_freeze', + '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': 'Power freeze', + 'platform': 'smartthings', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'power_freeze', + 'unique_id': '7db87911-7dce-1cf2-7119-b953432a2f09_main_samsungce.powerFreeze_activated_activated', + 'unit_of_measurement': None, + }) +# --- +# name: test_all_entities[da_ref_normal_000001][switch.refrigerator_power_freeze-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'Refrigerator Power freeze', + }), + 'context': , + 'entity_id': 'switch.refrigerator_power_freeze', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- # name: test_all_entities[da_ref_normal_000001][switch.refrigerator_sabbath_mode-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ @@ -105,7 +199,7 @@ 'device_id': , 'disabled_by': None, 'domain': 'switch', - 'entity_category': None, + 'entity_category': , 'entity_id': 'switch.refrigerator_sabbath_mode', 'has_entity_name': True, 'hidden_by': None, @@ -187,6 +281,194 @@ 'state': 'on', }) # --- +# name: test_all_entities[da_ref_normal_01001][switch.refrigerator_power_cool-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': , + 'entity_id': 'switch.refrigerator_power_cool', + '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': 'Power cool', + 'platform': 'smartthings', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'power_cool', + 'unique_id': '7d3feb98-8a36-4351-c362-5e21ad3a78dd_main_samsungce.powerCool_activated_activated', + 'unit_of_measurement': None, + }) +# --- +# name: test_all_entities[da_ref_normal_01001][switch.refrigerator_power_cool-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'Refrigerator Power cool', + }), + 'context': , + 'entity_id': 'switch.refrigerator_power_cool', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- +# name: test_all_entities[da_ref_normal_01001][switch.refrigerator_power_freeze-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': , + 'entity_id': 'switch.refrigerator_power_freeze', + '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': 'Power freeze', + 'platform': 'smartthings', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'power_freeze', + 'unique_id': '7d3feb98-8a36-4351-c362-5e21ad3a78dd_main_samsungce.powerFreeze_activated_activated', + 'unit_of_measurement': None, + }) +# --- +# name: test_all_entities[da_ref_normal_01001][switch.refrigerator_power_freeze-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'Refrigerator Power freeze', + }), + 'context': , + 'entity_id': 'switch.refrigerator_power_freeze', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- +# name: test_all_entities[da_ref_normal_01011][switch.frigo_power_cool-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': , + 'entity_id': 'switch.frigo_power_cool', + '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': 'Power cool', + 'platform': 'smartthings', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'power_cool', + 'unique_id': '5758b2ec-563e-f39b-ec39-208e54aabf60_main_samsungce.powerCool_activated_activated', + 'unit_of_measurement': None, + }) +# --- +# name: test_all_entities[da_ref_normal_01011][switch.frigo_power_cool-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'Frigo Power cool', + }), + 'context': , + 'entity_id': 'switch.frigo_power_cool', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- +# name: test_all_entities[da_ref_normal_01011][switch.frigo_power_freeze-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': , + 'entity_id': 'switch.frigo_power_freeze', + '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': 'Power freeze', + 'platform': 'smartthings', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'power_freeze', + 'unique_id': '5758b2ec-563e-f39b-ec39-208e54aabf60_main_samsungce.powerFreeze_activated_activated', + 'unit_of_measurement': None, + }) +# --- +# name: test_all_entities[da_ref_normal_01011][switch.frigo_power_freeze-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'Frigo Power freeze', + }), + 'context': , + 'entity_id': 'switch.frigo_power_freeze', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- # name: test_all_entities[da_rvc_normal_000001][switch.robot_vacuum-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ diff --git a/tests/components/smartthings/test_switch.py b/tests/components/smartthings/test_switch.py index 09f710366d0..59790abe07d 100644 --- a/tests/components/smartthings/test_switch.py +++ b/tests/components/smartthings/test_switch.py @@ -110,6 +110,38 @@ async def test_command_switch_turn_on_off( ) +@pytest.mark.parametrize("device_fixture", ["da_ref_normal_000001"]) +@pytest.mark.parametrize( + ("action", "command"), + [ + (SERVICE_TURN_ON, Command.ACTIVATE), + (SERVICE_TURN_OFF, Command.DEACTIVATE), + ], +) +async def test_custom_commands( + hass: HomeAssistant, + devices: AsyncMock, + mock_config_entry: MockConfigEntry, + action: str, + command: Command, +) -> None: + """Test switch turn on and off command.""" + await setup_integration(hass, mock_config_entry) + + await hass.services.async_call( + SWITCH_DOMAIN, + action, + {ATTR_ENTITY_ID: "switch.refrigerator_power_cool"}, + blocking=True, + ) + devices.execute_device_command.assert_called_once_with( + "7db87911-7dce-1cf2-7119-b953432a2f09", + Capability.SAMSUNG_CE_POWER_COOL, + command, + MAIN, + ) + + @pytest.mark.parametrize("device_fixture", ["c2c_arlo_pro_3_switch"]) async def test_state_update( hass: HomeAssistant,