mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Rename "Ruckus Unleashed" integration to "Ruckus" (#125392)
This commit is contained in:
parent
aba23eb513
commit
9777ed2e62
@ -1,4 +1,4 @@
|
|||||||
"""The Ruckus Unleashed integration."""
|
"""The Ruckus integration."""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@ -24,13 +24,13 @@ from .const import (
|
|||||||
PLATFORMS,
|
PLATFORMS,
|
||||||
UNDO_UPDATE_LISTENERS,
|
UNDO_UPDATE_LISTENERS,
|
||||||
)
|
)
|
||||||
from .coordinator import RuckusUnleashedDataUpdateCoordinator
|
from .coordinator import RuckusDataUpdateCoordinator
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__package__)
|
_LOGGER = logging.getLogger(__package__)
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
"""Set up Ruckus Unleashed from a config entry."""
|
"""Set up Ruckus from a config entry."""
|
||||||
|
|
||||||
ruckus = AjaxSession.async_create(
|
ruckus = AjaxSession.async_create(
|
||||||
entry.data[CONF_HOST],
|
entry.data[CONF_HOST],
|
||||||
@ -46,7 +46,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
await ruckus.close()
|
await ruckus.close()
|
||||||
raise ConfigEntryAuthFailed from autherr
|
raise ConfigEntryAuthFailed from autherr
|
||||||
|
|
||||||
coordinator = RuckusUnleashedDataUpdateCoordinator(hass, ruckus=ruckus)
|
coordinator = RuckusDataUpdateCoordinator(hass, ruckus=ruckus)
|
||||||
|
|
||||||
await coordinator.async_config_entry_first_refresh()
|
await coordinator.async_config_entry_first_refresh()
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
"""Config flow for Ruckus Unleashed integration."""
|
"""Config flow for Ruckus integration."""
|
||||||
|
|
||||||
from collections.abc import Mapping
|
from collections.abc import Mapping
|
||||||
import logging
|
import logging
|
||||||
@ -59,8 +59,8 @@ async def validate_input(hass: HomeAssistant, data):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class RuckusUnleashedConfigFlow(ConfigFlow, domain=DOMAIN):
|
class RuckusConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow for Ruckus Unleashed."""
|
"""Handle a config flow for Ruckus."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
"""Constants for the Ruckus Unleashed integration."""
|
"""Constants for the Ruckus integration."""
|
||||||
|
|
||||||
from homeassistant.const import Platform
|
from homeassistant.const import Platform
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
"""Ruckus Unleashed DataUpdateCoordinator."""
|
"""Ruckus DataUpdateCoordinator."""
|
||||||
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
@ -15,11 +15,11 @@ from .const import API_CLIENT_MAC, DOMAIN, KEY_SYS_CLIENTS, SCAN_INTERVAL
|
|||||||
_LOGGER = logging.getLogger(__package__)
|
_LOGGER = logging.getLogger(__package__)
|
||||||
|
|
||||||
|
|
||||||
class RuckusUnleashedDataUpdateCoordinator(DataUpdateCoordinator):
|
class RuckusDataUpdateCoordinator(DataUpdateCoordinator):
|
||||||
"""Coordinator to manage data from Ruckus Unleashed client."""
|
"""Coordinator to manage data from Ruckus client."""
|
||||||
|
|
||||||
def __init__(self, hass: HomeAssistant, *, ruckus: AjaxSession) -> None:
|
def __init__(self, hass: HomeAssistant, *, ruckus: AjaxSession) -> None:
|
||||||
"""Initialize global Ruckus Unleashed data updater."""
|
"""Initialize global Ruckus data updater."""
|
||||||
self.ruckus = ruckus
|
self.ruckus = ruckus
|
||||||
|
|
||||||
update_interval = timedelta(seconds=SCAN_INTERVAL)
|
update_interval = timedelta(seconds=SCAN_INTERVAL)
|
||||||
@ -38,7 +38,7 @@ class RuckusUnleashedDataUpdateCoordinator(DataUpdateCoordinator):
|
|||||||
return {client[API_CLIENT_MAC]: client for client in clients}
|
return {client[API_CLIENT_MAC]: client for client in clients}
|
||||||
|
|
||||||
async def _async_update_data(self) -> dict:
|
async def _async_update_data(self) -> dict:
|
||||||
"""Fetch Ruckus Unleashed data."""
|
"""Fetch Ruckus data."""
|
||||||
try:
|
try:
|
||||||
return {KEY_SYS_CLIENTS: await self._fetch_clients()}
|
return {KEY_SYS_CLIENTS: await self._fetch_clients()}
|
||||||
except AuthenticationError as autherror:
|
except AuthenticationError as autherror:
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
"""Support for Ruckus Unleashed devices."""
|
"""Support for Ruckus devices."""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ from .const import (
|
|||||||
KEY_SYS_CLIENTS,
|
KEY_SYS_CLIENTS,
|
||||||
UNDO_UPDATE_LISTENERS,
|
UNDO_UPDATE_LISTENERS,
|
||||||
)
|
)
|
||||||
from .coordinator import RuckusUnleashedDataUpdateCoordinator
|
from .coordinator import RuckusDataUpdateCoordinator
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__package__)
|
_LOGGER = logging.getLogger(__package__)
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ _LOGGER = logging.getLogger(__package__)
|
|||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up device tracker for Ruckus Unleashed component."""
|
"""Set up device tracker for Ruckus component."""
|
||||||
coordinator = hass.data[DOMAIN][entry.entry_id][COORDINATOR]
|
coordinator = hass.data[DOMAIN][entry.entry_id][COORDINATOR]
|
||||||
|
|
||||||
tracked: set[str] = set()
|
tracked: set[str] = set()
|
||||||
@ -58,9 +58,7 @@ def add_new_entities(coordinator, async_add_entities, tracked):
|
|||||||
|
|
||||||
device = coordinator.data[KEY_SYS_CLIENTS][mac]
|
device = coordinator.data[KEY_SYS_CLIENTS][mac]
|
||||||
_LOGGER.debug("adding new device: [%s] %s", mac, device[API_CLIENT_HOSTNAME])
|
_LOGGER.debug("adding new device: [%s] %s", mac, device[API_CLIENT_HOSTNAME])
|
||||||
new_tracked.append(
|
new_tracked.append(RuckusDevice(coordinator, mac, device[API_CLIENT_HOSTNAME]))
|
||||||
RuckusUnleashedDevice(coordinator, mac, device[API_CLIENT_HOSTNAME])
|
|
||||||
)
|
|
||||||
tracked.add(mac)
|
tracked.add(mac)
|
||||||
|
|
||||||
async_add_entities(new_tracked)
|
async_add_entities(new_tracked)
|
||||||
@ -69,13 +67,13 @@ def add_new_entities(coordinator, async_add_entities, tracked):
|
|||||||
@callback
|
@callback
|
||||||
def restore_entities(
|
def restore_entities(
|
||||||
registry: er.EntityRegistry,
|
registry: er.EntityRegistry,
|
||||||
coordinator: RuckusUnleashedDataUpdateCoordinator,
|
coordinator: RuckusDataUpdateCoordinator,
|
||||||
entry: ConfigEntry,
|
entry: ConfigEntry,
|
||||||
async_add_entities: AddEntitiesCallback,
|
async_add_entities: AddEntitiesCallback,
|
||||||
tracked: set[str],
|
tracked: set[str],
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Restore clients that are not a part of active clients list."""
|
"""Restore clients that are not a part of active clients list."""
|
||||||
missing: list[RuckusUnleashedDevice] = []
|
missing: list[RuckusDevice] = []
|
||||||
|
|
||||||
for entity in registry.entities.get_entries_for_config_entry_id(entry.entry_id):
|
for entity in registry.entities.get_entries_for_config_entry_id(entry.entry_id):
|
||||||
if (
|
if (
|
||||||
@ -83,9 +81,7 @@ def restore_entities(
|
|||||||
and entity.unique_id not in coordinator.data[KEY_SYS_CLIENTS]
|
and entity.unique_id not in coordinator.data[KEY_SYS_CLIENTS]
|
||||||
):
|
):
|
||||||
missing.append(
|
missing.append(
|
||||||
RuckusUnleashedDevice(
|
RuckusDevice(coordinator, entity.unique_id, entity.original_name)
|
||||||
coordinator, entity.unique_id, entity.original_name
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
tracked.add(entity.unique_id)
|
tracked.add(entity.unique_id)
|
||||||
|
|
||||||
@ -93,11 +89,11 @@ def restore_entities(
|
|||||||
async_add_entities(missing)
|
async_add_entities(missing)
|
||||||
|
|
||||||
|
|
||||||
class RuckusUnleashedDevice(CoordinatorEntity, ScannerEntity):
|
class RuckusDevice(CoordinatorEntity, ScannerEntity):
|
||||||
"""Representation of a Ruckus Unleashed client."""
|
"""Representation of a Ruckus client."""
|
||||||
|
|
||||||
def __init__(self, coordinator, mac, name) -> None:
|
def __init__(self, coordinator, mac, name) -> None:
|
||||||
"""Initialize a Ruckus Unleashed client."""
|
"""Initialize a Ruckus client."""
|
||||||
super().__init__(coordinator)
|
super().__init__(coordinator)
|
||||||
self._mac = mac
|
self._mac = mac
|
||||||
self._name = name
|
self._name = name
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"domain": "ruckus_unleashed",
|
"domain": "ruckus_unleashed",
|
||||||
"name": "Ruckus Unleashed",
|
"name": "Ruckus",
|
||||||
"codeowners": ["@lanrat", "@ms264556", "@gabe565"],
|
"codeowners": ["@lanrat", "@ms264556", "@gabe565"],
|
||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"documentation": "https://www.home-assistant.io/integrations/ruckus_unleashed",
|
"documentation": "https://www.home-assistant.io/integrations/ruckus_unleashed",
|
||||||
|
@ -5208,7 +5208,7 @@
|
|||||||
"iot_class": "local_push"
|
"iot_class": "local_push"
|
||||||
},
|
},
|
||||||
"ruckus_unleashed": {
|
"ruckus_unleashed": {
|
||||||
"name": "Ruckus Unleashed",
|
"name": "Ruckus",
|
||||||
"integration_type": "hub",
|
"integration_type": "hub",
|
||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"iot_class": "local_polling"
|
"iot_class": "local_polling"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
"""Tests for the Ruckus Unleashed integration."""
|
"""Tests for the Ruckus integration."""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ DEFAULT_UNIQUEID = DEFAULT_SYSTEM_INFO[API_SYS_SYSINFO][API_SYS_SYSINFO_SERIAL]
|
|||||||
|
|
||||||
|
|
||||||
def mock_config_entry() -> MockConfigEntry:
|
def mock_config_entry() -> MockConfigEntry:
|
||||||
"""Return a Ruckus Unleashed mock config entry."""
|
"""Return a Ruckus mock config entry."""
|
||||||
return MockConfigEntry(
|
return MockConfigEntry(
|
||||||
domain=DOMAIN,
|
domain=DOMAIN,
|
||||||
title=DEFAULT_TITLE,
|
title=DEFAULT_TITLE,
|
||||||
@ -89,7 +89,7 @@ def mock_config_entry() -> MockConfigEntry:
|
|||||||
|
|
||||||
|
|
||||||
async def init_integration(hass: HomeAssistant) -> MockConfigEntry:
|
async def init_integration(hass: HomeAssistant) -> MockConfigEntry:
|
||||||
"""Set up the Ruckus Unleashed integration in Home Assistant."""
|
"""Set up the Ruckus integration in Home Assistant."""
|
||||||
entry = mock_config_entry()
|
entry = mock_config_entry()
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
# Make device tied to other integration so device tracker entities get enabled
|
# Make device tied to other integration so device tracker entities get enabled
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
"""Test the Ruckus Unleashed config flow."""
|
"""Test the config flow."""
|
||||||
|
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
"""The sensor tests for the Ruckus Unleashed platform."""
|
"""The sensor tests for the Ruckus platform."""
|
||||||
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from unittest.mock import AsyncMock
|
from unittest.mock import AsyncMock
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
"""Test the Ruckus Unleashed config flow."""
|
"""Test the Ruckus config flow."""
|
||||||
|
|
||||||
from unittest.mock import AsyncMock
|
from unittest.mock import AsyncMock
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user