Update link to docs and add docstrings
This commit is contained in:
parent
2da422fd77
commit
5cea8fda9f
1 changed files with 6 additions and 9 deletions
|
@ -2,21 +2,17 @@
|
||||||
"""
|
"""
|
||||||
homeassistant.components.weblink
|
homeassistant.components.weblink
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Adds links to external webpage
|
Adds links to external webpages.
|
||||||
|
|
||||||
For more details about this component, please refer to the documentation at
|
For more details about this component, please refer to the documentation at
|
||||||
https://home-assistant.io/components/webpage/
|
https://home-assistant.io/components/weblink/
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# The domain of your component. Should be equal to the name of your component
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.util import slugify
|
from homeassistant.util import slugify
|
||||||
|
|
||||||
DOMAIN = "weblink"
|
DOMAIN = "weblink"
|
||||||
|
|
||||||
# List of component names (string) your component depends upon
|
|
||||||
DEPENDENCIES = []
|
DEPENDENCIES = []
|
||||||
|
|
||||||
ATTR_NAME = 'name'
|
ATTR_NAME = 'name'
|
||||||
|
@ -41,15 +37,13 @@ def setup(hass, config):
|
||||||
Link(hass, link.get(ATTR_NAME), link.get(ATTR_URL),
|
Link(hass, link.get(ATTR_NAME), link.get(ATTR_URL),
|
||||||
link.get(ATTR_ICON))
|
link.get(ATTR_ICON))
|
||||||
|
|
||||||
# return boolean to indicate that initialization was successful
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
class Link(Entity):
|
class Link(Entity):
|
||||||
""" Represent a link """
|
""" Represent a link. """
|
||||||
|
|
||||||
def __init__(self, hass, name, url, icon):
|
def __init__(self, hass, name, url, icon):
|
||||||
""" Represents a link. """
|
|
||||||
self.hass = hass
|
self.hass = hass
|
||||||
self._name = name
|
self._name = name
|
||||||
self._url = url
|
self._url = url
|
||||||
|
@ -59,12 +53,15 @@ class Link(Entity):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def icon(self):
|
def icon(self):
|
||||||
|
""" Icon to use in the frontend, if any. """
|
||||||
return self._icon
|
return self._icon
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
|
""" Returns the name of the URL. """
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
|
""" Returns the URL. """
|
||||||
return self._url
|
return self._url
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue