Skip to content

Commit

Permalink
Rename "Ruckus Unleashed" integration to "Ruckus" (#125392)
Browse files Browse the repository at this point in the history
  • Loading branch information
ms264556 authored Sep 6, 2024
1 parent aba23eb commit 9777ed2
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 35 deletions.
8 changes: 4 additions & 4 deletions homeassistant/components/ruckus_unleashed/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""The Ruckus Unleashed integration."""
"""The Ruckus integration."""

import logging

Expand All @@ -24,13 +24,13 @@
PLATFORMS,
UNDO_UPDATE_LISTENERS,
)
from .coordinator import RuckusUnleashedDataUpdateCoordinator
from .coordinator import RuckusDataUpdateCoordinator

_LOGGER = logging.getLogger(__package__)


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(
entry.data[CONF_HOST],
Expand All @@ -46,7 +46,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
await ruckus.close()
raise ConfigEntryAuthFailed from autherr

coordinator = RuckusUnleashedDataUpdateCoordinator(hass, ruckus=ruckus)
coordinator = RuckusDataUpdateCoordinator(hass, ruckus=ruckus)

await coordinator.async_config_entry_first_refresh()

Expand Down
6 changes: 3 additions & 3 deletions homeassistant/components/ruckus_unleashed/config_flow.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Config flow for Ruckus Unleashed integration."""
"""Config flow for Ruckus integration."""

from collections.abc import Mapping
import logging
Expand Down Expand Up @@ -59,8 +59,8 @@ async def validate_input(hass: HomeAssistant, data):
}


class RuckusUnleashedConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Ruckus Unleashed."""
class RuckusConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Ruckus."""

VERSION = 1

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/ruckus_unleashed/const.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Constants for the Ruckus Unleashed integration."""
"""Constants for the Ruckus integration."""

from homeassistant.const import Platform

Expand Down
10 changes: 5 additions & 5 deletions homeassistant/components/ruckus_unleashed/coordinator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Ruckus Unleashed DataUpdateCoordinator."""
"""Ruckus DataUpdateCoordinator."""

from datetime import timedelta
import logging
Expand All @@ -15,11 +15,11 @@
_LOGGER = logging.getLogger(__package__)


class RuckusUnleashedDataUpdateCoordinator(DataUpdateCoordinator):
"""Coordinator to manage data from Ruckus Unleashed client."""
class RuckusDataUpdateCoordinator(DataUpdateCoordinator):
"""Coordinator to manage data from Ruckus client."""

def __init__(self, hass: HomeAssistant, *, ruckus: AjaxSession) -> None:
"""Initialize global Ruckus Unleashed data updater."""
"""Initialize global Ruckus data updater."""
self.ruckus = ruckus

update_interval = timedelta(seconds=SCAN_INTERVAL)
Expand All @@ -38,7 +38,7 @@ async def _fetch_clients(self) -> dict:
return {client[API_CLIENT_MAC]: client for client in clients}

async def _async_update_data(self) -> dict:
"""Fetch Ruckus Unleashed data."""
"""Fetch Ruckus data."""
try:
return {KEY_SYS_CLIENTS: await self._fetch_clients()}
except AuthenticationError as autherror:
Expand Down
24 changes: 10 additions & 14 deletions homeassistant/components/ruckus_unleashed/device_tracker.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Support for Ruckus Unleashed devices."""
"""Support for Ruckus devices."""

from __future__ import annotations

Expand All @@ -19,15 +19,15 @@
KEY_SYS_CLIENTS,
UNDO_UPDATE_LISTENERS,
)
from .coordinator import RuckusUnleashedDataUpdateCoordinator
from .coordinator import RuckusDataUpdateCoordinator

_LOGGER = logging.getLogger(__package__)


async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
) -> None:
"""Set up device tracker for Ruckus Unleashed component."""
"""Set up device tracker for Ruckus component."""
coordinator = hass.data[DOMAIN][entry.entry_id][COORDINATOR]

tracked: set[str] = set()
Expand Down Expand Up @@ -58,9 +58,7 @@ def add_new_entities(coordinator, async_add_entities, tracked):

device = coordinator.data[KEY_SYS_CLIENTS][mac]
_LOGGER.debug("adding new device: [%s] %s", mac, device[API_CLIENT_HOSTNAME])
new_tracked.append(
RuckusUnleashedDevice(coordinator, mac, device[API_CLIENT_HOSTNAME])
)
new_tracked.append(RuckusDevice(coordinator, mac, device[API_CLIENT_HOSTNAME]))
tracked.add(mac)

async_add_entities(new_tracked)
Expand All @@ -69,35 +67,33 @@ def add_new_entities(coordinator, async_add_entities, tracked):
@callback
def restore_entities(
registry: er.EntityRegistry,
coordinator: RuckusUnleashedDataUpdateCoordinator,
coordinator: RuckusDataUpdateCoordinator,
entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
tracked: set[str],
) -> None:
"""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):
if (
entity.platform == DOMAIN
and entity.unique_id not in coordinator.data[KEY_SYS_CLIENTS]
):
missing.append(
RuckusUnleashedDevice(
coordinator, entity.unique_id, entity.original_name
)
RuckusDevice(coordinator, entity.unique_id, entity.original_name)
)
tracked.add(entity.unique_id)

_LOGGER.debug("added %d missing devices", len(missing))
async_add_entities(missing)


class RuckusUnleashedDevice(CoordinatorEntity, ScannerEntity):
"""Representation of a Ruckus Unleashed client."""
class RuckusDevice(CoordinatorEntity, ScannerEntity):
"""Representation of a Ruckus client."""

def __init__(self, coordinator, mac, name) -> None:
"""Initialize a Ruckus Unleashed client."""
"""Initialize a Ruckus client."""
super().__init__(coordinator)
self._mac = mac
self._name = name
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/ruckus_unleashed/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"domain": "ruckus_unleashed",
"name": "Ruckus Unleashed",
"name": "Ruckus",
"codeowners": ["@lanrat", "@ms264556", "@gabe565"],
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/ruckus_unleashed",
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/generated/integrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -5208,7 +5208,7 @@
"iot_class": "local_push"
},
"ruckus_unleashed": {
"name": "Ruckus Unleashed",
"name": "Ruckus",
"integration_type": "hub",
"config_flow": true,
"iot_class": "local_polling"
Expand Down
6 changes: 3 additions & 3 deletions tests/components/ruckus_unleashed/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Tests for the Ruckus Unleashed integration."""
"""Tests for the Ruckus integration."""

from __future__ import annotations

Expand Down Expand Up @@ -78,7 +78,7 @@


def mock_config_entry() -> MockConfigEntry:
"""Return a Ruckus Unleashed mock config entry."""
"""Return a Ruckus mock config entry."""
return MockConfigEntry(
domain=DOMAIN,
title=DEFAULT_TITLE,
Expand All @@ -89,7 +89,7 @@ def mock_config_entry() -> 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.add_to_hass(hass)
# Make device tied to other integration so device tracker entities get enabled
Expand Down
2 changes: 1 addition & 1 deletion tests/components/ruckus_unleashed/test_config_flow.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Test the Ruckus Unleashed config flow."""
"""Test the config flow."""

from copy import deepcopy
from datetime import timedelta
Expand Down
2 changes: 1 addition & 1 deletion tests/components/ruckus_unleashed/test_device_tracker.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""The sensor tests for the Ruckus Unleashed platform."""
"""The sensor tests for the Ruckus platform."""

from datetime import timedelta
from unittest.mock import AsyncMock
Expand Down
2 changes: 1 addition & 1 deletion tests/components/ruckus_unleashed/test_init.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Test the Ruckus Unleashed config flow."""
"""Test the Ruckus config flow."""

from unittest.mock import AsyncMock

Expand Down

0 comments on commit 9777ed2

Please sign in to comment.