From 2c2e8db19f2240bc804444d1e67ba4db2ec9a3d8 Mon Sep 17 00:00:00 2001 From: wollew Date: Tue, 5 May 2026 11:08:00 +0200 Subject: [PATCH] Remove deprecated reboot service for Velux gateway (#169796) --- homeassistant/components/velux/__init__.py | 59 ++------------------ homeassistant/components/velux/icons.json | 7 --- homeassistant/components/velux/services.yaml | 3 - homeassistant/components/velux/strings.json | 15 ----- tests/components/velux/test_init.py | 42 -------------- 5 files changed, 4 insertions(+), 122 deletions(-) delete mode 100644 homeassistant/components/velux/icons.json delete mode 100644 homeassistant/components/velux/services.yaml diff --git a/homeassistant/components/velux/__init__.py b/homeassistant/components/velux/__init__.py index 31b9c0219f22..863971ac1bef 100644 --- a/homeassistant/components/velux/__init__.py +++ b/homeassistant/components/velux/__init__.py @@ -2,26 +2,16 @@ from pyvlx import PyVLX, PyVLXException -from homeassistant.config_entries import ConfigEntry, ConfigEntryState +from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( CONF_HOST, CONF_MAC, CONF_PASSWORD, EVENT_HOMEASSISTANT_STOP, ) -from homeassistant.core import Event, HomeAssistant, ServiceCall -from homeassistant.exceptions import ( - ConfigEntryAuthFailed, - ConfigEntryNotReady, - HomeAssistantError, - ServiceValidationError, -) -from homeassistant.helpers import ( - config_validation as cv, - device_registry as dr, - issue_registry as ir, -) -from homeassistant.helpers.typing import ConfigType +from homeassistant.core import Event, HomeAssistant +from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady +from homeassistant.helpers import config_validation as cv, device_registry as dr from .const import DOMAIN, LOGGER, PLATFORMS @@ -30,47 +20,6 @@ type VeluxConfigEntry = ConfigEntry[PyVLX] CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN) -async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: - """Set up the Velux component.""" - - async def async_reboot_gateway(service_call: ServiceCall) -> None: - """Reboot the gateway (deprecated - use button entity instead).""" - ir.async_create_issue( - hass, - DOMAIN, - "deprecated_reboot_service", - is_fixable=False, - issue_domain=DOMAIN, - severity=ir.IssueSeverity.WARNING, - translation_key="deprecated_reboot_service", - breaks_in_ha_version="2026.6.0", - ) - - # Find a loaded config entry to get the PyVLX instance - # We assume only one gateway is set up or we just reboot the first one found - # (this is no change to the previous behavior, the alternative would be to reboot all) - for entry in hass.config_entries.async_entries(DOMAIN): - if entry.state is ConfigEntryState.LOADED: - try: - await entry.runtime_data.reboot_gateway() - except (OSError, PyVLXException) as err: - raise HomeAssistantError( - translation_domain=DOMAIN, - translation_key="reboot_failed", - ) from err - else: - return - - raise ServiceValidationError( - translation_domain=DOMAIN, - translation_key="no_gateway_loaded", - ) - - hass.services.async_register(DOMAIN, "reboot_gateway", async_reboot_gateway) - - return True - - async def async_setup_entry(hass: HomeAssistant, entry: VeluxConfigEntry) -> bool: """Set up the velux component.""" host = entry.data[CONF_HOST] diff --git a/homeassistant/components/velux/icons.json b/homeassistant/components/velux/icons.json deleted file mode 100644 index 78cb5b148385..000000000000 --- a/homeassistant/components/velux/icons.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "services": { - "reboot_gateway": { - "service": "mdi:restart" - } - } -} diff --git a/homeassistant/components/velux/services.yaml b/homeassistant/components/velux/services.yaml deleted file mode 100644 index 7aee1694061a..000000000000 --- a/homeassistant/components/velux/services.yaml +++ /dev/null @@ -1,3 +0,0 @@ -# Velux Integration services - -reboot_gateway: diff --git a/homeassistant/components/velux/strings.json b/homeassistant/components/velux/strings.json index a52fb0a245c9..f833503aaac9 100644 --- a/homeassistant/components/velux/strings.json +++ b/homeassistant/components/velux/strings.json @@ -59,23 +59,8 @@ "device_communication_error": { "message": "Failed to communicate with Velux device: {error}" }, - "no_gateway_loaded": { - "message": "No loaded Velux gateway found" - }, "reboot_failed": { "message": "Failed to reboot gateway. Try again in a few moments or power cycle the device manually" } - }, - "issues": { - "deprecated_reboot_service": { - "description": "The `velux.reboot_gateway` action is deprecated and will be removed in Home Assistant 2026.6.0. Please use the 'Restart' button entity instead. You can find this button in the device page for your KLF 200 Gateway or by searching for 'restart' in your entity list.", - "title": "Velux 'Reboot gateway' action deprecated" - } - }, - "services": { - "reboot_gateway": { - "description": "Reboots the KLF200 Gateway", - "name": "Reboot gateway" - } } } diff --git a/tests/components/velux/test_init.py b/tests/components/velux/test_init.py index 39e034793ba4..8711ad9a7c8a 100644 --- a/tests/components/velux/test_init.py +++ b/tests/components/velux/test_init.py @@ -11,12 +11,9 @@ from unittest.mock import patch import pytest from pyvlx.exception import PyVLXException -from homeassistant.components.velux.const import DOMAIN from homeassistant.config_entries import ConfigEntryState from homeassistant.const import Platform from homeassistant.core import HomeAssistant -from homeassistant.exceptions import HomeAssistantError, ServiceValidationError -from homeassistant.setup import async_setup_component from tests.common import AsyncMock, ConfigEntry, MockConfigEntry @@ -125,42 +122,3 @@ async def test_unload_does_not_disconnect_if_platform_unload_fails( # Verify disconnect was NOT called since platform unload failed mock_pyvlx.disconnect.assert_not_awaited() - - -@pytest.mark.usefixtures("setup_integration") -async def test_reboot_gateway_service_raises_on_exception( - hass: HomeAssistant, mock_pyvlx: AsyncMock -) -> None: - """Test that reboot_gateway service raises HomeAssistantError on exception.""" - - mock_pyvlx.reboot_gateway.side_effect = OSError("Connection failed") - with pytest.raises(HomeAssistantError, match="Failed to reboot gateway"): - await hass.services.async_call( - "velux", - "reboot_gateway", - blocking=True, - ) - - mock_pyvlx.reboot_gateway.side_effect = PyVLXException("Reboot failed") - with pytest.raises(HomeAssistantError, match="Failed to reboot gateway"): - await hass.services.async_call( - "velux", - "reboot_gateway", - blocking=True, - ) - - -async def test_reboot_gateway_service_raises_validation_error( - hass: HomeAssistant, -) -> None: - """Test that reboot_gateway service raises ServiceValidationError when no gateway is loaded.""" - # Set up the velux integration's async_setup to register the service - await async_setup_component(hass, DOMAIN, {}) - await hass.async_block_till_done() - - with pytest.raises(ServiceValidationError, match="No loaded Velux gateway found"): - await hass.services.async_call( - "velux", - "reboot_gateway", - blocking=True, - )