Rename various usages of UniFi to better identify only UniFi Network (#59568)

* Renames various usages of UniFi to better indentify only UniFi Network

* Apply suggestions from code review

Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com>

* Missed renames

* Updates more locations

* Removes instances of application/controller

* Missed a spot

* Updates all UniFi Controller instances

* Fixes typo

* Reverts changes to translations

Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com>
This commit is contained in:
Christopher Bailey 2021-11-26 16:44:49 -05:00 committed by GitHub
parent 296b738740
commit 5a72c9f7c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 75 additions and 67 deletions

View File

@ -1,4 +1,4 @@
"""Integration to UniFi controllers and its various features."""
"""Integration to UniFi Network and its various features."""
from homeassistant.const import EVENT_HOMEASSISTANT_STOP
from homeassistant.core import callback
from homeassistant.helpers import device_registry as dr
@ -20,7 +20,7 @@ STORAGE_VERSION = 1
async def async_setup(hass, config):
"""Component doesn't support configuration through configuration.yaml."""
"""Integration doesn't support configuration through configuration.yaml."""
hass.data[UNIFI_WIRELESS_CLIENTS] = wireless_clients = UnifiWirelessClients(hass)
await wireless_clients.async_load()
@ -28,7 +28,7 @@ async def async_setup(hass, config):
async def async_setup_entry(hass, config_entry):
"""Set up the UniFi component."""
"""Set up the UniFi Network integration."""
hass.data.setdefault(UNIFI_DOMAIN, {})
# Flat configuration was introduced with 2021.3
@ -53,7 +53,7 @@ async def async_setup_entry(hass, config_entry):
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, controller.shutdown)
)
LOGGER.debug("UniFi config options %s", config_entry.options)
LOGGER.debug("UniFi Network config options %s", config_entry.options)
if controller.mac is None:
return True
@ -64,8 +64,8 @@ async def async_setup_entry(hass, config_entry):
configuration_url=controller.api.url,
connections={(CONNECTION_NETWORK_MAC, controller.mac)},
default_manufacturer=ATTR_MANUFACTURER,
default_model="UniFi Controller",
default_name="UniFi Controller",
default_model="UniFi Network",
default_name="UniFi Network",
)
return True

View File

@ -1,8 +1,8 @@
"""Config flow for UniFi.
"""Config flow for UniFi Network integration.
Provides user initiated configuration flow.
Discovery of controllers hosted on UDM and UDM Pro devices through SSDP.
Reauthentication when issue with credentials are reported.
Discovery of UniFi Network instances hosted on UDM and UDM Pro devices
through SSDP. Reauthentication when issue with credentials are reported.
Configuration of options through options flow.
"""
import socket
@ -56,7 +56,7 @@ MODEL_PORTS = {
class UnifiFlowHandler(config_entries.ConfigFlow, domain=UNIFI_DOMAIN):
"""Handle a UniFi config flow."""
"""Handle a UniFi Network config flow."""
VERSION = 1
@ -67,7 +67,7 @@ class UnifiFlowHandler(config_entries.ConfigFlow, domain=UNIFI_DOMAIN):
return UnifiOptionsFlowHandler(config_entry)
def __init__(self):
"""Initialize the UniFi flow."""
"""Initialize the UniFi Network flow."""
self.config = {}
self.site_ids = {}
self.site_names = {}
@ -242,16 +242,16 @@ class UnifiFlowHandler(config_entries.ConfigFlow, domain=UNIFI_DOMAIN):
class UnifiOptionsFlowHandler(config_entries.OptionsFlow):
"""Handle Unifi options."""
"""Handle Unifi Network options."""
def __init__(self, config_entry):
"""Initialize UniFi options flow."""
"""Initialize UniFi Network options flow."""
self.config_entry = config_entry
self.options = dict(config_entry.options)
self.controller = None
async def async_step_init(self, user_input=None):
"""Manage the UniFi options."""
"""Manage the UniFi Network options."""
self.controller = self.hass.data[UNIFI_DOMAIN][self.config_entry.entry_id]
self.options[CONF_BLOCK_CLIENT] = self.controller.option_block_clients
@ -416,7 +416,7 @@ class UnifiOptionsFlowHandler(config_entries.OptionsFlow):
async def async_discover_unifi(hass):
"""Discover UniFi address."""
"""Discover UniFi Network address."""
try:
return await hass.async_add_executor_job(socket.gethostbyname, "unifi")
except socket.gaierror:

View File

@ -1,4 +1,4 @@
"""Constants for the UniFi component."""
"""Constants for the UniFi Network integration."""
import logging
LOGGER = logging.getLogger(__package__)

View File

@ -1,4 +1,4 @@
"""UniFi Controller abstraction."""
"""UniFi Network abstraction."""
from __future__ import annotations
import asyncio
@ -90,7 +90,7 @@ DEVICE_CONNECTED = (
class UniFiController:
"""Manages a single UniFi Controller."""
"""Manages a single UniFi Network instance."""
def __init__(self, hass, config_entry):
"""Initialize the system."""
@ -198,7 +198,7 @@ class UniFiController:
if signal == SIGNAL_CONNECTION_STATE:
if data == STATE_DISCONNECTED and self.available:
LOGGER.warning("Lost connection to UniFi controller")
LOGGER.warning("Lost connection to UniFi Network")
if (data == STATE_RUNNING and not self.available) or (
data == STATE_DISCONNECTED and self.available
@ -209,7 +209,7 @@ class UniFiController:
if not self.available:
self.hass.loop.call_later(RETRY_TIMER, self.reconnect, True)
else:
LOGGER.info("Connected to UniFi controller")
LOGGER.info("Connected to UniFi Network")
elif signal == SIGNAL_DATA and data:
@ -301,7 +301,7 @@ class UniFiController:
unifi_wireless_clients.update_data(self.wireless_clients, self.config_entry)
async def async_setup(self):
"""Set up a UniFi controller."""
"""Set up a UniFi Network instance."""
try:
self.api = await get_controller(
self.hass,
@ -413,11 +413,11 @@ class UniFiController:
def reconnect(self, log=False) -> None:
"""Prepare to reconnect UniFi session."""
if log:
LOGGER.info("Will try to reconnect to UniFi controller")
LOGGER.info("Will try to reconnect to UniFi Network")
self.hass.loop.create_task(self.async_reconnect())
async def async_reconnect(self) -> None:
"""Try to reconnect UniFi session."""
"""Try to reconnect UniFi Network session."""
try:
async with async_timeout.timeout(5):
await self.api.login()
@ -494,7 +494,11 @@ async def get_controller(
return controller
except aiounifi.Unauthorized as err:
LOGGER.warning("Connected to UniFi at %s but not registered: %s", host, err)
LOGGER.warning(
"Connected to UniFi Network at %s but not registered: %s",
host,
err,
)
raise AuthenticationRequired from err
except (
@ -503,13 +507,17 @@ async def get_controller(
aiounifi.ServiceUnavailable,
aiounifi.RequestError,
) as err:
LOGGER.error("Error connecting to the UniFi controller at %s: %s", host, err)
LOGGER.error("Error connecting to the UniFi Network at %s: %s", host, err)
raise CannotConnect from err
except aiounifi.LoginRequired as err:
LOGGER.warning("Connected to UniFi at %s but login required: %s", host, err)
LOGGER.warning(
"Connected to UniFi Network at %s but login required: %s",
host,
err,
)
raise AuthenticationRequired from err
except aiounifi.AiounifiException as err:
LOGGER.exception("Unknown UniFi communication error occurred: %s", err)
LOGGER.exception("Unknown UniFi Network communication error occurred: %s", err)
raise AuthenticationRequired from err

View File

@ -1,4 +1,4 @@
"""Track both clients and devices using UniFi controllers."""
"""Track both clients and devices using UniFi Network."""
from datetime import timedelta
from aiounifi.api import SOURCE_DATA, SOURCE_EVENT
@ -72,7 +72,7 @@ WIRELESS_CONNECTION = (
async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up device tracker for UniFi component."""
"""Set up device tracker for UniFi Network integration."""
controller = hass.data[UNIFI_DOMAIN][config_entry.entry_id]
controller.entities[DOMAIN] = {CLIENT_TRACKER: set(), DEVICE_TRACKER: set()}

View File

@ -1,9 +1,9 @@
"""Errors for the UniFi component."""
"""Errors for the UniFi Network integration."""
from homeassistant.exceptions import HomeAssistantError
class UnifiException(HomeAssistantError):
"""Base class for UniFi exceptions."""
"""Base class for UniFi Network exceptions."""
class AlreadyConfigured(UnifiException):
@ -19,7 +19,7 @@ class CannotConnect(UnifiException):
class LoginRequired(UnifiException):
"""Component got logged out."""
"""Integration got logged out."""
class UserLevel(UnifiException):

View File

@ -1,6 +1,6 @@
{
"domain": "unifi",
"name": "Ubiquiti UniFi",
"name": "UniFi Network",
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/unifi",
"requirements": [
@ -23,4 +23,4 @@
}
],
"iot_class": "local_push"
}
}

View File

@ -1,4 +1,4 @@
"""Sensor platform for UniFi integration.
"""Sensor platform for UniFi Network integration.
Support for bandwidth sensors of network clients.
Support for uptime sensors of network clients.
@ -21,7 +21,7 @@ UPTIME_SENSOR = "uptime"
async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up sensors for UniFi integration."""
"""Set up sensors for UniFi Network integration."""
controller = hass.data[UNIFI_DOMAIN][config_entry.entry_id]
controller.entities[DOMAIN] = {
RX_SENSOR: set(),
@ -82,7 +82,7 @@ def add_uptime_entities(controller, async_add_entities, clients):
class UniFiBandwidthSensor(UniFiClient, SensorEntity):
"""UniFi bandwidth sensor base class."""
"""UniFi Network bandwidth sensor base class."""
DOMAIN = DOMAIN
@ -127,7 +127,7 @@ class UniFiTxBandwidthSensor(UniFiBandwidthSensor):
class UniFiUpTimeSensor(UniFiClient, SensorEntity):
"""UniFi uptime sensor."""
"""UniFi Network client uptime sensor."""
DOMAIN = DOMAIN
TYPE = UPTIME_SENSOR

View File

@ -1,4 +1,4 @@
"""UniFi services."""
"""UniFi Network services."""
import voluptuous as vol
@ -47,7 +47,7 @@ def async_setup_services(hass) -> None:
@callback
def async_unload_services(hass) -> None:
"""Unload UniFi services."""
"""Unload UniFi Network services."""
for service in SUPPORTED_SERVICES:
hass.services.async_remove(UNIFI_DOMAIN, service)

View File

@ -1,6 +1,6 @@
reconnect_client:
name: Reconnect wireless client
description: Try to get wireless client to reconnect to UniFi network
description: Try to get wireless client to reconnect to UniFi Network
fields:
device_id:
name: Device
@ -11,5 +11,5 @@ reconnect_client:
integration: unifi
remove_clients:
name: Remove clients from the UniFi Controller
name: Remove clients from the UniFi Network
description: Clean up clients that has only been associated with the controller for a short period of time.

View File

@ -3,7 +3,7 @@
"flow_title": "{site} ({host})",
"step": {
"user": {
"title": "Set up UniFi Controller",
"title": "Set up UniFi Network",
"data": {
"host": "[%key:common::config_flow::data::host%]",
"username": "[%key:common::config_flow::data::username%]",
@ -20,7 +20,7 @@
"unknown_client_mac": "No client available on that MAC address"
},
"abort": {
"already_configured": "Controller site is already configured",
"already_configured": "UniFi Network site is already configured",
"configuration_updated": "Configuration updated.",
"reauth_successful": "[%key:common::config_flow::abort::reauth_successful%]"
}
@ -30,14 +30,14 @@
"device_tracker": {
"data": {
"detection_time": "Time in seconds from last seen until considered away",
"ignore_wired_bug": "Disable UniFi wired bug logic",
"ignore_wired_bug": "Disable UniFi Network wired bug logic",
"ssid_filter": "Select SSIDs to track wireless clients on",
"track_clients": "Track network clients",
"track_devices": "Track network devices (Ubiquiti devices)",
"track_wired_clients": "Include wired network clients"
},
"description": "Configure device tracking",
"title": "UniFi options 1/3"
"title": "UniFi Network options 1/3"
},
"client_control": {
"data": {
@ -46,7 +46,7 @@
"dpi_restrictions": "Allow control of DPI restriction groups"
},
"description": "Configure client controls\n\nCreate switches for serial numbers you want to control network access for.",
"title": "UniFi options 2/3"
"title": "UniFi Network options 2/3"
},
"simple_options": {
"data": {
@ -54,7 +54,7 @@
"track_devices": "[%key:component::unifi::options::step::device_tracker::data::track_devices%]",
"block_client": "[%key:component::unifi::options::step::client_control::data::block_client%]"
},
"description": "Configure UniFi integration"
"description": "Configure UniFi Network integration"
},
"statistics_sensors": {
"data": {
@ -62,7 +62,7 @@
"allow_uptime_sensors": "Uptime sensors for network clients"
},
"description": "Configure statistics sensors",
"title": "UniFi options 3/3"
"title": "UniFi Network options 3/3"
}
}
}

View File

@ -1,4 +1,4 @@
"""Switch platform for UniFi integration.
"""Switch platform for UniFi Network integration.
Support for controlling power supply of clients which are powered over Ethernet (POE).
Support for controlling network access of clients selected in option flow.
@ -36,7 +36,7 @@ CLIENT_UNBLOCKED = (WIRED_CLIENT_UNBLOCKED, WIRELESS_CLIENT_UNBLOCKED)
async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up switches for UniFi component.
"""Set up switches for UniFi Network integration.
Switches are controlling network access and switch ports with POE.
"""
@ -374,6 +374,6 @@ class UniFiDPIRestrictionSwitch(UniFiBase, SwitchEntity):
entry_type=DeviceEntryType.SERVICE,
identifiers={(DOMAIN, f"unifi_controller_{self._item.site_id}")},
manufacturer=ATTR_MANUFACTURER,
model="UniFi Controller",
name="UniFi Controller",
model="UniFi Network",
name="UniFi Network",
)

View File

@ -1,4 +1,4 @@
"""Base class for UniFi entities."""
"""Base class for UniFi Network entities."""
import logging
from typing import Any
@ -18,7 +18,7 @@ class UniFiBase(Entity):
TYPE = ""
def __init__(self, item, controller) -> None:
"""Set up UniFi entity base.
"""Set up UniFi Network entity base.
Register mac to controller entities to cover disabled entities.
"""

