Update link to docs and add docstrings

This commit is contained in:
Fabian Affolter 2016-02-02 23:55:44 +01:00
parent 2da422fd77
commit 5cea8fda9f

View file

@ -2,21 +2,17 @@
"""
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
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
from homeassistant.helpers.entity import Entity
from homeassistant.util import slugify
DOMAIN = "weblink"
# List of component names (string) your component depends upon
DEPENDENCIES = []
ATTR_NAME = 'name'
@ -41,15 +37,13 @@ def setup(hass, config):
Link(hass, link.get(ATTR_NAME), link.get(ATTR_URL),
link.get(ATTR_ICON))
# return boolean to indicate that initialization was successful
return True
class Link(Entity):
""" Represent a link """
""" Represent a link. """
def __init__(self, hass, name, url, icon):
""" Represents a link. """
self.hass = hass
self._name = name
self._url = url
@ -59,12 +53,15 @@ class Link(Entity):
@property
def icon(self):
""" Icon to use in the frontend, if any. """
return self._icon
@property
def name(self):
""" Returns the name of the URL. """
return self._name
@property
def state(self):
""" Returns the URL. """
return self._url