Extract developer site (#5249)

* Extract developer site

* Fix title in sidebar

* Update dev section reference

* Update edit in github link on help page
This commit is contained in:
Paulus Schoutsen 2018-04-26 11:14:55 -04:00 committed by GitHub
parent a83fd1d874
commit 80b268cd65
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
75 changed files with 282 additions and 4166 deletions

View file

@ -9,49 +9,6 @@ sharing: true
footer: true
---
The goal of development 101 is to get you familiar with the basics of developing for Home Assistant. Before we start, please make sure you familiarize yourself with the [architecture].
To get our code running inside Home Assistant we're going to create a custom component. The first step is to locate your config folder. You can find the path to your config folder by opening the Home Assistant frontend, click on the <img src='/images/screenshots/developer-tool-about-icon.png' alt='service developer tool icon' class="no-shadow" height="38" />. It's the path after the text "Path to configuration.yaml".
Inside your configuration directory create a new folder called `custom_components`. It might be that one already exists, that's fine too. This is the folder that Home Assistant will look at when looking for custom code.
<p class='note'>
The Home Assistant API has two variants: a synchronous and an asynchronous version (asyncio). This development course will focus on the synchronous version.
</p>
To verify that everything is working correctly, let's create a small Hello World component. To do so, create a file called `hello_world.py` in your custom components folder. Copy paste the following content to it:
```python
# The domain of your component. Equal to the filename of your component.
DOMAIN = "hello_world"
def setup(hass, config):
"""Setup the hello_world component."""
# States are in the format DOMAIN.OBJECT_ID.
hass.states.set('hello_world.Hello_World', 'Works!')
# Return boolean to indicate that initialization was successfully.
return True
```
Last step is to add `hello_world:` entry to your `configuration.yaml` file.
```yaml
# Hello World component
hello_world:
```
After running `hass`, we should see log entries stating that `hello_world` component was loaded. What is more, additional state card shall appear within main panel.
```log
2018-04-03 21:44:20 INFO (MainThread) [homeassistant.loader] Loaded hello_world from custom_components.hello_world
2018-04-03 21:44:20 INFO (MainThread) [homeassistant.setup] Setting up hello_world
```
<p class='img'>
<img src='/images/screenshots/hello-world-state-card.png' />
State card showing that Hello World component is working as intended.
</p>
[architecture]: /developers/architecture/
<script>
window.location = 'https://developers.home-assistant.io/docs/en/dev_101_index.html';
</script>