View File

@ -1 +1 @@
"""Tests for the UniFi component."""
"""Tests for the UniFi Network integration."""

View File

@ -1,4 +1,4 @@
"""Fixtures for UniFi methods."""
"""Fixtures for UniFi Network methods."""
from __future__ import annotations
from unittest.mock import patch

View File

@ -1,4 +1,4 @@
"""Test UniFi config flow."""
"""Test UniFi Network config flow."""
import socket
from unittest.mock import patch

View File

@ -1,4 +1,4 @@
"""Test UniFi Controller."""
"""Test UniFi Network."""
import asyncio
from copy import deepcopy
@ -171,7 +171,7 @@ async def setup_unifi_integration(
unique_id="1",
config_entry_id=DEFAULT_CONFIG_ENTRY_ID,
):
"""Create the UniFi controller."""
"""Create the UniFi Network instance."""
assert await async_setup_component(hass, UNIFI_DOMAIN, {})
config_entry = MockConfigEntry(

View File

@ -1,4 +1,4 @@
"""The tests for the UniFi device tracker platform."""
"""The tests for the UniFi Network device tracker platform."""
from datetime import timedelta
from unittest.mock import patch
@ -900,7 +900,7 @@ async def test_wireless_client_go_wired_issue(
):
"""Test the solution to catch wireless device go wired UniFi issue.
UniFi has a known issue that when a wireless device goes away it sometimes gets marked as wired.
UniFi Network has a known issue that when a wireless device goes away it sometimes gets marked as wired.
"""
client = {
"essid": "ssid",

View File

@ -1,4 +1,4 @@
"""Test UniFi setup process."""
"""Test UniFi Network integration setup process."""
from unittest.mock import AsyncMock, patch
from homeassistant.components import unifi
@ -59,8 +59,8 @@ async def test_controller_mac(hass):
)
assert device.configuration_url == "https://123:443"
assert device.manufacturer == "Ubiquiti Networks"
assert device.model == "UniFi Controller"
assert device.name == "UniFi Controller"
assert device.model == "UniFi Network"
assert device.name == "UniFi Network"
assert device.sw_version is None

View File

@ -1,4 +1,4 @@
"""UniFi sensor platform tests."""
"""UniFi Network sensor platform tests."""
from datetime import datetime
from unittest.mock import patch

View File

@ -1,4 +1,4 @@
"""UniFi switch platform tests."""
"""UniFi Network switch platform tests."""
from copy import deepcopy
from unittest.mock import patch