Update code examples

This commit is contained in:
Fabian Affolter 2016-02-22 16:11:39 +01:00
parent 56b2ce7cef
commit ccbef55136
3 changed files with 20 additions and 20 deletions

View file

@ -13,15 +13,15 @@ ha_category: Custom Python Component Examples
This is a simple hello world example to show the basics for setting a state. To use this example, create the file `<config dir>/custom_components/hello_state.py` and copy the below example code.
```python
# The domain of your component. Should be equal to the name of your component
DOMAIN = "hello_state"
# The domain of your component. Should be equal to the name of your component.
DOMAIN = 'hello_state'
CONF_NAME = 'name'
DEFAULT_NAME = 'World'
def setup(hass, config):
""" Setup is called when Home Assistant is loading our component. """
"""Setup is called when Home Assistant is loading our component."""
# Get the name from the configuration. Use DEFAULT_NAME if no name provided.
name = config[DOMAIN].get(CONF_NAME, DEFAULT_NAME)
@ -29,7 +29,7 @@ def setup(hass, config):
# States are in the format DOMAIN.OBJECT_ID
hass.states.set('hello_state.hello', name)
# return boolean to indicate that initialization was successful
# Return boolean to indicate that initialization was successfully.
return True
```