From 6a021e64ecb5377533bfc67b14efd5f77013deda Mon Sep 17 00:00:00 2001 From: Manu Date: Mon, 19 Oct 2026 04:21:38 +0200 Subject: [PATCH] Remove deprecated 'heos.sign_in' and 'heos.sign_out' actions in HEOS integration (#187102) --- homeassistant/components/heos/const.py | 2 - homeassistant/components/heos/icons.json | 6 - homeassistant/components/heos/services.py | 92 +------------- homeassistant/components/heos/services.yaml | 15 --- homeassistant/components/heos/strings.json | 36 ------ tests/components/heos/test_services.py | 132 -------------------- 6 files changed, 2 insertions(+), 281 deletions(-) delete mode 100644 tests/components/heos/test_services.py diff --git a/homeassistant/components/heos/const.py b/homeassistant/components/heos/const.py index d49fc17aa538..8919ea7c3038 100644 --- a/homeassistant/components/heos/const.py +++ b/homeassistant/components/heos/const.py @@ -12,5 +12,3 @@ SERVICE_GROUP_VOLUME_DOWN = "group_volume_down" SERVICE_GROUP_VOLUME_UP = "group_volume_up" SERVICE_MOVE_QUEUE_ITEM = "move_queue_item" SERVICE_REMOVE_FROM_QUEUE = "remove_from_queue" -SERVICE_SIGN_IN = "sign_in" -SERVICE_SIGN_OUT = "sign_out" diff --git a/homeassistant/components/heos/icons.json b/homeassistant/components/heos/icons.json index 916aa82f391b..f1a027a4fb50 100644 --- a/homeassistant/components/heos/icons.json +++ b/homeassistant/components/heos/icons.json @@ -17,12 +17,6 @@ }, "remove_from_queue": { "service": "mdi:playlist-remove" - }, - "sign_in": { - "service": "mdi:login" - }, - "sign_out": { - "service": "mdi:logout" } } } diff --git a/homeassistant/components/heos/services.py b/homeassistant/components/heos/services.py index baf813440269..a1d3e224d5ad 100644 --- a/homeassistant/components/heos/services.py +++ b/homeassistant/components/heos/services.py @@ -5,24 +5,19 @@ import logging from typing import Final import probatio -from pyheos import CommandAuthenticationError, Heos, HeosError from homeassistant.components.media_player import ( ATTR_MEDIA_VOLUME_LEVEL, DOMAIN as MEDIA_PLAYER_DOMAIN, ) -from homeassistant.config_entries import ConfigEntryState -from homeassistant.core import HomeAssistant, ServiceCall, SupportsResponse, callback -from homeassistant.exceptions import HomeAssistantError, ServiceValidationError -from homeassistant.helpers import config_validation as cv, issue_registry as ir +from homeassistant.core import HomeAssistant, SupportsResponse, callback +from homeassistant.helpers import config_validation as cv from homeassistant.helpers.service import async_register_platform_entity_service from homeassistant.helpers.typing import VolDictType, VolSchemaType from .const import ( ATTR_DESTINATION_POSITION, - ATTR_PASSWORD, ATTR_QUEUE_IDS, - ATTR_USERNAME, DOMAIN, SERVICE_GET_QUEUE, SERVICE_GROUP_VOLUME_DOWN, @@ -30,38 +25,14 @@ from .const import ( SERVICE_GROUP_VOLUME_UP, SERVICE_MOVE_QUEUE_ITEM, SERVICE_REMOVE_FROM_QUEUE, - SERVICE_SIGN_IN, - SERVICE_SIGN_OUT, ) -from .coordinator import HeosConfigEntry _LOGGER = logging.getLogger(__name__) -HEOS_SIGN_IN_SCHEMA = probatio.Schema( - { - probatio.Required(ATTR_USERNAME): cv.string, - probatio.Required(ATTR_PASSWORD): cv.string, - } -) - -HEOS_SIGN_OUT_SCHEMA = probatio.Schema({}) - @callback def async_setup_services(hass: HomeAssistant) -> None: """Register HEOS services.""" - hass.services.async_register( - DOMAIN, - SERVICE_SIGN_IN, - _sign_in_handler, - schema=HEOS_SIGN_IN_SCHEMA, - ) - hass.services.async_register( - DOMAIN, - SERVICE_SIGN_OUT, - _sign_out_handler, - schema=HEOS_SIGN_OUT_SCHEMA, - ) for description in MEDIA_PLAYER_ENTITY_SERVICES: async_register_platform_entity_service( hass, @@ -125,62 +96,3 @@ MEDIA_PLAYER_ENTITY_SERVICES: Final = ( EntityServiceDescription(SERVICE_GROUP_VOLUME_DOWN, "async_group_volume_down"), EntityServiceDescription(SERVICE_GROUP_VOLUME_UP, "async_group_volume_up"), ) - - -def _get_controller(hass: HomeAssistant) -> Heos: - """Get the HEOS controller instance.""" - _LOGGER.warning( - "Actions 'heos.sign_in' and 'heos.sign_out' are deprecated" - " and will be removed in the 2025.8.0 release" - ) - ir.async_create_issue( - hass, - DOMAIN, - "sign_in_out_deprecated", - breaks_in_ha_version="2025.8.0", - is_fixable=False, - severity=ir.IssueSeverity.WARNING, - translation_key="sign_in_out_deprecated", - ) - - entry: HeosConfigEntry | None = ( - hass.config_entries.async_entry_for_domain_unique_id(DOMAIN, DOMAIN) - ) - - if not entry or entry.state is not ConfigEntryState.LOADED: - raise HomeAssistantError( - translation_domain=DOMAIN, translation_key="integration_not_loaded" - ) - return entry.runtime_data.heos - - -async def _sign_in_handler(service: ServiceCall) -> None: - """Sign in to the HEOS account.""" - controller = _get_controller(service.hass) - username = service.data[ATTR_USERNAME] - password = service.data[ATTR_PASSWORD] - try: - await controller.sign_in(username, password) - except CommandAuthenticationError as err: - raise ServiceValidationError( - translation_domain=DOMAIN, translation_key="sign_in_auth_error" - ) from err - except HeosError as err: - raise HomeAssistantError( - translation_domain=DOMAIN, - translation_key="sign_in_error", - translation_placeholders={"error": str(err)}, - ) from err - - -async def _sign_out_handler(service: ServiceCall) -> None: - """Sign out of the HEOS account.""" - controller = _get_controller(service.hass) - try: - await controller.sign_out() - except HeosError as err: - raise HomeAssistantError( - translation_domain=DOMAIN, - translation_key="sign_out_error", - translation_placeholders={"error": str(err)}, - ) from err diff --git a/homeassistant/components/heos/services.yaml b/homeassistant/components/heos/services.yaml index 333a15940bcd..1ad5f34cde7b 100644 --- a/homeassistant/components/heos/services.yaml +++ b/homeassistant/components/heos/services.yaml @@ -62,18 +62,3 @@ group_volume_up: entity: integration: heos domain: media_player - -sign_in: - fields: - username: - required: true - example: "example@example.com" - selector: - text: - password: - required: true - example: "password" - selector: - text: - -sign_out: diff --git a/homeassistant/components/heos/strings.json b/homeassistant/components/heos/strings.json index 724e353be93e..8f1b247be9a1 100644 --- a/homeassistant/components/heos/strings.json +++ b/homeassistant/components/heos/strings.json @@ -60,21 +60,9 @@ "entity_not_grouped": { "message": "Entity {entity_id} is not joined to a group" }, - "integration_not_loaded": { - "message": "The HEOS integration is not loaded" - }, "not_heos_media_player": { "message": "Entity {entity_id} is not a HEOS media player entity" }, - "sign_in_auth_error": { - "message": "Failed to sign in: Invalid username and/or password" - }, - "sign_in_error": { - "message": "Unable to sign in: {error}" - }, - "sign_out_error": { - "message": "Unable to sign out: {error}" - }, "unable_to_connect": { "message": "Unable to connect to {host}" }, @@ -88,12 +76,6 @@ "message": "Unsupported media_content_id: {media_content_id}" } }, - "issues": { - "sign_in_out_deprecated": { - "description": "Actions 'heos.sign_in' and 'heos.sign_out' are deprecated and will be removed in the 2025.8.0 release. Enter your HEOS Account credentials in the configuration options and the integration will manage authentication automatically.", - "title": "HEOS Actions Deprecated" - } - }, "options": { "error": { "invalid_auth": "[%key:common::config_flow::error::invalid_auth%]", @@ -162,24 +144,6 @@ } }, "name": "Remove from queue" - }, - "sign_in": { - "description": "Signs in to a HEOS account.", - "fields": { - "password": { - "description": "The password of the HEOS account.", - "name": "[%key:common::config_flow::data::password%]" - }, - "username": { - "description": "The username or email of the HEOS account.", - "name": "[%key:common::config_flow::data::username%]" - } - }, - "name": "Sign in" - }, - "sign_out": { - "description": "Signs out of the HEOS account.", - "name": "Sign out" } } } diff --git a/tests/components/heos/test_services.py b/tests/components/heos/test_services.py deleted file mode 100644 index 151571ceb50c..000000000000 --- a/tests/components/heos/test_services.py +++ /dev/null @@ -1,132 +0,0 @@ -"""Tests for the services module.""" - -from pyheos import CommandAuthenticationError, HeosError -import pytest - -from homeassistant.components.heos.const import ( - ATTR_PASSWORD, - ATTR_USERNAME, - DOMAIN, - SERVICE_SIGN_IN, - SERVICE_SIGN_OUT, -) -from homeassistant.core import HomeAssistant -from homeassistant.exceptions import HomeAssistantError, ServiceValidationError - -from . import MockHeos - -from tests.common import MockConfigEntry - - -async def test_sign_in( - hass: HomeAssistant, config_entry: MockConfigEntry, controller: MockHeos -) -> None: - """Test the sign-in service.""" - config_entry.add_to_hass(hass) - assert await hass.config_entries.async_setup(config_entry.entry_id) - - await hass.services.async_call( - DOMAIN, - SERVICE_SIGN_IN, - {ATTR_USERNAME: "test@test.com", ATTR_PASSWORD: "password"}, - blocking=True, - ) - - controller.sign_in.assert_called_once_with("test@test.com", "password") - - -async def test_sign_in_failed( - hass: HomeAssistant, config_entry: MockConfigEntry, controller: MockHeos -) -> None: - """Test sign-in service logs error when not connected.""" - config_entry.add_to_hass(hass) - assert await hass.config_entries.async_setup(config_entry.entry_id) - - controller.sign_in.side_effect = CommandAuthenticationError( - "", "Invalid credentials", 6 - ) - - with pytest.raises(ServiceValidationError): - await hass.services.async_call( - DOMAIN, - SERVICE_SIGN_IN, - {ATTR_USERNAME: "test@test.com", ATTR_PASSWORD: "password"}, - blocking=True, - ) - - controller.sign_in.assert_called_once_with("test@test.com", "password") - - -async def test_sign_in_unknown_error( - hass: HomeAssistant, config_entry: MockConfigEntry, controller: MockHeos -) -> None: - """Test sign-in service logs error for failure.""" - config_entry.add_to_hass(hass) - assert await hass.config_entries.async_setup(config_entry.entry_id) - - controller.sign_in.side_effect = HeosError() - - with pytest.raises(HomeAssistantError): - await hass.services.async_call( - DOMAIN, - SERVICE_SIGN_IN, - {ATTR_USERNAME: "test@test.com", ATTR_PASSWORD: "password"}, - blocking=True, - ) - - controller.sign_in.assert_called_once_with("test@test.com", "password") - - -async def test_sign_in_not_loaded_raises( - hass: HomeAssistant, config_entry: MockConfigEntry -) -> None: - """Test the sign-in service when entry not loaded raises exception.""" - config_entry.add_to_hass(hass) - assert await hass.config_entries.async_setup(config_entry.entry_id) - assert await hass.config_entries.async_unload(config_entry.entry_id) - - with pytest.raises(HomeAssistantError, match="The HEOS integration is not loaded"): - await hass.services.async_call( - DOMAIN, - SERVICE_SIGN_IN, - {ATTR_USERNAME: "test@test.com", ATTR_PASSWORD: "password"}, - blocking=True, - ) - - -async def test_sign_out( - hass: HomeAssistant, config_entry: MockConfigEntry, controller: MockHeos -) -> None: - """Test the sign-out service.""" - config_entry.add_to_hass(hass) - assert await hass.config_entries.async_setup(config_entry.entry_id) - - await hass.services.async_call(DOMAIN, SERVICE_SIGN_OUT, {}, blocking=True) - - assert controller.sign_out.call_count == 1 - - -async def test_sign_out_not_loaded_raises( - hass: HomeAssistant, config_entry: MockConfigEntry -) -> None: - """Test the sign-out service when entry not loaded raises exception.""" - config_entry.add_to_hass(hass) - assert await hass.config_entries.async_setup(config_entry.entry_id) - assert await hass.config_entries.async_unload(config_entry.entry_id) - - with pytest.raises(HomeAssistantError, match="The HEOS integration is not loaded"): - await hass.services.async_call(DOMAIN, SERVICE_SIGN_OUT, {}, blocking=True) - - -async def test_sign_out_unknown_error( - hass: HomeAssistant, config_entry: MockConfigEntry, controller: MockHeos -) -> None: - """Test the sign-out service.""" - config_entry.add_to_hass(hass) - assert await hass.config_entries.async_setup(config_entry.entry_id) - controller.sign_out.side_effect = HeosError() - - with pytest.raises(HomeAssistantError): - await hass.services.async_call(DOMAIN, SERVICE_SIGN_OUT, {}, blocking=True) - - assert controller.sign_out.call_count == 1