parent
13e2bb1e22
commit
d3ada34498
|
@ -8,9 +8,8 @@ import speedtest
|
|||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_SCAN_INTERVAL, EVENT_HOMEASSISTANT_STARTED
|
||||
from homeassistant.core import CoreState, HomeAssistant, ServiceCall
|
||||
from homeassistant.core import CoreState, HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||
|
||||
from .const import (
|
||||
|
@ -20,7 +19,6 @@ from .const import (
|
|||
DEFAULT_SERVER,
|
||||
DOMAIN,
|
||||
PLATFORMS,
|
||||
SPEED_TEST_SERVICE,
|
||||
)
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
@ -58,8 +56,6 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
|
|||
|
||||
async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool:
|
||||
"""Unload SpeedTest Entry from config_entry."""
|
||||
hass.services.async_remove(DOMAIN, SPEED_TEST_SERVICE)
|
||||
|
||||
unload_ok = await hass.config_entries.async_unload_platforms(
|
||||
config_entry, PLATFORMS
|
||||
)
|
||||
|
@ -141,30 +137,6 @@ class SpeedTestDataCoordinator(DataUpdateCoordinator):
|
|||
except speedtest.SpeedtestException as err:
|
||||
raise ConfigEntryNotReady from err
|
||||
|
||||
async def request_update(call: ServiceCall) -> None:
|
||||
"""Request update."""
|
||||
async_create_issue(
|
||||
self.hass,
|
||||
DOMAIN,
|
||||
"deprecated_service",
|
||||
breaks_in_ha_version="2022.11.0",
|
||||
is_fixable=True,
|
||||
is_persistent=True,
|
||||
severity=IssueSeverity.WARNING,
|
||||
translation_key="deprecated_service",
|
||||
)
|
||||
|
||||
_LOGGER.warning(
|
||||
(
|
||||
'The "%s" service is deprecated and will be removed in "2022.11.0"; '
|
||||
'use the "homeassistant.update_entity" service and pass it a target Speedtest entity_id'
|
||||
),
|
||||
SPEED_TEST_SERVICE,
|
||||
)
|
||||
await self.async_request_refresh()
|
||||
|
||||
self.hass.services.async_register(DOMAIN, SPEED_TEST_SERVICE, request_update)
|
||||
|
||||
self.config_entry.async_on_unload(
|
||||
self.config_entry.add_update_listener(options_updated_listener)
|
||||
)
|
||||
|
|
|
@ -14,8 +14,6 @@ from homeassistant.const import (
|
|||
|
||||
DOMAIN: Final = "speedtestdotnet"
|
||||
|
||||
SPEED_TEST_SERVICE: Final = "speedtest"
|
||||
|
||||
|
||||
@dataclass
|
||||
class SpeedtestSensorEntityDescription(SensorEntityDescription):
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
speedtest:
|
||||
name: Speedtest
|
||||
description: Immediately execute a speed test with Speedtest.net
|
|
@ -19,18 +19,5 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"issues": {
|
||||
"deprecated_service": {
|
||||
"title": "The speedtest service is being removed",
|
||||
"fix_flow": {
|
||||
"step": {
|
||||
"confirm": {
|
||||
"title": "The speedtest service is being removed",
|
||||
"description": "Update any automations or scripts that use this service to instead use the `homeassistant.update_entity` service with a target Speedtest entity_id. Then, click SUBMIT below to mark this issue as resolved."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
"""Tests for SpeedTest integration."""
|
||||
|
||||
from collections.abc import Awaitable
|
||||
from datetime import timedelta
|
||||
from typing import Callable
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from aiohttp import ClientWebSocketResponse
|
||||
import speedtest
|
||||
|
||||
from homeassistant.components.speedtestdotnet.const import (
|
||||
|
@ -13,7 +10,6 @@ from homeassistant.components.speedtestdotnet.const import (
|
|||
CONF_SERVER_ID,
|
||||
CONF_SERVER_NAME,
|
||||
DOMAIN,
|
||||
SPEED_TEST_SERVICE,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.const import CONF_SCAN_INTERVAL, STATE_UNAVAILABLE
|
||||
|
@ -21,7 +17,6 @@ from homeassistant.core import HomeAssistant
|
|||
import homeassistant.util.dt as dt_util
|
||||
|
||||
from tests.common import MockConfigEntry, async_fire_time_changed
|
||||
from tests.components.repairs import get_repairs
|
||||
|
||||
|
||||
async def test_successful_config_entry(hass: HomeAssistant) -> None:
|
||||
|
@ -43,7 +38,6 @@ async def test_successful_config_entry(hass: HomeAssistant) -> None:
|
|||
|
||||
assert entry.state == ConfigEntryState.LOADED
|
||||
assert hass.data[DOMAIN]
|
||||
assert hass.services.has_service(DOMAIN, SPEED_TEST_SERVICE)
|
||||
|
||||
|
||||
async def test_setup_failed(hass: HomeAssistant, mock_api: MagicMock) -> None:
|
||||
|
@ -125,28 +119,3 @@ async def test_get_best_server_error(hass: HomeAssistant, mock_api: MagicMock) -
|
|||
state = hass.states.get("sensor.speedtest_ping")
|
||||
assert state is not None
|
||||
assert state.state == STATE_UNAVAILABLE
|
||||
|
||||
|
||||
async def test_deprecated_service_alert(
|
||||
hass: HomeAssistant,
|
||||
hass_ws_client: Callable[[HomeAssistant], Awaitable[ClientWebSocketResponse]],
|
||||
) -> None:
|
||||
"""Test that an issue is raised if deprecated services is called."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
"speedtest",
|
||||
{},
|
||||
blocking=True,
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
issues = await get_repairs(hass, hass_ws_client)
|
||||
assert len(issues) == 1
|
||||
assert issues[0]["issue_id"] == "deprecated_service"
|
||||
|
|
Loading…
Reference in New Issue