From 7dc2dff4e7c91f7a90796d22390be0030d5ca615 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Thu, 26 Feb 2026 12:53:18 +0100 Subject: [PATCH] Drop single-use service name constants in alexa_devices (#164151) --- .../components/alexa_devices/services.py | 9 +++---- .../components/alexa_devices/test_services.py | 25 ++++++++----------- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/homeassistant/components/alexa_devices/services.py b/homeassistant/components/alexa_devices/services.py index fb0fda0b843..06beb5258f3 100644 --- a/homeassistant/components/alexa_devices/services.py +++ b/homeassistant/components/alexa_devices/services.py @@ -16,9 +16,6 @@ from .coordinator import AmazonConfigEntry ATTR_TEXT_COMMAND = "text_command" ATTR_SOUND = "sound" ATTR_INFO_SKILL = "info_skill" -SERVICE_TEXT_COMMAND = "send_text_command" -SERVICE_SOUND_NOTIFICATION = "send_sound" -SERVICE_INFO_SKILL = "send_info_skill" SCHEMA_SOUND_SERVICE = vol.Schema( { @@ -128,17 +125,17 @@ def async_setup_services(hass: HomeAssistant) -> None: """Set up the services for the Amazon Devices integration.""" for service_name, method, schema in ( ( - SERVICE_SOUND_NOTIFICATION, + "send_sound", async_send_sound_notification, SCHEMA_SOUND_SERVICE, ), ( - SERVICE_TEXT_COMMAND, + "send_text_command", async_send_text_command, SCHEMA_CUSTOM_COMMAND, ), ( - SERVICE_INFO_SKILL, + "send_info_skill", async_send_info_skill, SCHEMA_INFO_SKILL, ), diff --git a/tests/components/alexa_devices/test_services.py b/tests/components/alexa_devices/test_services.py index db7745ee5b7..42a2ee36c5b 100644 --- a/tests/components/alexa_devices/test_services.py +++ b/tests/components/alexa_devices/test_services.py @@ -10,9 +10,6 @@ from homeassistant.components.alexa_devices.services import ( ATTR_INFO_SKILL, ATTR_SOUND, ATTR_TEXT_COMMAND, - SERVICE_INFO_SKILL, - SERVICE_SOUND_NOTIFICATION, - SERVICE_TEXT_COMMAND, ) from homeassistant.config_entries import ConfigEntryState from homeassistant.const import ATTR_DEVICE_ID @@ -35,9 +32,9 @@ async def test_setup_services( await setup_integration(hass, mock_config_entry) assert (services := hass.services.async_services_for_domain(DOMAIN)) - assert SERVICE_TEXT_COMMAND in services - assert SERVICE_SOUND_NOTIFICATION in services - assert SERVICE_INFO_SKILL in services + assert "send_text_command" in services + assert "send_sound" in services + assert "send_info_skill" in services async def test_info_skill_service( @@ -58,7 +55,7 @@ async def test_info_skill_service( await hass.services.async_call( DOMAIN, - SERVICE_INFO_SKILL, + "send_info_skill", { ATTR_INFO_SKILL: "tell_joke", ATTR_DEVICE_ID: device_entry.id, @@ -88,7 +85,7 @@ async def test_send_sound_service( await hass.services.async_call( DOMAIN, - SERVICE_SOUND_NOTIFICATION, + "send_sound", { ATTR_SOUND: "bell_02", ATTR_DEVICE_ID: device_entry.id, @@ -118,7 +115,7 @@ async def test_send_text_service( await hass.services.async_call( DOMAIN, - SERVICE_TEXT_COMMAND, + "send_text_command", { ATTR_TEXT_COMMAND: "Play B.B.C. radio on TuneIn", ATTR_DEVICE_ID: device_entry.id, @@ -173,7 +170,7 @@ async def test_invalid_parameters( with pytest.raises(ServiceValidationError) as exc_info: await hass.services.async_call( DOMAIN, - SERVICE_SOUND_NOTIFICATION, + "send_sound", { ATTR_SOUND: sound, ATTR_DEVICE_ID: device_id, @@ -229,7 +226,7 @@ async def test_invalid_info_skillparameters( with pytest.raises(ServiceValidationError) as exc_info: await hass.services.async_call( DOMAIN, - SERVICE_INFO_SKILL, + "send_info_skill", { ATTR_INFO_SKILL: info_skill, ATTR_DEVICE_ID: device_id, @@ -266,7 +263,7 @@ async def test_config_entry_not_loaded( with pytest.raises(ServiceValidationError) as exc_info: await hass.services.async_call( DOMAIN, - SERVICE_SOUND_NOTIFICATION, + "send_sound", { ATTR_SOUND: "bell_02", ATTR_DEVICE_ID: device_entry.id, @@ -300,7 +297,7 @@ async def test_invalid_config_entry( # Call Service await hass.services.async_call( DOMAIN, - SERVICE_SOUND_NOTIFICATION, + "send_sound", { ATTR_SOUND: "bell_02", ATTR_DEVICE_ID: device_entry.id, @@ -332,7 +329,7 @@ async def test_missing_config_entry( with pytest.raises(ServiceValidationError) as exc_info: await hass.services.async_call( DOMAIN, - SERVICE_SOUND_NOTIFICATION, + "send_sound", { ATTR_SOUND: "bell_02", ATTR_DEVICE_ID: device_entry.id,