diff --git a/CODEOWNERS b/CODEOWNERS index a8057197827..b1d81bafa2a 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -392,7 +392,6 @@ homeassistant/components/vlc_telnet/* @rodripf homeassistant/components/waqi/* @andrey-git homeassistant/components/watson_tts/* @rutkai homeassistant/components/weather/* @fabaff -homeassistant/components/weblink/* @home-assistant/core homeassistant/components/webostv/* @bendavid homeassistant/components/websocket_api/* @home-assistant/core homeassistant/components/wemo/* @sqldiablo diff --git a/homeassistant/components/demo/__init__.py b/homeassistant/components/demo/__init__.py index b6845d9d6a4..a5b8aa9db7f 100644 --- a/homeassistant/components/demo/__init__.py +++ b/homeassistant/components/demo/__init__.py @@ -124,19 +124,6 @@ async def async_setup(hass, config): ) ) - # Set up weblink - tasks.append( - bootstrap.async_setup_component( - hass, - "weblink", - { - "weblink": { - "entities": [{"name": "Router", "url": "http://192.168.1.1"}] - } - }, - ) - ) - results = await asyncio.gather(*tasks) if any(not result for result in results): diff --git a/homeassistant/components/weblink/__init__.py b/homeassistant/components/weblink/__init__.py deleted file mode 100644 index 8a770f916bd..00000000000 --- a/homeassistant/components/weblink/__init__.py +++ /dev/null @@ -1,78 +0,0 @@ -"""Support for links to external web pages.""" -import logging - -import voluptuous as vol - -from homeassistant.const import CONF_ICON, CONF_NAME, CONF_URL -import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity -from homeassistant.util import slugify - -_LOGGER = logging.getLogger(__name__) - -CONF_ENTITIES = "entities" -CONF_RELATIVE_URL_ERROR_MSG = "Invalid relative URL. Absolute path required." -CONF_RELATIVE_URL_REGEX = r"\A/" - -DOMAIN = "weblink" - -ENTITIES_SCHEMA = vol.Schema( - { - # pylint: disable=no-value-for-parameter - vol.Required(CONF_URL): vol.Any( - vol.Match(CONF_RELATIVE_URL_REGEX, msg=CONF_RELATIVE_URL_ERROR_MSG), - vol.Url(), - ), - vol.Required(CONF_NAME): cv.string, - vol.Optional(CONF_ICON): cv.icon, - } -) - -CONFIG_SCHEMA = vol.Schema( - {DOMAIN: vol.Schema({vol.Required(CONF_ENTITIES): [ENTITIES_SCHEMA]})}, - extra=vol.ALLOW_EXTRA, -) - - -def setup(hass, config): - """Set up the weblink component.""" - _LOGGER.warning( - "The weblink integration has been deprecated and is pending for removal " - "in Home Assistant 0.107.0. Please use this instead: " - "https://www.home-assistant.io/lovelace/entities/#weblink" - ) - - links = config.get(DOMAIN) - - for link in links.get(CONF_ENTITIES): - Link(hass, link.get(CONF_NAME), link.get(CONF_URL), link.get(CONF_ICON)) - - return True - - -class Link(Entity): - """Representation of a link.""" - - def __init__(self, hass, name, url, icon): - """Initialize the link.""" - self.hass = hass - self._name = name - self._url = url - self._icon = icon - self.entity_id = DOMAIN + ".%s" % slugify(name) - self.schedule_update_ha_state() - - @property - def icon(self): - """Return the icon to use in the frontend, if any.""" - return self._icon - - @property - def name(self): - """Return the name of the URL.""" - return self._name - - @property - def state(self): - """Return the URL.""" - return self._url diff --git a/homeassistant/components/weblink/manifest.json b/homeassistant/components/weblink/manifest.json deleted file mode 100644 index 28ffa581bb8..00000000000 --- a/homeassistant/components/weblink/manifest.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "domain": "weblink", - "name": "Weblink", - "documentation": "https://www.home-assistant.io/integrations/weblink", - "requirements": [], - "dependencies": [], - "codeowners": ["@home-assistant/core"], - "quality_scale": "internal" -} diff --git a/tests/components/weblink/__init__.py b/tests/components/weblink/__init__.py deleted file mode 100644 index 1d58e9c24d6..00000000000 --- a/tests/components/weblink/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""Tests for the weblink component.""" diff --git a/tests/components/weblink/test_init.py b/tests/components/weblink/test_init.py deleted file mode 100644 index 5f803107c46..00000000000 --- a/tests/components/weblink/test_init.py +++ /dev/null @@ -1,143 +0,0 @@ -"""The tests for the weblink component.""" -import unittest - -from homeassistant.components import weblink -from homeassistant.setup import setup_component - -from tests.common import get_test_home_assistant - - -class TestComponentWeblink(unittest.TestCase): - """Test the Weblink component.""" - - def setUp(self): - """Set up things to be run when tests are started.""" - self.hass = get_test_home_assistant() - - def tearDown(self): - """Stop everything that was started.""" - self.hass.stop() - - def test_bad_config(self): - """Test if new entity is created.""" - assert not setup_component( - self.hass, "weblink", {"weblink": {"entities": [{}]}} - ) - - def test_bad_config_relative_url(self): - """Test if new entity is created.""" - assert not setup_component( - self.hass, - "weblink", - { - "weblink": { - "entities": [ - { - weblink.CONF_NAME: "My router", - weblink.CONF_URL: "../states/group.bla", - } - ] - } - }, - ) - - def test_bad_config_relative_file(self): - """Test if new entity is created.""" - assert not setup_component( - self.hass, - "weblink", - { - "weblink": { - "entities": [ - {weblink.CONF_NAME: "My group", weblink.CONF_URL: "group.bla"} - ] - } - }, - ) - - def test_good_config_absolute_path(self): - """Test if new entity is created.""" - assert setup_component( - self.hass, - "weblink", - { - "weblink": { - "entities": [ - { - weblink.CONF_NAME: "My second URL", - weblink.CONF_URL: "/states/group.bla", - } - ] - } - }, - ) - - def test_good_config_path_short(self): - """Test if new entity is created.""" - assert setup_component( - self.hass, - "weblink", - { - "weblink": { - "entities": [ - {weblink.CONF_NAME: "My third URL", weblink.CONF_URL: "/states"} - ] - } - }, - ) - - def test_good_config_path_directory(self): - """Test if new entity is created.""" - assert setup_component( - self.hass, - "weblink", - { - "weblink": { - "entities": [ - { - weblink.CONF_NAME: "My last URL", - weblink.CONF_URL: "/states/bla/", - } - ] - } - }, - ) - - def test_good_config_ftp_link(self): - """Test if new entity is created.""" - assert setup_component( - self.hass, - "weblink", - { - "weblink": { - "entities": [ - { - weblink.CONF_NAME: "My FTP URL", - weblink.CONF_URL: "ftp://somehost/", - } - ] - } - }, - ) - - def test_entities_get_created(self): - """Test if new entity is created.""" - assert setup_component( - self.hass, - weblink.DOMAIN, - { - weblink.DOMAIN: { - "entities": [ - { - weblink.CONF_NAME: "My router", - weblink.CONF_URL: "http://127.0.0.1/", - } - ] - } - }, - ) - - state = self.hass.states.get("weblink.my_router") - - assert state is not None - assert state.state == "http://127.0.0.1/"