mirror of
https://github.com/home-assistant/core.git
synced 2026-07-13 17:44:45 +01:00
Remove deprecated reboot service for Velux gateway (#169796)
This commit is contained in:
@@ -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]
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"services": {
|
||||
"reboot_gateway": {
|
||||
"service": "mdi:restart"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
# Velux Integration services
|
||||
|
||||
reboot_gateway:
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user