Remove weblink integration (#32024)

This commit is contained in:
Franck Nijhof 2020-02-20 17:50:40 +01:00 committed by GitHub
parent a7d5e898ba
commit 5c5f839119
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 0 additions and 245 deletions

View File

@ -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

View File

@ -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):

View File

@ -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

View File

@ -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"
}

View File

@ -1 +0,0 @@
"""Tests for the weblink component."""

View File

@ -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/"