mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 19:57:07 +00:00
Deprecate SmartThings media player switch (#141467)
* Deprecate SmartThings media player switch * Fix * Fix * Update homeassistant/components/smartthings/strings.json Co-authored-by: Abílio Costa <abmantis@users.noreply.github.com> * Fix --------- Co-authored-by: Abílio Costa <abmantis@users.noreply.github.com>
This commit is contained in:
parent
fe99c39e25
commit
2e3853dd7d
@ -481,7 +481,7 @@
|
|||||||
"issues": {
|
"issues": {
|
||||||
"deprecated_binary_valve": {
|
"deprecated_binary_valve": {
|
||||||
"title": "Deprecated valve binary sensor detected in some automations or scripts",
|
"title": "Deprecated valve binary sensor detected in some automations or scripts",
|
||||||
"description": "The valve binary sensor `{entity}` is deprecated and is used in the following automations or scripts:\n{items}\n\nA valve entity with controls is available and should be used going forward. Please use it in the above automations or scripts to fix this issue."
|
"description": "The valve binary sensor `{entity}` is deprecated and is used in the following automations or scripts:\n{items}\n\nA valve entity with controls is available and should be used going forward. Please use the new valve entity in the above automations or scripts to fix this issue."
|
||||||
},
|
},
|
||||||
"deprecated_binary_fridge_door": {
|
"deprecated_binary_fridge_door": {
|
||||||
"title": "Deprecated refrigerator door binary sensor detected in some automations or scripts",
|
"title": "Deprecated refrigerator door binary sensor detected in some automations or scripts",
|
||||||
@ -489,15 +489,19 @@
|
|||||||
},
|
},
|
||||||
"deprecated_machine_state": {
|
"deprecated_machine_state": {
|
||||||
"title": "Deprecated machine state sensor detected in some automations or scripts",
|
"title": "Deprecated machine state sensor detected in some automations or scripts",
|
||||||
"description": "The machine state sensor `{entity}` is deprecated and is used in the following automations or scripts:\n{items}\n\nA select entity is now available for the machine state and should be used going forward. Please use them in the above automations or scripts to fix this issue."
|
"description": "The machine state sensor `{entity}` is deprecated and is used in the following automations or scripts:\n{items}\n\nA select entity is now available for the machine state and should be used going forward. Please use the new select entity in the above automations or scripts to fix this issue."
|
||||||
},
|
},
|
||||||
"deprecated_switch_appliance": {
|
"deprecated_switch_appliance": {
|
||||||
"title": "Deprecated switch detected in some automations or scripts",
|
"title": "Deprecated switch detected in some automations or scripts",
|
||||||
"description": "The switch `{entity}` is deprecated because the actions did not work, so it has been replaced with a binary sensor instead.\n\nThe switch was used in the following automations or scripts:\n{items}\n\nPlease use them in the above automations or scripts to fix this issue."
|
"description": "The switch `{entity}` is deprecated because the actions did not work, so it has been replaced with a binary sensor instead.\n\nThe switch was used in the following automations or scripts:\n{items}\n\nPlease use the new binary sensor in the above automations or scripts to fix this issue."
|
||||||
|
},
|
||||||
|
"deprecated_switch_media_player": {
|
||||||
|
"title": "[%key:component::smartthings::issues::deprecated_switch_appliance::title%]",
|
||||||
|
"description": "The switch `{entity}` 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 to fix this issue."
|
||||||
},
|
},
|
||||||
"deprecated_media_player": {
|
"deprecated_media_player": {
|
||||||
"title": "Deprecated sensor detected in some automations or scripts",
|
"title": "Deprecated sensor detected in some automations or scripts",
|
||||||
"description": "The sensor `{entity}` is deprecated because it has been replaced with a media player entity.\n\nThe sensor was used in the following automations or scripts:\n{items}\n\nPlease use the media player entity in the above automations or scripts to fix this issue."
|
"description": "The sensor `{entity}` is deprecated because it has been replaced with a media player entity.\n\nThe sensor was used in the following automations or scripts:\n{items}\n\nPlease use the new media player entity in the above automations or scripts to fix this issue."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,6 +136,7 @@ class SmartThingsSwitch(SmartThingsEntity, SwitchEntity):
|
|||||||
"""Define a SmartThings switch."""
|
"""Define a SmartThings switch."""
|
||||||
|
|
||||||
entity_description: SmartThingsSwitchEntityDescription
|
entity_description: SmartThingsSwitchEntityDescription
|
||||||
|
created_issue: bool = False
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@ -184,16 +185,26 @@ class SmartThingsSwitch(SmartThingsEntity, SwitchEntity):
|
|||||||
async def async_added_to_hass(self) -> None:
|
async def async_added_to_hass(self) -> None:
|
||||||
"""Call when entity is added to hass."""
|
"""Call when entity is added to hass."""
|
||||||
await super().async_added_to_hass()
|
await super().async_added_to_hass()
|
||||||
if self.entity_description != SWITCH or self.device.device.components[
|
media_player = all(
|
||||||
MAIN
|
capability in self.device.status[MAIN]
|
||||||
].manufacturer_category not in {
|
for capability in (
|
||||||
Category.CLOTHING_CARE_MACHINE,
|
Capability.AUDIO_MUTE,
|
||||||
Category.COOKTOP,
|
Capability.AUDIO_VOLUME,
|
||||||
Category.DRYER,
|
Capability.MEDIA_PLAYBACK,
|
||||||
Category.WASHER,
|
)
|
||||||
Category.MICROWAVE,
|
)
|
||||||
Category.DISHWASHER,
|
if (
|
||||||
}:
|
self.entity_description != SWITCH
|
||||||
|
and self.device.device.components[MAIN].manufacturer_category
|
||||||
|
not in {
|
||||||
|
Category.CLOTHING_CARE_MACHINE,
|
||||||
|
Category.COOKTOP,
|
||||||
|
Category.DRYER,
|
||||||
|
Category.WASHER,
|
||||||
|
Category.MICROWAVE,
|
||||||
|
Category.DISHWASHER,
|
||||||
|
}
|
||||||
|
) or (self.entity_description != SWITCH and not media_player):
|
||||||
return
|
return
|
||||||
automations = automations_with_entity(self.hass, self.entity_id)
|
automations = automations_with_entity(self.hass, self.entity_id)
|
||||||
scripts = scripts_with_entity(self.hass, self.entity_id)
|
scripts = scripts_with_entity(self.hass, self.entity_id)
|
||||||
@ -211,6 +222,9 @@ class SmartThingsSwitch(SmartThingsEntity, SwitchEntity):
|
|||||||
if (item := entity_reg.async_get(entity_id))
|
if (item := entity_reg.async_get(entity_id))
|
||||||
]
|
]
|
||||||
|
|
||||||
|
identifier = "media_player" if media_player else "appliance"
|
||||||
|
|
||||||
|
self.created_issue = True
|
||||||
async_create_issue(
|
async_create_issue(
|
||||||
self.hass,
|
self.hass,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
@ -218,7 +232,7 @@ class SmartThingsSwitch(SmartThingsEntity, SwitchEntity):
|
|||||||
breaks_in_ha_version="2025.10.0",
|
breaks_in_ha_version="2025.10.0",
|
||||||
is_fixable=False,
|
is_fixable=False,
|
||||||
severity=IssueSeverity.WARNING,
|
severity=IssueSeverity.WARNING,
|
||||||
translation_key="deprecated_switch_appliance",
|
translation_key=f"deprecated_switch_{identifier}",
|
||||||
translation_placeholders={
|
translation_placeholders={
|
||||||
"entity": self.entity_id,
|
"entity": self.entity_id,
|
||||||
"items": "\n".join(items_list),
|
"items": "\n".join(items_list),
|
||||||
@ -228,16 +242,7 @@ class SmartThingsSwitch(SmartThingsEntity, SwitchEntity):
|
|||||||
async def async_will_remove_from_hass(self) -> None:
|
async def async_will_remove_from_hass(self) -> None:
|
||||||
"""Call when entity will be removed from hass."""
|
"""Call when entity will be removed from hass."""
|
||||||
await super().async_will_remove_from_hass()
|
await super().async_will_remove_from_hass()
|
||||||
if self.entity_description != SWITCH or self.device.device.components[
|
if not self.created_issue:
|
||||||
MAIN
|
|
||||||
].manufacturer_category not in {
|
|
||||||
Category.CLOTHING_CARE_MACHINE,
|
|
||||||
Category.COOKTOP,
|
|
||||||
Category.DRYER,
|
|
||||||
Category.WASHER,
|
|
||||||
Category.MICROWAVE,
|
|
||||||
Category.DISHWASHER,
|
|
||||||
}:
|
|
||||||
return
|
return
|
||||||
async_delete_issue(self.hass, DOMAIN, f"deprecated_switch_{self.entity_id}")
|
async_delete_issue(self.hass, DOMAIN, f"deprecated_switch_{self.entity_id}")
|
||||||
|
|
||||||
|
@ -128,10 +128,11 @@ async def test_state_update(
|
|||||||
|
|
||||||
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
("device_fixture", "entity_id"),
|
("device_fixture", "entity_id", "translation_key"),
|
||||||
[
|
[
|
||||||
("da_wm_wm_000001", "switch.washer"),
|
("da_wm_wm_000001", "switch.washer", "deprecated_switch_appliance"),
|
||||||
("da_wm_wd_000001", "switch.dryer"),
|
("da_wm_wd_000001", "switch.dryer", "deprecated_switch_appliance"),
|
||||||
|
("hw_q80r_soundbar", "switch.soundbar", "deprecated_switch_media_player"),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_create_issue(
|
async def test_create_issue(
|
||||||
@ -140,6 +141,7 @@ async def test_create_issue(
|
|||||||
mock_config_entry: MockConfigEntry,
|
mock_config_entry: MockConfigEntry,
|
||||||
issue_registry: ir.IssueRegistry,
|
issue_registry: ir.IssueRegistry,
|
||||||
entity_id: str,
|
entity_id: str,
|
||||||
|
translation_key: str,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test we create an issue when an automation or script is using a deprecated entity."""
|
"""Test we create an issue when an automation or script is using a deprecated entity."""
|
||||||
issue_id = f"deprecated_switch_{entity_id}"
|
issue_id = f"deprecated_switch_{entity_id}"
|
||||||
@ -187,7 +189,7 @@ async def test_create_issue(
|
|||||||
assert len(issue_registry.issues) == 1
|
assert len(issue_registry.issues) == 1
|
||||||
issue = issue_registry.async_get_issue(DOMAIN, issue_id)
|
issue = issue_registry.async_get_issue(DOMAIN, issue_id)
|
||||||
assert issue is not None
|
assert issue is not None
|
||||||
assert issue.translation_key == "deprecated_switch_appliance"
|
assert issue.translation_key == translation_key
|
||||||
assert issue.translation_placeholders == {
|
assert issue.translation_placeholders == {
|
||||||
"entity": entity_id,
|
"entity": entity_id,
|
||||||
"items": "- [test](/config/automation/edit/test)\n- [test](/config/script/edit/test)",
|
"items": "- [test](/config/automation/edit/test)\n- [test](/config/script/edit/test)",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user