Remove deprecated freebox reboot service (#144303)

This commit is contained in:
epenet 2025-05-06 12:21:48 +02:00 committed by GitHub
parent c9a9488ff5
commit 687c74ee4c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 4 additions and 39 deletions

View File

@ -1,23 +1,20 @@
"""Support for Freebox devices (Freebox v6 and Freebox mini 4K)."""
from datetime import timedelta
import logging
from freebox_api.exceptions import HttpRequestError
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_HOST, CONF_PORT, EVENT_HOMEASSISTANT_STOP
from homeassistant.core import Event, HomeAssistant, ServiceCall
from homeassistant.core import Event, HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers.event import async_track_time_interval
from .const import DOMAIN, PLATFORMS, SERVICE_REBOOT
from .const import DOMAIN, PLATFORMS
from .router import FreeboxRouter, get_api
SCAN_INTERVAL = timedelta(seconds=30)
_LOGGER = logging.getLogger(__name__)
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up Freebox entry."""
@ -40,20 +37,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
# Services
async def async_reboot(call: ServiceCall) -> None:
"""Handle reboot service call."""
# The Freebox reboot service has been replaced by a
# dedicated button entity and marked as deprecated
_LOGGER.warning(
"The 'freebox.reboot' service is deprecated and "
"replaced by a dedicated reboot button entity; please "
"use that entity to reboot the freebox instead"
)
await router.reboot()
hass.services.async_register(DOMAIN, SERVICE_REBOOT, async_reboot)
async def async_close_connection(event: Event) -> None:
"""Close Freebox connection on HA Stop."""
await router.close()
@ -71,6 +54,5 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
if unload_ok:
router: FreeboxRouter = hass.data[DOMAIN].pop(entry.unique_id)
await router.close()
hass.services.async_remove(DOMAIN, SERVICE_REBOOT)
return unload_ok

View File

@ -8,7 +8,6 @@ import socket
from homeassistant.const import Platform
DOMAIN = "freebox"
SERVICE_REBOOT = "reboot"
APP_DESC = {
"app_id": "hass",

View File

@ -1,11 +1,11 @@
"""Tests for the Freebox init."""
from unittest.mock import ANY, Mock, patch
from unittest.mock import ANY, Mock
from pytest_unordered import unordered
from homeassistant.components.device_tracker import DOMAIN as DT_DOMAIN
from homeassistant.components.freebox.const import DOMAIN, SERVICE_REBOOT
from homeassistant.components.freebox.const import DOMAIN
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
from homeassistant.config_entries import ConfigEntryState
@ -33,19 +33,6 @@ async def test_setup(hass: HomeAssistant, router: Mock) -> None:
assert router.call_count == 1
assert router().open.call_count == 1
assert hass.services.has_service(DOMAIN, SERVICE_REBOOT)
with patch(
"homeassistant.components.freebox.router.FreeboxRouter.reboot"
) as mock_service:
await hass.services.async_call(
DOMAIN,
SERVICE_REBOOT,
blocking=True,
)
await hass.async_block_till_done()
mock_service.assert_called_once()
async def test_setup_import(hass: HomeAssistant, router: Mock) -> None:
"""Test setup of integration from import."""
@ -65,8 +52,6 @@ async def test_setup_import(hass: HomeAssistant, router: Mock) -> None:
assert router.call_count == 1
assert router().open.call_count == 1
assert hass.services.has_service(DOMAIN, SERVICE_REBOOT)
async def test_unload_remove(hass: HomeAssistant, router: Mock) -> None:
"""Test unload and remove of integration."""
@ -106,7 +91,6 @@ async def test_unload_remove(hass: HomeAssistant, router: Mock) -> None:
assert state_switch.state == STATE_UNAVAILABLE
assert router().close.call_count == 1
assert not hass.services.has_service(DOMAIN, SERVICE_REBOOT)
await hass.config_entries.async_remove(entry.entry_id)
await hass.async_block_till_done()