diff --git a/homeassistant/components/ee_brightbox/__init__.py b/homeassistant/components/ee_brightbox/__init__.py deleted file mode 100644 index bec0886ae07..00000000000 --- a/homeassistant/components/ee_brightbox/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""The ee_brightbox component.""" diff --git a/homeassistant/components/ee_brightbox/device_tracker.py b/homeassistant/components/ee_brightbox/device_tracker.py deleted file mode 100644 index f29eaf6f948..00000000000 --- a/homeassistant/components/ee_brightbox/device_tracker.py +++ /dev/null @@ -1,103 +0,0 @@ -"""Support for EE Brightbox router.""" -import logging - -# pylint: disable=import-error -from eebrightbox import EEBrightBox, EEBrightBoxException -import voluptuous as vol - -from homeassistant.components.device_tracker import ( - DOMAIN, - PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA, - DeviceScanner, -) -from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME -import homeassistant.helpers.config_validation as cv - -_LOGGER = logging.getLogger(__name__) - -CONF_VERSION = "version" - -CONF_DEFAULT_IP = "192.168.1.1" -CONF_DEFAULT_USERNAME = "admin" -CONF_DEFAULT_VERSION = 2 - -PLATFORM_SCHEMA = PARENT_PLATFORM_SCHEMA.extend( - { - vol.Required(CONF_VERSION, default=CONF_DEFAULT_VERSION): cv.positive_int, - vol.Required(CONF_HOST, default=CONF_DEFAULT_IP): cv.string, - vol.Required(CONF_USERNAME, default=CONF_DEFAULT_USERNAME): cv.string, - vol.Required(CONF_PASSWORD): cv.string, - } -) - - -def get_scanner(hass, config): - """Return a router scanner instance.""" - scanner = EEBrightBoxScanner(config[DOMAIN]) - - return scanner if scanner.check_config() else None - - -class EEBrightBoxScanner(DeviceScanner): - """Scan EE Brightbox router.""" - - def __init__(self, config): - """Initialise the scanner.""" - self.config = config - self.devices = {} - - def check_config(self): - """Check if provided configuration and credentials are correct.""" - try: - with EEBrightBox(self.config) as ee_brightbox: - return bool(ee_brightbox.get_devices()) - except EEBrightBoxException: - _LOGGER.exception("Failed to connect to the router") - return False - - def scan_devices(self): - """Scan for devices.""" - with EEBrightBox(self.config) as ee_brightbox: - self.devices = {d["mac"]: d for d in ee_brightbox.get_devices()} - - macs = [d["mac"] for d in self.devices.values() if d["activity_ip"]] - - _LOGGER.debug("Scan devices %s", macs) - - return macs - - def get_device_name(self, device): - """Get the name of a device from hostname.""" - if device in self.devices: - return self.devices[device]["hostname"] or None - - return None - - def get_extra_attributes(self, device): - """ - Get the extra attributes of a device. - - Extra attributes include: - - ip - - mac - - port - ethX or wifiX - - last_active - """ - port_map = { - "wl1": "wifi5Ghz", - "wl0": "wifi2.4Ghz", - "eth0": "eth0", - "eth1": "eth1", - "eth2": "eth2", - "eth3": "eth3", - } - - if device in self.devices: - return { - "ip": self.devices[device]["ip"], - "mac": self.devices[device]["mac"], - "port": port_map[self.devices[device]["port"]], - "last_active": self.devices[device]["time_last_active"], - } - - return {} diff --git a/homeassistant/components/ee_brightbox/manifest.json b/homeassistant/components/ee_brightbox/manifest.json deleted file mode 100644 index b7aae9f5a87..00000000000 --- a/homeassistant/components/ee_brightbox/manifest.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "domain": "ee_brightbox", - "name": "EE Bright Box", - "disabled": "Library has incompatible requirements.", - "documentation": "https://www.home-assistant.io/integrations/ee_brightbox", - "requirements": ["eebrightbox==0.0.4"], - "codeowners": [], - "iot_class": "local_polling" -} diff --git a/tests/components/ee_brightbox/__init__.py b/tests/components/ee_brightbox/__init__.py deleted file mode 100644 index 03abf6af02a..00000000000 --- a/tests/components/ee_brightbox/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""Tests for the ee_brightbox component.""" diff --git a/tests/components/ee_brightbox/test_device_tracker.py b/tests/components/ee_brightbox/test_device_tracker.py deleted file mode 100644 index afe3897eff9..00000000000 --- a/tests/components/ee_brightbox/test_device_tracker.py +++ /dev/null @@ -1,123 +0,0 @@ -"""Tests for the EE BrightBox device scanner.""" -from datetime import datetime -from unittest.mock import patch - -# Integration is disabled -# from eebrightbox import EEBrightBoxException -import pytest - -from homeassistant.components.device_tracker import DOMAIN -from homeassistant.const import CONF_PASSWORD, CONF_PLATFORM -from homeassistant.setup import async_setup_component - -# Integration is disabled -pytest.skip("Integration has been disabled in the manifest", allow_module_level=True) - - -def _configure_mock_get_devices(eebrightbox_mock): - eebrightbox_instance = eebrightbox_mock.return_value - eebrightbox_instance.__enter__.return_value = eebrightbox_instance - eebrightbox_instance.get_devices.return_value = [ - { - "mac": "AA:BB:CC:DD:EE:FF", - "ip": "192.168.1.10", - "hostname": "hostnameAA", - "activity_ip": True, - "port": "eth0", - "time_last_active": datetime(2019, 1, 20, 16, 4, 0), - }, - { - "mac": "11:22:33:44:55:66", - "hostname": "hostname11", - "ip": "192.168.1.11", - "activity_ip": True, - "port": "wl0", - "time_last_active": datetime(2019, 1, 20, 11, 9, 0), - }, - { - "mac": "FF:FF:FF:FF:FF:FF", - "hostname": "hostnameFF", - "ip": "192.168.1.12", - "activity_ip": False, - "port": "wl1", - "time_last_active": datetime(2019, 1, 15, 16, 9, 0), - }, - ] - - -def _configure_mock_failed_config_check(eebrightbox_mock): - eebrightbox_instance = eebrightbox_mock.return_value - # Integration is disabled - eebrightbox_instance.__enter__.side_effect = EEBrightBoxException( # noqa: F821 - "Failed to connect to the router" - ) - - -@pytest.fixture(autouse=True) -def mock_dev_track(mock_device_tracker_conf): - """Mock device tracker config loading.""" - pass - - -@patch("homeassistant.components.ee_brightbox.device_tracker.EEBrightBox") -async def test_missing_credentials(eebrightbox_mock, hass): - """Test missing credentials.""" - _configure_mock_get_devices(eebrightbox_mock) - - result = await async_setup_component( - hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "ee_brightbox"}} - ) - - assert result - - await hass.async_block_till_done() - - assert hass.states.get("device_tracker.hostnameaa") is None - assert hass.states.get("device_tracker.hostname11") is None - assert hass.states.get("device_tracker.hostnameff") is None - - -@patch("homeassistant.components.ee_brightbox.device_tracker.EEBrightBox") -async def test_invalid_credentials(eebrightbox_mock, hass): - """Test invalid credentials.""" - _configure_mock_failed_config_check(eebrightbox_mock) - - result = await async_setup_component( - hass, - DOMAIN, - {DOMAIN: {CONF_PLATFORM: "ee_brightbox", CONF_PASSWORD: "test_password"}}, - ) - - assert result - - await hass.async_block_till_done() - - assert hass.states.get("device_tracker.hostnameaa") is None - assert hass.states.get("device_tracker.hostname11") is None - assert hass.states.get("device_tracker.hostnameff") is None - - -@patch("homeassistant.components.ee_brightbox.device_tracker.EEBrightBox") -async def test_get_devices(eebrightbox_mock, hass): - """Test valid configuration.""" - _configure_mock_get_devices(eebrightbox_mock) - - result = await async_setup_component( - hass, - DOMAIN, - {DOMAIN: {CONF_PLATFORM: "ee_brightbox", CONF_PASSWORD: "test_password"}}, - ) - - assert result - - await hass.async_block_till_done() - - assert hass.states.get("device_tracker.hostnameaa") is not None - assert hass.states.get("device_tracker.hostname11") is not None - assert hass.states.get("device_tracker.hostnameff") is None - - state = hass.states.get("device_tracker.hostnameaa") - assert state.attributes["mac"] == "AA:BB:CC:DD:EE:FF" - assert state.attributes["ip"] == "192.168.1.10" - assert state.attributes["port"] == "eth0" - assert state.attributes["last_active"] == datetime(2019, 1, 20, 16, 4, 0)