Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated services from Huawei LTE #107578

Merged
merged 1 commit into from Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
46 changes: 1 addition & 45 deletions homeassistant/components/huawei_lte/__init__.py
Expand Up @@ -13,7 +13,6 @@

from huawei_lte_api.Client import Client
from huawei_lte_api.Connection import Connection
from huawei_lte_api.enums.device import ControlModeEnum
from huawei_lte_api.exceptions import (
LoginErrorInvalidCredentialsException,
ResponseErrorException,
Expand Down Expand Up @@ -51,16 +50,13 @@
from homeassistant.helpers.dispatcher import async_dispatcher_connect, dispatcher_send
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.event import async_track_time_interval
from homeassistant.helpers.issue_registry import IssueSeverity, create_issue
from homeassistant.helpers.service import async_register_admin_service
from homeassistant.helpers.typing import ConfigType

from .const import (
ADMIN_SERVICES,
ALL_KEYS,
ATTR_CONFIG_ENTRY_ID,
BUTTON_KEY_CLEAR_TRAFFIC_STATISTICS,
BUTTON_KEY_RESTART,
CONF_MANUFACTURER,
CONF_UNAUTHENTICATED_MODE,
CONNECTION_TIMEOUT,
Expand All @@ -84,8 +80,6 @@
KEY_WLAN_WIFI_FEATURE_SWITCH,
KEY_WLAN_WIFI_GUEST_NETWORK_SWITCH,
NOTIFY_SUPPRESS_TIMEOUT,
SERVICE_CLEAR_TRAFFIC_STATISTICS,
SERVICE_REBOOT,
SERVICE_RESUME_INTEGRATION,
SERVICE_SUSPEND_INTEGRATION,
UPDATE_SIGNAL,
Expand Down Expand Up @@ -533,45 +527,7 @@ def service_handler(service: ServiceCall) -> None:
_LOGGER.error("%s: router %s unavailable", service.service, url)
return

if service.service == SERVICE_CLEAR_TRAFFIC_STATISTICS:
create_issue(
hass,
DOMAIN,
"service_clear_traffic_statistics_moved_to_button",
breaks_in_ha_version="2024.2.0",
is_fixable=False,
severity=IssueSeverity.WARNING,
translation_key="service_changed_to_button",
translation_placeholders={
"service": service.service,
"button": BUTTON_KEY_CLEAR_TRAFFIC_STATISTICS,
},
)
if router.suspended:
_LOGGER.debug("%s: ignored, integration suspended", service.service)
return
result = router.client.monitoring.set_clear_traffic()
_LOGGER.debug("%s: %s", service.service, result)
elif service.service == SERVICE_REBOOT:
create_issue(
hass,
DOMAIN,
"service_reboot_moved_to_button",
breaks_in_ha_version="2024.2.0",
is_fixable=False,
severity=IssueSeverity.WARNING,
translation_key="service_changed_to_button",
translation_placeholders={
"service": service.service,
"button": BUTTON_KEY_RESTART,
},
)
if router.suspended:
_LOGGER.debug("%s: ignored, integration suspended", service.service)
return
result = router.client.device.set_control(ControlModeEnum.REBOOT)
_LOGGER.debug("%s: %s", service.service, result)
elif service.service == SERVICE_RESUME_INTEGRATION:
if service.service == SERVICE_RESUME_INTEGRATION:
# Login will be handled automatically on demand
router.suspended = False
_LOGGER.debug("%s: %s", service.service, "done")
Expand Down
4 changes: 0 additions & 4 deletions homeassistant/components/huawei_lte/const.py
Expand Up @@ -19,14 +19,10 @@
CONNECTION_TIMEOUT = 10
NOTIFY_SUPPRESS_TIMEOUT = 30

SERVICE_CLEAR_TRAFFIC_STATISTICS = "clear_traffic_statistics"
SERVICE_REBOOT = "reboot"
SERVICE_RESUME_INTEGRATION = "resume_integration"
SERVICE_SUSPEND_INTEGRATION = "suspend_integration"

ADMIN_SERVICES = {
SERVICE_CLEAR_TRAFFIC_STATISTICS,
SERVICE_REBOOT,
SERVICE_RESUME_INTEGRATION,
SERVICE_SUSPEND_INTEGRATION,
}
Expand Down
14 changes: 0 additions & 14 deletions homeassistant/components/huawei_lte/services.yaml
@@ -1,17 +1,3 @@
clear_traffic_statistics:
fields:
url:
example: http://192.168.100.1/
selector:
text:

reboot:
fields:
url:
example: http://192.168.100.1/
selector:
text:

resume_integration:
fields:
url:
Expand Down
26 changes: 0 additions & 26 deletions homeassistant/components/huawei_lte/strings.json
Expand Up @@ -309,33 +309,7 @@
}
}
},
"issues": {
"service_changed_to_button": {
"title": "Service changed to a button",
"description": "The {service} service is deprecated, use the corresponding {button} button instead."
}
},
"services": {
"clear_traffic_statistics": {
"name": "Clear traffic statistics",
"description": "Clears traffic statistics.",
"fields": {
"url": {
"name": "[%key:common::config_flow::data::url%]",
"description": "URL of router to clear; optional when only one is configured."
}
}
},
"reboot": {
"name": "Reboot",
"description": "Reboots router.",
"fields": {
"url": {
"name": "[%key:common::config_flow::data::url%]",
"description": "URL of router to reboot; optional when only one is configured."
}
}
},
"resume_integration": {
"name": "Resume integration",
"description": "Resumes suspended integration.",
Expand Down